troubleshooting Question

How can I display the gridlines in a spreadsheet exported from a VB.Net web gridview?

Avatar of klgrube
klgrube asked on
.NET ProgrammingASP.NET
21 Comments1 Solution2680 ViewsLast Modified:
Hi!

    I'm successfully exporting a griview on an ASP.Net web form to an Excel file.  My problem is that the resulting new Excel file doesn't have the 'gridlines' option checked, so there are not gridlines showing on the newly-created file!  I don't want to use the gidlines from the gridview, mainly because they're just not Excel's real gridlines.

   In code - as I'm creating the stringwriter and rendering the HTML to export the gridview - how can I tell Excel to check the checkbox for 'Gridlines' in its Options, or more accurately, how can I set that option for the newly-created Excel file from within code?  Perhaps I need to export this as a CSV instead or something.  I'd hate to have to save the file on the server and then open it back up for the user.  Right now it just asks them if they want to open or save the file.  Either way, no gridlines.

   I've seen this question out there a fair amount of times.  I've even asked before last February on the ASP.Net forums, but never got an answer.  So, if we can come up with an answer that would be great.

   Oh, I'm using VB.Net, VS 2005, and Office 2003, if that helps.  All I'm looking for are the few lines of code that I can place into the 'on click' event of the Export button that contains the code that actually exports the gridview to Excel, that will allow the file to be opened up with gridlines displaying.

   Please let me know!

Thanks!
Karen
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 21 Comments.
Join the Community
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 21 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