5
Reply

Want to save as Excel 2013 format (xlsx)

Asp.Net Hein

Asp.Net Hein

May 19 2015 4:48 AM
716
Hello, I want to save the gridview to excel file. If I change the place of (.xlsx) to (.xls) , it is saved as 97-2003 excel format.
 
But now I change the (.xlsx).
It is saved as excel file.But I cannot reopen the excel file.
 
Can anybody help me in my problem?
Thanks a lot :-)
 
grvid.AllowPaging = false;
getgrid();
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=file-name.xlsx");
Response.ContentType = "application/vnd.xlsx";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
grvid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
grvid.AllowPaging = true;
getgrid();

Answers (5)