Last post Jan 12, 2011 12:34 PM by nilsan
Jan 12, 2011 09:34 AM|gfedz|LINK
I have been searching the web for a clear way on how to export gridview data to excel 2007/2010. All I have found is how to do it to excel 2003 format (xls). Does anyone have an exmaple or know how to export into excel 2007/2010? The code I've posted
is in 2003 and is working for xls, but I need it in the 2007/2010 format (xlsx).
Protected Sub btnExportDemand_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportDemand.Click
myGridViewDemand.AlternatingRowStyle.BackColor = Drawing.Color.White
Response.AddHeader("content-disposition", "attachment;filename=Demand_Report_" & Date.Today.ToString("MM-dd-yyyy") & ".xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim StringWriter As New System.IO.StringWriter()
Dim HtmlTextWriter As New HtmlTextWriter(StringWriter)
I have tried changing Response.ContextType to application/ms-excel; vnd.xlsx; octet-stream; vnd.openxmlformats-officedocument.spreadsheetml.sheet
Jan 12, 2011 09:53 AM|mehta.rahulit|LINK
Jan 12, 2011 10:36 AM|gfedz|LINK
I have already went through that post. There wasn't really anything on client side exporting. I found this link that anyone with this issue should read.
Jan 12, 2011 12:34 PM|nilsan|LINK
The code I've posted is in 2003 and is working for xls, but I need it in the 2007/2010 format (xlsx).
Please check out this
link an alternative way to export to excel.