View Single Post
  #1 (permalink)  
Old March 20th, 2007, 02:27 PM
Sir Guso Sir Guso is offline
Registered User
Join Date: Mar 2005
Location: Minneapolis, Minnesota, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Inline Excel Output Filename

I have searched many forums on my problem and tried many things that I have seen but nothing seems to work. So, perhaps I will be lucky and someone will be able to help me.

I have a 1.1 .NET project that I redirect to from another website in order to generate an Excel report. Up until now we have been writing to a file on the server, redirect to that file, then the user can save or open it. That worked finr but can no longer do that and must instead produce the Excel document within the browser using the inline parameter in a Response.AddHeader and giving it a filename. The problem is that this filename is ignored and when the user tries to save the opened Excel file the filename that is there is "Copy of TheInitialAspxPageName.aspx."

I am running it on my PC currently as a test project but I get the same result when I port whatever code to teh actual reporting application and place it on the server to use. My test app has a start page called ReportStart.aspx and all it has is a button that when clicked does a server transfer to a page that is used to figure out what report is coming in so as to send the right variables and then perform another "server.transfer" to the page that generates the Excel output. On that page the Excel output is created and put into a memstream. Below is the latest code (end of Page_Load code) I am trying -- please respond if you have any idea of how to solve this. You will see some commented out lines of what was tried before and also did not help. Thanks.

string textFileParameters = "inline; filename=" + reportName + ".xls";
//Response.Buffer = true;

//Response.ContentType = "application/x-msexcel";
Response.ContentType = "application/msexcel";

//Response.Expires = -1;
//Response.Buffer = true;
Response.Buffer = false;

//Response.ContentType = "application/";
//Response.AddHeader("Cache-Control", "max-age=0");

System.IO.MemoryStream memStream = new System.IO.MemoryStream();