Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know how to export multiple panels to excel. I got this code:
C#
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename= Report.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
Panel4.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()

It only works for 1 panel only. If I add another panel and add in the code still doesn't work. is there any way to do this?

This is my code for 2 panels:
C#
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename= Report.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
Dim stringWrite2 As New System.IO.StringWriter()
Dim htmlWrite2 As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite2)
Panel4.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Panel2.RenderControl(htmlWrite2)
Response.Write(stringWrite2.ToString())
Response.End()
Posted
Updated 12-Nov-14 19:34pm
v4
Comments
DamithSL 12-Nov-14 22:34pm    
update the question with the code you have tried with two panels

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900