Click here to Skip to main content
15,924,982 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

This is my code...

showing format extenton error. If i click yes after open excel file..

Please hele me.

Response.ClearContent();
Response.Buffer = true;
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment;filename="Report.xls);
//Response.AddHeader("content-disposition", String.Format(@"attachment;filename={0}.xls", sheetName.Replace(" ", "_")));
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
SalesGrid.AllowPaging = false;
SalesQuery(Convert.ToDateTime(TxtFromDt.Text), Convert.ToDateTime(TxtToDt.Text));
SalesGrid.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
Posted
Comments
VICK 24-Sep-13 6:17am    
attachment;filename="Report.xls);

do you have file with extension .xls or xlsx mean 2007 version..

Coz might be format extension error could be coz of version difference.
VICK 24-Sep-13 6:18am    
2ndly try to put debugger in the code to get the exact location of the error.. so that problem could be properly handled.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900