Solved

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

Posted on 2009-05-18
7
1,915 Views
Last Modified: 2013-12-08
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?
0
Comment
Question by:CMES-IT
  • 3
  • 2
7 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24419394
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
 

Author Comment

by:CMES-IT
ID: 25150837
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
 
LVL 29

Expert Comment

by:Badotz
ID: 25151216
>>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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

Author Comment

by:CMES-IT
ID: 25152468
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
 
LVL 29

Expert Comment

by:Badotz
ID: 25152610
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
 
LVL 29

Expert Comment

by:Badotz
ID: 25152619
"may be not be as great as yours"

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Now-a-days, indirectly, postal services have been replaced by email services. Yes, whenever we hear the word "email" a lot of people only think of gmail. Some people still think that email and gmail are one and the same thing :-). Let's see some …
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question