2017-06-02 115 views
0

我要出口gridcontrol EXCELL但我有一些浮點值,但是當我出口它,它是出口,如文本 我使用此代碼:DevExpress的gridcontrol EXCELL

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

後,我用Google搜索了一些,我發現財產以後:

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

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

link.ExportTo(true);它示數MEE這樣的:

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

plz help mee

回答

1

我不認爲你需要打擾GridViewExportLink。事實上,每導出到XLS文件:

打印鏈接(在WinForms和WPF)不支持這種[EXCEL] 出口模式,並使用數據感知輸出,需要調用 的特定控件的相應方法(例如GridControl)。

你可以簡單地用GridControl的ExportToXls method指定XlsExportOptions object

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