2017-06-02 125 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)); 
相关问题