We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

save grid as excel - file download dialog

Thread ID:





50093 Oct 5,2006 08:08 AM Feb 13,2008 06:30 AM ASP.NET Web Forms (Classic) 2
Tags: FAQ
Irina Jouk
Asked On October 5, 2006 08:08 AM


I do the export of grid from web page to excel using
httpResp.ContentType = "application/x-unknown";
httpResp.AddHeader("Content-Disposition", "attachment; filename=" + myfilename + ";");

I set application to unknown and did not add .xls to file name in order not to display ‘open’ button on the file download dialog box, because users do not want that button. The problem is that when user clicks ‘save’ than in save as type dropdown only doc type can be selected, there is no excel spreadsheet in the type selection list. Is there way to control that? May be some parameter of httpResp.ContentType? I need hide ‘open’ button and let user save as excel.

Thanks in advance

Replied On February 13, 2008 06:28 AM

HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + strPath.Name);
HttpContext.Current.Response.AddHeader("Content-Length", strPath.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.ContentType = "text";

Replied On February 13, 2008 06:30 AM

HttpContext.Current.Response.ContentType = "text";


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.