G
Guest
Hi
How can I Export an HTML Table to excel?
My goal is a button, and when the user clicks this button a popup appears
asking the user to 'open' or 'save' the generated Excel file.
Actually I'm exporting by rendering my table to an htmlwriter and sending
this to excel. This is working nearly perfect. There's a problem with Excel's
auto-formatting of cells.
Excel is changing the content of my cells. '1.23' is getting 'Jan 23',
'true' gets 'TRUE' and so on. Always if Excel recognizes a format it knows,
it changes the content.
How can I prevent Excel from doing this?
I want my content 'as is'. Means it shouldn't be changed.
If I need to change my export (creating a excel workbook and sheet in
asp.net) I need at least the coding framework to get one cell filled, because
all my attempts in doing this went to an exception
Here's the actual piece of code I'm using:
Dim sw As System.IO.StringWriter = New System.IO.StringWriter
Dim hw As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(sw)
Dim str_temp As String = "attachment;filename=dtsReport_" &
System.DateTime.Today.Month & "-" & System.DateTime.Today.Day & "-" &
System.DateTime.Today.Year & ".xls"
Response.Clear()
Response.AddHeader("content-disposition", str_temp)
Response.ContentType = "application/ms-excel"
tbl_temp.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()
How can I Export an HTML Table to excel?
My goal is a button, and when the user clicks this button a popup appears
asking the user to 'open' or 'save' the generated Excel file.
Actually I'm exporting by rendering my table to an htmlwriter and sending
this to excel. This is working nearly perfect. There's a problem with Excel's
auto-formatting of cells.
Excel is changing the content of my cells. '1.23' is getting 'Jan 23',
'true' gets 'TRUE' and so on. Always if Excel recognizes a format it knows,
it changes the content.
How can I prevent Excel from doing this?
I want my content 'as is'. Means it shouldn't be changed.
If I need to change my export (creating a excel workbook and sheet in
asp.net) I need at least the coding framework to get one cell filled, because
all my attempts in doing this went to an exception
Here's the actual piece of code I'm using:
Dim sw As System.IO.StringWriter = New System.IO.StringWriter
Dim hw As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(sw)
Dim str_temp As String = "attachment;filename=dtsReport_" &
System.DateTime.Today.Month & "-" & System.DateTime.Today.Day & "-" &
System.DateTime.Today.Year & ".xls"
Response.Clear()
Response.AddHeader("content-disposition", str_temp)
Response.ContentType = "application/ms-excel"
tbl_temp.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()