I am exporting a data grid to Excel using ExportToXlsx. Am having issue with column widths in Excel not being auto fit.
The code I use is:
GridView1.BestFitColumns()
GridView1.OptionsPrint.AutoWidth = False
GridView1.OptionsView.ColumnAutoWidth = False
GridView1.ExportToXlsx(Excel location and name)
The grid font is Tahoma 8. The column widths are correct in the grid.
When I open the Excel file the font is Calibri 11 (the default for Excel). From what I understand I can change the Excel default font/size for new worksheets only, am unable to have Excel open with a specific font/size of my choosing. Because the Excel font size is larger than the grid font size column content can be larger than column size.
If I open the exported Excel file, change the font/size, and save, then if I reopen the file it retains the font/size I supplied. However, when I export the file again and reopen the font goes back to Calibri 11.
I realize I could change the grid font but not something I prefer to do.
Is there any solution so the exported file will be Tahoma 8?