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 ''

2. MS Excel cannot access the file ''.  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  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!
Who is Participating?
Ok, one other thing to try, but I'm afraid my example is in ColdFusion (I'm not too savvy with ASP):

<CFHEADER NAME="Content-disposition" VALUE="attachment;filename=myFile.xls;">
<CFCONTENT TYPE="application/" RESET="no">

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.

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.  
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.

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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/"  %>
<% 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 %>
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.

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.
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.

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/" %>
<% 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.
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!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.