ASP.NET-created Excel files don't work properly in IE 8

Hi,

I have an ASP.NET web application that allows users to download reports and the contents of databases as Excel files, using the following construct:

        Dim context As HttpContext = HttpContext.Current
        context.Response.ClearHeaders()
        context.Response.ClearContent()
        context.Response.Clear()
        context.Response.AppendHeader("Content-Encoding", "text/html")
        context.Response.AppendHeader("Content-Type", "application/vnd.ms-excel")
        context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name + ".xls")

And then the user is prompted to Open or Save the file.

In IE 5, 6, and 7, Firefox 2 and 3, Opera, and every browser I've used recently, this works flawlessly. If you click "Open", the file opens in Microsoft Excel (provided the user has it).

But it doesn't work in IE 8. Once I click "Open", it starts Microsoft Excel, and then Excel says "Excel cannot access 'file[1].xls'. The document may be read-only or encrypted."  If you click "OK", it pops up a second error: 'file[1].xls' cannot be accessed. The file may be corrupted, located on a server that is not responding, or read-only".

If I choose "Save" instead of "Open", the file saves just fine.

If I set IE 8 to "Compatibility Mode" for my page, "Open" works just fine.

Adding the site to the "Trusted Sites" list made no difference.

So, I know this is an IE 8 issue, I just don't know how to solve it. I think it has something to do with how IE 8 saves the temporary files. Not sure.

Any suggestions?
CMES-ITAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
You does not seem to be alone with this problem
http://www.winvistatips.com/pdf-attachments-not-open-after-ie8-t175086.html

There is no fix or workaround yet.

>context.Response.AppendHeader("Content-Encoding", "text/html")
BTW, xls files are not html!
0
 
CMES-ITAuthor Commented:
I'm not sure that it's fair to accept a solution that there is no solution.

I don't care if you give him the points and close the question,  but if someone is looking for a solution to this problem, this is not a good answer.

Someone out there has figured out how to do Excel downloads in IE8. I am sure of it.
0
 
BadotzCommented:
>>I'm not sure that it's fair to accept a solution that there is no solution.

If that is the only answer, then why is it not acceptable?


You said:

If I set IE 8 to "Compatibility Mode" for my page, "Open" works just fine.

Isn't that the solution?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
CMES-ITAuthor Commented:
No, that's not the solution. I'm not the only one using my page, so my browser settings don't matter.

Now, there is a function for IE 8 where you add a line of code to the page header, and IE 8 forcefully renders the page in IE 7.

But, that still is not a solution. That's a hack.

To admit that there is no solution, or use the hack, is to admit that Microsoft purposefully broke Internet Explorer 8's ability to handle Excel files, and I find that highly unlikely, don't you?

The point of this being - perhaps EE doesn't have the answer. And that's disappointing, but acceptable. However, just because no one here reading this thread has the answer, doesn't mean there is one, and I don't think something should be marked as a solution when it isn't.
0
 
BadotzCommented:
Highly unlikely that they broke it on purpose? Yes.

Highly unlikely that they broke it? Nope. I've written enough software to understand how that could happen.

If you can determine that there *is* a solution, then post it here. We have access to the same tools as you, but our need for a fix may be not be as great as yours.
0
 
BadotzCommented:
"may be not be as great as yours"

Sheesh, even Yoda wouldn't say that ;-)
0
All Courses

From novice to tech pro — start learning today.