PDA

View Full Version : How do i save a excel sheet in a Microsoft office excel workbook format?


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

M@rco
07-19-2008, 12:17 PM
This is an ASP.Net question... wrong forum!

Don't duplicate the post in the right place... an admin should move it there for you shortly...

4monkeys
07-31-2008, 01:09 PM
I wanted to make the same question…
an admin should move it there for you shortly...
...but the question is here from 23 days :confused:
Can I re-post the thread in aspnet?

M@rco
07-31-2008, 02:29 PM
Sorry, I have requested it to be moved again... if it hasn't been done within 24hrs then post again...