save grid as excel - file download dialog

Hi,

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

2 Replies

SA Saranyan February 13, 2008 11:28 AM UTC

HttpContext.Current.Response.Clear();
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";
HttpContext.Current.Response.WriteFile(strPath.FullName);
HttpContext.Current.Response.End();



SA Saranyan February 13, 2008 11:30 AM UTC

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



Loader.
Up arrow icon