Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 20th, 2007, 02:27 PM
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/vnd.ms-msexcel";
//Response.AddHeader("Cache-Control", "max-age=0");

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


  #2 (permalink)  
Old March 28th, 2007, 10:58 AM
Registered User
Join Date: Mar 2005
Location: Minneapolis, Minnesota, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Weel, there have been no responses and I could not get a solution to this problem from anywhere I tried. One place I tried was Microsoft and they instead helped me use "Attachment" successfully by adding a line in the code of the calling page so I no longer had an issue using "Attachment." I guess that is what you have to use to get this to work right. Oh well. I tried.
  #3 (permalink)  
Old May 31st, 2007, 08:26 PM
Registered User
Join Date: May 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

If you use Isapi_Rewrite for IIS, there is a very clean solution to using "inline" and getting the correct file name for the Save As... Dialog.

Instead of making the link to ReportStart.aspx, make it to a fictional Directory like http://mysite/Download Reports/xx/MyFileNameAsIWouldLikeToSeeIt.xls where xx is the information ReportStart needs to be passed as a parameter.

In your httpd.ini for for isapi_rewrite, add a RewriteRule:

RewriteRule ([^.?]*?/)Download Reports/(.*)/(.*) $1ReportStart.aspx?id=$2 [I]

For those of you who don't live and breath Regex:

http://mysite/Download Reports/xx/MyFileNameAsIWouldLikeToSeeIt.xls

gets turned into:


The document should open in your browser. But the URL remains...Click Save As...and the file name is MyFileNameAsIWouldLikeToSeeIt.xls


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
inline assembly on VS2005 c++ PROBLEM Huskey C++ Programming 0 January 24th, 2007 10:58 AM
ASP to Excel - excel output formatting issue mat41 Classic ASP Professional 0 August 13th, 2006 06:41 AM
Output to Excel rgerald SQL Server 2000 9 July 7th, 2005 09:42 AM
Mail_IMAP->filename for inline attachments? kg Pro PHP 2 November 7th, 2004 09:01 AM
Saving Excel workbook with new filename tsegal20 Excel VBA 1 May 21st, 2004 01:55 PM

All times are GMT -4. The time now is 07:44 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.