VB.NET - AutoFit Functionality - Asked By Ryan Weaver on 18-Jul-14 05:59 PM

Refer to this article when looking into my question: http://www.nullskull.com/faq/501/export-datatable-to-excel-sheet-using-vbnet.aspx

Is there a way I can autofit the excel page before saving it the the file path?  I have everything working, but my data doesn't come up looking as nice as I want it to be.  An autofit would make the result look great.

Robbe Morris replied to Ryan Weaver on 18-Jul-14 06:01 PM
.cells(1,1).ShrinkToFit = True

What I typically do with stuff like this is to use the Macro recorder in Excel to record me manually doing what I want done, stop the recording, and the Edit the macro.  The code it generates is usually dead on for what I need.