Export html table into sheets of excel

Posted by Oswaldlily under ASP.NET on 8/29/2011 | Points: 10 | Views : 6120 | Status : [Member] | Replies : 1
I have 3 tables..my first table should come in sheet1 of excel
2nd table should come in sheet2 of excel.
third table should come in sheet3 of excel
is this correct?

Protected Sub lnk1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lnkExport.Click
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "application\vnd.ms-excel"
Response.AddHeader("Content-disposition", "attachment;filename=Export.xls")
Response.Charset = ""
Dim sw As System.IO.StringWriter = New System.IO.StringWriter()
Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
literal1.RenderControl(hw)
literal2.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()

Response.Clear()
Response.ClearHeaders()
Response.ContentType = "application\vnd.ms-excel"
Response.AddHeader("Content-disposition", "attachment;filename=Export.xls")
Response.Charset = ""
Dim sw1 As System.IO.StringWriter = New System.IO.StringWriter()
Dim hw1 As HtmlTextWriter = New HtmlTextWriter(sw1)
Literal3.RenderControl(hw1)
Literal4.RenderControl(hw1)
Response.Write(sw1.ToString())
Response.End()

Response.Clear()
Response.ClearHeaders()
Response.ContentType = "application\vnd.ms-excel"
Response.AddHeader("Content-disposition", "attachment;filename=Export.xls")
Response.Charset = ""
'Dim sw2 As System.IO.StringWriter = New System.IO.StringWriter()
Dim hw2 As HtmlTextWriter = New HtmlTextWriter(sw2)
Literal5.RenderControl(hw2)
Literal6.RenderControl(hw2)
Response.Write(sw2.ToString())
Response.End()
End Sub




Responses

Posted by: SheoNarayan on: 8/30/2011 [Administrator] HonoraryPlatinum | Points: 25

Login to post response