C# – Export To Excel a gridcontrol from devexpress with autosize of columns

c++devexpresswinforms

I'm using a grid control from devexpress.I export the informations to excel using this code :

grdExport.ExportToXls('C:\Test.xls');

But when I export data to excel or pdf all the columns has width of 1 cm.How can I export to excel/pdf and make autosize to columns or keep the width columns from the grid?(in grid the columns has autosize and looks fine).

Thanks

Best Solution

Please try to call grdExport.BestFitColumns Method
and set grdExport.OptionsPrint.AutoWidth property to false.

Check this Question