downloading .xls files from the web

  • Thread starter Thread starter Fonzie
  • Start date Start date
Hi
I m new to ASP.net development.
I am making a proj tht involves downloading and saving excel sheets
from a URL like

http://www.puc-rio.br/marco.ind/xls/dp-chapter6-nonlinear_npv.xls

Can someone tell me how to do tht?

Thanx!
hi,
check using this..

-----------
Response.ContentType="application/ms-excel";
filepath=Server.MapPath("filepath");
Response.AddHeader( "content-disposition","attachment;
inline;filename='"filename"");
FileStream sourceFile = new FileStream(filepath, FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
Response.End();

regards,
gella
 
Response.ContentType="application/ms-excel";

Shouldn't the type be "application/vnd.ms-excel"? There's no such
thing as "application/ms-excel" listed at IANA (http://www.iana.org/
assignments/media-types/). I'm a bit new to MIME types so correct me
if I'm wrong!

Chris
 
Back
Top