0
votes

I want to export gridcontrol excell but I have some float values but when I export it it is exporting like text I am using this code:

 gridControl1.ExportToXlsx("D:\\Turnover.xls");

after that I searched some and I found something:

 GridViewExportLink link;
       var provider = new ExportXlsProvider(fileName:@"D:\Trunover.xls");

        link = gridView1.CreateExportLink(provider) as GridViewExportLink;
        link.ExportCellsAsDisplayText = false;
        link.ExportTo(true);

but on link.ExportTo(true); it is erroring mee this:

Additional information: Object reference not set to an instance of an object.

1

1 Answers

1
votes

I don't think you need to bother with the GridViewExportLink. In fact, per the Export To XLS documentation:

Printing links (in WinForms and WPF) do not support this [Excel] export mode and to use the data-aware export, it is required to call the corresponding methods of specific controls (e.g., GridControl).

You can simply specify an XlsExportOptions object with the GridControl's ExportToXls method:

string FileName = "C:\\myfile.xls";
gridControl1.ExportToXls(FileName, new DevExpress.XtraPrinting.XlsExportOptions(DevExpress.XtraPrinting.TextExportMode.Value));