weiqiang_89
07-17-2008, 05:55 AM
Response.ClearHeaders()
Response.AppendHeader("content-disposition", "attachment;filename=exportedlist.xls")
Response.AppendHeader("Content-Type", "application/vnd.ms-excel")
Response.ContentType = "application/vnd.ms-excel"
Dim sw As IO.StringWriter = New IO.StringWriter()
Dim htw As New HtmlTextWriter(sw)
GridView.RenderControl(htw)
Response.Write(sw.ToString())
Response.End()
I had this coding which i can download to excel from a gridview.
But when i open the downloaded excel file, the format appears to be a webpage and it is save as a "exportedlist.xls" .
I want it to be save as a Microsoft office excel workbook format when it is first downloaded from an asp.net page because i need this format as i need to upload to the server then view in gridview then upload to the database.
I am using vb.net,Excel 2003,visual studio 2005.
Any help would be appreciated.
Thanks
Response.AppendHeader("content-disposition", "attachment;filename=exportedlist.xls")
Response.AppendHeader("Content-Type", "application/vnd.ms-excel")
Response.ContentType = "application/vnd.ms-excel"
Dim sw As IO.StringWriter = New IO.StringWriter()
Dim htw As New HtmlTextWriter(sw)
GridView.RenderControl(htw)
Response.Write(sw.ToString())
Response.End()
I had this coding which i can download to excel from a gridview.
But when i open the downloaded excel file, the format appears to be a webpage and it is save as a "exportedlist.xls" .
I want it to be save as a Microsoft office excel workbook format when it is first downloaded from an asp.net page because i need this format as i need to upload to the server then view in gridview then upload to the database.
I am using vb.net,Excel 2003,visual studio 2005.
Any help would be appreciated.
Thanks