Bug when using ExportDocument to Excel

Stimulsoft Reports.WPF discussion
Post Reply
lavitzspear
Posts: 5
Joined: Thu Oct 17, 2019 1:34 pm

Bug when using ExportDocument to Excel

Post by lavitzspear »

I'm trying to create an excel document with about 100,000 lines but I receive the error : "Index was outside the bounds of the array". I tried changing the export settings but no parameter seems to fix that error.

I tried saving the mdc and exporting in excel from the viewer and strangely enough it works. When testing, I saw that if I have over 65536 record then the export create a new page in excel, but the export with the viewer does not. So what configuration do I need to change to be able to export the same way as the viewer.

This is the stacktrace :
à Stimulsoft.Report.Export.StiExcelExportService.WriteToOLEContainer() dans D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\Export\Services\Office\StiExcelExportService.cs:ligne 2829
à Stimulsoft.Report.Export.StiExcelExportService.ExportExcel(StiReport report, Stream stream, StiExcelExportSettings settings) dans D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\Export\Services\Office\StiExcelExportService.cs:ligne 3450
à Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, StiExportService exportService, Stream stream, StiExportSettings settings) dans D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\StiReport.Export.cs:ligne 771
à Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, String file, StiExportSettings settings) dans D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\StiReport.Export.cs:ligne 121
à Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, String file) dans D:\Stimulsoft\Stimulsoft.Reports\Stimulsoft.Report\StiReport.Export.cs:ligne 80
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Bug when using ExportDocument to Excel

Post by Lech Kulikowski »

Hello,

Please clarify which version are you use?

Also, 65536 is the maximum number of rows for the Excel 97-2003 file format.
Any .xls files that you open will be limited to that number of rows.

Thank you.
lavitzspear
Posts: 5
Joined: Thu Oct 17, 2019 1:34 pm

Re: Bug when using ExportDocument to Excel

Post by lavitzspear »

I'm using the version 2019.2.2

I know about the maximum number of rows. What I don't understand is why when I export using the viewer, the excel file does not have that limit, whereas when I export in my application, there is that limit. Like I said, I tried changing the export settings, but I can't seem to find which one is the one that could change that.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Bug when using ExportDocument to Excel

Post by HighAley »

Hello.

Do you use the same format for the export?
The xlsx format supports more rows on the sheet.

Thank you.
lavitzspear
Posts: 5
Joined: Thu Oct 17, 2019 1:34 pm

Re: Bug when using ExportDocument to Excel

Post by lavitzspear »

Either I'm explaining poorly or you are not understanding my question correctly, so I added a screenshot that will hopefully explain better what I need to know.
stimulsoft report settings.png
stimulsoft report settings.png (36.62 KiB) Viewed 4982 times
As you can see, those are the settings I use to export, but the ExportDocument function is crashing with the error message in my first post. By default, the ExcelType was ExcelBinary, which I think was the cause of the maximum number of lines being 65536, so I change it to Excel2007 but I still receive the error.

So what do I need to change to export like in the viewer, since that's working while this is not. Is it event in this parameter or there is something else I need to change.

Thank you.
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Bug when using ExportDocument to Excel

Post by Lech Kulikowski »

Hello,

Please send us a sample project which reproduces the issue for analysis.

Thank you.
lavitzspear
Posts: 5
Joined: Thu Oct 17, 2019 1:34 pm

Re: Bug when using ExportDocument to Excel

Post by lavitzspear »

I tried uploading the mdc but I always receive the error "Error parsing server response." I though it was because it was too big (675 Mo) so I zip it but I still receive that error message. Since the zip is also too big to send by email, I uploaded it here : https://filebin.net/5yw3ene4j4cj1wpo

Now remember that exporting with this mdc, everything works fine. But when I want to create the same result but with my application with the code in my third pôst, that is when I received the error in my first post.
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Bug when using ExportDocument to Excel

Post by Lech Kulikowski »

Hello,

> I'm trying to create an excel document with about 100,000 lines but I receive the error : "Index was outside the bounds of the array".
> I tried uploading the mdc

Thanks to your file, it allow to find the problem. it turned out that the size of the internal buffer was not enough.
The problem has not been crashed before, because before you no one has tried to export such large files to the Excel97-2003 format.
The fix will be in the next build.

> As you can see, those are the settings I use to export, but the ExportDocument function is crashing with the error message in my first post.
> By default, the ExcelType was ExcelBinary, which I think was the cause of the maximum number of lines being 65536, so I change it to Excel2007 but I still receive the error.

ExportSettings do not affect the type of expor, change ExcelType does not make sense.
The type of export depends only on the StiExportFormat parameter that you pass in the _StimulsoftExportFormat variable

"Excel" is Excel2007+, "xlsx" - StiExcel2007ExportService,
"Excel97-2003" is "xls", StiExcelExportService.

so the correct export code looks like this:
var es1 = new StiExcelExportSettings();
report.ExportDocument(StiExportFormat.Excel, @"d:\test.xls", es1);

var es2 = new StiExcel2007ExportSettings();
report.ExportDocument(StiExportFormat.Excel2007, @"d:\test.xlsx", es2);

Thank you.
lavitzspear
Posts: 5
Joined: Thu Oct 17, 2019 1:34 pm

Re: Bug when using ExportDocument to Excel

Post by lavitzspear »

I change the export settings for the correct one. I did not see that there was multiple ExportSettings.

Can you give me an estimate to when the next build will be released?

Thank you
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Bug when using ExportDocument to Excel

Post by Lech Kulikowski »

Hello,

The next build will be available within one or two weeks.

Thank you.
Post Reply