Home     Products      Support      Corporate     Sign In 

Support Knowledge Base, Article 895

Product
ExcelWriter
Title
File Not Found error when attempting to open downloaded spreadsheet in Excel
Problem

An ExcelWriter-generated spreadsheet is streamed to the client using the option to open the file Excel (rather than the browser plug-in). The Open/Save dialog appears. If the user chooses to save the file to disk, the file is saved correctly. However, on certain client machines, the "open" option does not work and the file does not open in Excel. A "File Not Found" error is received.


This behavior has been seen on Windows XP and Windows 2003.
Solution

This problem can caused by the server sending HTTP response headers that tell the browser not to cache the response. It is common for developers to configure ASP or ASP.NET applications this way because they contain dynamic content. Telling the browser not to cache the page ensures it will always make a new request to the server and get the most up-to-date version of the page. However, in a page which generates an Excel file and streams it to the client, it is better NOT to turn off client-side caching because the file needs to stay around long enough for the browser to pass it to Excel.

Even if the server has told the browser not to cache the file, the actual behavior may be different on different client machines. On certain clients, the temp file will remain long enough for Excel to open it. But on some client configurations, the spreadsheet gets deleted immediately by the operating system and Excel will not be able to find it.

The HTTP headers which control client-side caching may have been set either in your ASP or ASP.NET code or in IIS. The solution is to turn off these HTTP headers, either by removing the lines of code, or disabling the settings in IIS.

In Your Code

By default, ASP and ASP.NET do not add any headers to control browser caching behavior. If the headers have been set in your page, you will see some combination of the following lines of code:

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

If you see these lines of code in your ExcelWriter page, remove them.

In IIS

The default IIS settings for a virtual directory do not cause the generation of HTTP headers that affect client-side caching behavior. However, if you are experiencing this problem and there is nothing in your code, it is a good idea to check IIS. If IIS settings are causing the headers to be generated, you will see something like this in the "HTTP Headers" tab in the properties dialog of your virtual directory:

To turn off these settings, uncheck "Enable Content Expiration" If you prefer to keep the "Enable Content Expiration" settings for all your other non-ExcelWriter pages, you can do the above step in the "properties" dialog for the specific ExcelWriter page rather than for the application as a whole.

Related Links
OfficeWriter Home Page
OfficeWriter Enterprise Edition
Latest OfficeWriter News
OfficeWriter: Programmatic Runtime Control

Created : 9/7/2006 1:01:26 PM (last modified : 2/26/2007 4:46:18 PM)

Rate this article!

 
Comments



Copyright 2006 © SoftArtisans, Inc. All Rights Reserved.

Site Map     |     Privacy Policy     |     Contact Us