从报表导出excel文件时,我收到此错误,从报表预览中触发此操作.
xrptDoc.ExportToXlsX("D:\\ExportedFile.xlsx");
这是以下堆栈跟踪:
in DevExpress.XtraPrinting.Native.PSMessageBoxBase.ShowException(String text, String caption, IServiceProvider servProvider, Exception initialException)
in DevExpress.XtraPrinting.Native.PSMessageBoxBase.ShowException(Exception initialException, IServiceProvider servProvider)
in DevExpress.XtraPrinting.Native.FileExportHelper.ShowException(Exception e)
in DevExpress.XtraPrinting.Native.FileExportHelper.Execute(String path, Action1`1 callback)
in DevExpress.XtraPrinting.PrintingSystemBase.ExportXlsPage(String filePath, Action1`1 callback)
in DevExpress.XtraPrinting.PrintingSystemBase.ExportToXlsxInternal(String filePath, XlsxExportOptions options)
in DevExpress.XtraPrinting.PrintingSystemBase.ExportToXlsx(String filePath, XlsxExportOptions options)
in DevExpress.XtraReports.UI.XtraReport.ExportToXlsx(String path, XlsxExportOptions options)
in DevExpress.XtraReports.UI.XtraReport.ExportToXlsx(String path)
该异常有一个内部异常.哪个是相同的错误(通用GDI错误)但不同的堆栈跟踪:
in System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
in System.Drawing.Image.Save(Stream stream, ImageFormat format)
in DevExpress.XtraExport.XlsxPackage.AddDrawings(ZipArchive archive)
in DevExpress.XtraExport.XlsxPackage.CreateXlsxFile()
in DevExpress.XtraExport.ExportXlsxProvider.DevExpress.XtraExport.IExportProvider.Commit()
in DevExpress.XtraPrinting.Export.XLS.XlsExportProviderBase.Commit()
in DevExpress.XtraPrinting.Export.XLS.XlsExportProviderBase.CreateDocument(LayoutControlCollection layoutControls, Boolean correctImportBrickBounds)
in DevExpress.XtraPrinting.Export.XLS.XlsExportProviderBase.CreateDocument(Document document)
in DevExpress.XtraPrinting.Export.XLS.XlsxExportProvider.CreateDocument(Document document)
in DevExpress.XtraPrinting.PrintingSystemBase.ExportToXlsCore(XlsExportProviderBase xlsExportProvider)
in DevExpress.XtraPrinting.PrintingSystemBase.ExportToXlsx(Stream stream, XlsxExportOptions options)
in DevExpress.XtraPrinting.PrintingSystemBase.<>c__DisplayClassf.<ExportToXlsxInternal>b__d(Stream stream)
in DevExpress.XtraPrinting.Native.FileExportHelper.Execute(String path, Action1`1 callback)
最佳答案 看了你的截图后,我可能会假设你正在使用行(可能是XRCrossBandLines或/和XRCrossBandBoxes).如果这些行太长,Excel无法处理它们.例如,XRCrossBandLine从ReportHeader转到ReportFooter.如果这是真的,不要做这么长的路线.让它们从PageHeader转到PageFooter.在这种情况下,行将更短,Excel将能够处理它们.
另一件事我注意到你的报告可能有砖块.您应该在报表设计器中有相应的消息.如果这是真的,我建议你避免过渡,因为这样的布局可能无法正确导出到Excel.
如果它没有帮助,我建议你请DevExpress支持来看看这个问题.