4

I'm getting this error when exporting an excel file from a report, firing this action from the preview of the report.

xrptDoc.ExportToXlsX("D:\\ExportedFile.xlsx");

This is the following stacktrace:

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)

The exception has an inner exception. Which is the same error (Generic GDI+ Error) but different stacktrace:

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)

Trying to export

jcvegan
  • 3,111
  • 9
  • 43
  • 66
  • Are you running the report creation from a service? (i.e. detached from the preview?) Are you including any image in the report? If this is the case, is the image available for reading during the whole creation of the report? – Alex Mazzariol Jun 01 '15 at 16:20
  • @AlexMazzariol not including images on the report. Just a table – jcvegan Jun 01 '15 at 16:29
  • Does the user have write permission on D: drive? Sorry for the seemingly trivial question, but may help exclude causes. – Alex Mazzariol Jun 01 '15 at 16:38
  • @AlexMazzariol Yes! I understand that question. Don't worry – jcvegan Jun 01 '15 at 16:52
  • Search google for GDI+ generic error. It can be lots of different things. Most common are locking issues (two threads/processes on the same file, file or image or memory was not disposed), and memory issues (image is just too big, check 32bits vs 64bits). – Simon Mourier Jun 02 '15 at 06:33
  • 2
    @jcvegan, this information is not enough to detect the issue's cause. I can suggest that you do the following: 1) adjust the VS as explained in this article: https://www.devexpress.com/Support/Center/Question/Details/K18549 , reproduce the problem and get a real callstack; 2) copy&paste it here. 3) provide the exact version of the XtraReports Suite you are using. Try to use the latest one (if you do not own it, you can always test TRIAL version, it is available to download from http://devexpress.com) and see if the issue is reproducible with it. – platon Jun 02 '15 at 08:11

1 Answers1

2

Having taken a look at your screenshot, I may assume that you are using lines (probably XRCrossBandLines or/and XRCrossBandBoxes). If those lines are too long, Excel can't process them. For example, XRCrossBandLine goes from ReportHeader to ReportFooter. If it's true, don't make such a long line. Make them go from PageHeader to PageFooter. In this case, the lines will be shorter and Excel will be able to process them.

Another thing I noticed that your report may have crossing bricks. You should have got a corresponding message in the report designer. If it's true, I suggest you avoid crossing since such a layout may not be exported to Excel correctly.

If it's not helpful, I'd suggest you ask DevExpress support to take a look at this issue.

Gosha_Fighten
  • 3,838
  • 1
  • 20
  • 31