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.Strin gWriter = New System.IO.Strin gWriter
Dim hw As System.Web.UI.H tmlTextWriter = New HtmlTextWriter( sw)
Dim str_temp As String = "attachment;fil ename=dtsReport _" &
System.DateTime .Today.Month & "-" & System.DateTime .Today.Day & "-" &
System.DateTime .Today.Year & ".xls"
Response.Clear( )
Response.AddHea der("content-disposition", str_temp)
Response.Conten tType = "applicatio n/ms-excel"
tbl_temp.Render Control(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.Strin gWriter = New System.IO.Strin gWriter
Dim hw As System.Web.UI.H tmlTextWriter = New HtmlTextWriter( sw)
Dim str_temp As String = "attachment;fil ename=dtsReport _" &
System.DateTime .Today.Month & "-" & System.DateTime .Today.Day & "-" &
System.DateTime .Today.Year & ".xls"
Response.Clear( )
Response.AddHea der("content-disposition", str_temp)
Response.Conten tType = "applicatio n/ms-excel"
tbl_temp.Render Control(hw)
Response.Write( sw.ToString())
Response.End()
Comment