Adding Text to ListView Excel Export

D

DavidC

I am exporting to Excel from a ListView and it works fine except for my extra
text. I am trying to set the font size in an initial response.write text but
it is not working as it outputs it to the default text size of the ListView.
Below is my code to send to Excel. The line in question is the strClient
variable. Thanks.

Sub SendToExcel(ByVal Source As Object, ByVal E As EventArgs) Handles
LBtnExport.Click
Dim lb As Label = Page.Master.FindControl("LblPerson")
Dim strClient As String = "<tr><td style=""font-family: Verdana;
font-size: 20pt;"">" & lb.Text & "</td></tr>"
If PanelYTD.Visible Then
'Exporting YTD Summary
Dim gv As ListView = lvYTDSummary
gv.DataBind()
Dim tw As New StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=ytdsummary.xls")
Response.Charset = ""
EnableViewState = False
gv.RenderControl(hw)
Response.Write(strClient)
Response.Write(tw.ToString())
Response.End()
gv.DataBind()
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top