troubleshooting Question

Exporting to Excel and maintaining Excel's Gridlines

Avatar of rito1
rito1 asked on
6 Comments1 Solution453 ViewsLast Modified:
Hi All

I am using the following code to export a Gridview control to Excel but have noticed that it removes Excel's gridlines within the worksheet that surrounds the Gridview data... Is it possible to keep the gridlines within the worksheet?

Protected Sub ExportButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=TableData.xls")
        HttpContext.Current.Response.Charset = ""
        HttpContext.Current.Response.ContentType = "application/vnd.xls"
        Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
        Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)

End Sub

Many thanks

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros