Welcome Guest ( Log In | Register )

Bump Topic Topic Closed RSS Feed

Outline · [ Standard ] · Linear+

> Flush Excel in Asp.net

views
     
TSshinchan^^
post Feb 22 2006, 09:20 AM, updated 14y ago

K66
*********
All Stars
21,031 posts

Joined: Jan 2003
From: Pekopon


I want to prompt the save,open,cancel dialog and stream the file to the web user.
I did the pdf one and it works



CODE
String file = Request.QueryString["file"];
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition","attachment;filename="+file);
Response.WriteFile(@"\\WORKSTATION\OSC\LIMIT\"+file);
Response.Flush();
Response.Close();
RegisterStartupScript("closeWindow","<script language='javascript'>window.close();</javascript>");
Response.End();


now i want to change to excel type

CODE
String file = Request.QueryString["file"];
Response.ContentType = "application/excel";
Response.AddHeader("Content-Disposition","attachment;filename="+file);
Response.WriteFile(@"\\WORKSTATION\OSC\LIMIT\"+file);
Response.Flush();
Response.Close();
RegisterStartupScript("closeWindow","<script language='javascript'>window.close();</javascript>");
Response.End();


Excel can be downloaded and open. but it is corrupted, mainly asciii code

any idea?

i try
"application/nvd.excel"
"application/nvd.ms-excel"
"application/excel"
"application/ms-.excel"

all cannot
aiseh
TSshinchan^^
post Feb 22 2006, 09:33 AM

K66
*********
All Stars
21,031 posts

Joined: Jan 2003
From: Pekopon


d*mn instead of downloading

i think i m getting a conversion of the aspx. to excel

no wonder get weird output

This post has been edited by shinchan^^: Feb 22 2006, 09:33 AM
TSshinchan^^
post Feb 22 2006, 04:37 PM

K66
*********
All Stars
21,031 posts

Joined: Jan 2003
From: Pekopon


aiya solved myself

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition","attachment;filename="+file);

Topic ClosedOptions
 

Switch to:
| Lo-Fi Version
0.0298sec    3.47    5 queries    GZIP Disabled
Time is now: 21st November 2019 - 06:20 PM