[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 566
  • Last Modified:

IE 6 Export to Excel Issue (works in Firefox) (ASP file)

I've got a table of results that I'm trying to export to Excel (asp script) -- and although I can export them fine using Firefox, I get errors when using IE 6.0. I'm 99.9% sure the ASP and HTML are coded properly on the scripts (since it's working in Firefox), and I don't have any special security settings set on that file.

Here are the errors we get when we try to export this file from the web to Excel:

(If choosing "Open"):
1. Could not open 'http://www.mydomain.com/exportfile.asp'

2. MS Excel cannot access the file 'http://www.mydomain.com/exportfile.asp'.  There are several possible reasons:
-file name or path name does not exist
-file you're trying to open is being used by another program.  Close the document in the other program, and try again
-name of the workbook you're trying to save is the same name of another document that is read-only.  Try saving the workbook with a different name.

[I Can assure you it's NONE of the above in #2]

(If choosing to "Save") we get:
Internet Explorer cannot download exportfile.asp from www.mydomain.com/exportfile.asp.  IE was not able to open this Internet site.  The requested site is either unavailable or cannot be found.  Please try again later.

We get these errors on machines running Windows XP SP1, XP SP2, Excel 2002 SP2, Excel 2003 SP1.  My IE version is the latest as of the time of this posting (IE 6.0.2800.1106.xpsp2.040919-1003).  And my IE Security settings are in good shape (yes, I can enable downloads).
Note, that it's only when I try to export this file is when we get these errors, and that it is working fine on Firefox... I'm completely stumped, this one's worth a bunch of points.

Any help is thoroughly appreciated!
0
torys
Asked:
torys
  • 5
  • 4
1 Solution
 
torysAuthor Commented:
Also -- Microsoft does touch on this, but they're Hotfix isn't readily available (I don't want to pay for a support call), and it  doesn't address Excel 2000.  
See http://support.microsoft.com/?kbid=840386
0
 
Dain_AndersonCommented:
Do you have any no-cache headers in your ASP pages? That can cause the issue you're describing. We had the same issue with IE and Excel, but not with FireFox and Excel.

-Dain
0
 
torysAuthor Commented:
I added no-cache headers to the exportfile.asp page, but still getting same issue -- will I have to add the no-cache headers to the original page that has the cmdbutton that triggers exportfile.asp?

The headers look like:
<% Response.ContentType = "application/vnd.ms-excel"  %>
<% Response.Buffer = True %>
<% Response.ExpiresAbsolute = Now() - 1 %>
<% Response.Expires = 0 %>
<% Response.CacheControl = "private" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.AddHeader "cache-control", "no-store" %>
<% server.scripttimeout=500000 %>
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
Dain_AndersonCommented:
In IE, the no-cache headers cause the streamed data to "reset" as it's sent, so you'd want to remove them. Also, are you doing this over SSL? The same issue in IE can cause what you described.

-Dain
0
 
torysAuthor Commented:

Originally, no, I did not include the cache headers, so I'll be sure to remove them... I double checked an include file to make sure it didn't have any cache headers either.

And no, we are not using SSL on these pages.  Good thinking, but still stumped.
0
 
Dain_AndersonCommented:
Ok, one other thing to try, but I'm afraid my example is in ColdFusion (I'm not too savvy with ASP):

<CFCONTENT RESET="Yes">
<CFFLUSH INTERVAL="1">
<CFHEADER NAME="Content-disposition" VALUE="attachment;filename=myFile.xls;">
<CFCONTENT TYPE="application/vnd.ms-excel" RESET="no">
<CFOUTPUT>#Output#</CFOUTPUT>

You'll notice that I'm using the header "Content-Disposition" and attaching a pseudo filename, "myFile.xls" -- try using that header. Not sure if it will work, but it's worth a try. The code you're seeing does exactly what you're trying to do except in ColdFusion (we had the exact same problem).

Here's the kicker though: the first two lines are actually what we used to solve the problem, but I don't know the equivalent in ASP (if there is one). The first line flushes or "resets" the output stream before sending the dynamically-created Excel data; the second line tells the output stream to be flushed at interval of 1KB.

-Dain
0
 
torysAuthor Commented:
I'm still new to ASP myself, and I'm not sure it's a buffering issue, but regarding Response Object Methods in ASP, we have:

Clear - Empties any buffered return info to the browser
Flush - Sends teh data in the buffer immediately to the browser
End - Stops processing of ASP and returns any data in the buffer

(not sure about the flushing interval setting)...I'll see if I can translate your CF example into ASP and get back to you.

Thanks.
0
 
torysAuthor Commented:
I added a Buffering and flush setting in the header of exportfile.asp, so it looked like this:

<%@ Language=VBScript %>
<% Response.ContentType = "application/vnd.ms-excel" %>
<% Response.Buffer = True %>
<% Response.Flush %>
<% server.scripttimeout=500000 %>

And guess what... it WORKED!  Apparently we have to flush out the buffer before Excel will take the data from IE.  Thanks! Points awarded.
0
 
Dain_AndersonCommented:
Killer! Good to know!

I know that when we had the same problem, I beat my head against the wall for about 2 weeks trying to figure it out. In our case, IE didn't like _any_ content in the buffer before dynamically creating the file. What took us for a ride was that FireFox was smart enough to know when the file was being sent and didn't have any problems.

Anyway, I'm truly glad that worked out for you!

-Dain
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now