Mark B. – tech

Undetected File Type when downloading Excel File (ASP Classic)

Sometimes when downloading excel file from website, we get unknown file type (*.File).  To fix this, just add the content-type of file that you want to download. exp : “application/vnd.ms-excel”.

sample code :

Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName.Trim() + ".xls");
Response.WriteFile(pathfile);
Response.End();

Advertisements
This entry was published on April 18, 2011 at 4:12 am and is filed under IT Problem Solving. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: