Export to PDF or Excel causes "Input string was not in a correct format" and "Index was outside the bounds of the array"

When trying to export in excel.
Stack Trace:
System.FormatException: Input string was not in a correct format.
     at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
     at Syncfusion.Blazor.Grids.Internal.GridExcelExport`1.ProcessHeaderContent()
     at Syncfusion.Blazor.Grids.Internal.GridExcelExport`1.IterateElements()
     at Syncfusion.Blazor.Grids.Internal.GridExcelExport`1.ExecuteResult(SfGrid`1 GridModel, Object dataSource)
     at Syncfusion.Blazor.Grids.Internal.GridExcelExport`1.ExportHelper(SfGrid`1 gridModel, Object dataSource)
     at Syncfusion.Blazor.Grids.Internal.GridExcelExport`1.ExcelExport(SfGrid`1 GridModel, ExcelExportProperties ExportProperties)
     at Syncfusion.Blazor.Grids.SfGrid`1.ExcelExport(ExcelExportProperties excelExportProperties, Nullable`1 isMultipleExport, Object workbook, Nullable`1 isBlob

When some columns are selected/unselected and trying to export in pdf.
Stack Trace:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
     at Syncfusion.PdfExport.PdfGridCellCollection.CheckIndex(Int32 index)
     at Syncfusion.PdfExport.PdfGridCellCollection.get_Item(Int32 index)
     at Syncfusion.Blazor.Grids.Internal.GridPdfExport`1.ProcessColumnHeader(GridColumn column)
     at Syncfusion.Blazor.Grids.Internal.GridPdfExport`1.ProcessHeaderContent()
     at Syncfusion.Blazor.Grids.Internal.GridPdfExport`1.IterateElements()
     at Syncfusion.Blazor.Grids.Internal.GridPdfExport`1.ExportHandler()
     at Syncfusion.Blazor.Grids.Internal.GridPdfExport`1.ExecuteResult(SfGrid`1 GridModel, Object dataSource)
     at Syncfusion.Blazor.Grids.Internal.GridPdfExport`1.PdfExportHelper(SfGrid`1 GridModel, Object dataSource)
     at Syncfusion.Blazor.Grids.Internal.GridPdfExport`1.PdfExport(SfGrid`1 GridModel, PdfExportProperties CustomPdfProperties, Boolean multipleExport)
     at Syncfusion.Blazor.Grids.SfGrid`1.PdfExport(PdfExportProperties pdfExportProperties, Nullable`1 isMultipleExport, Object pdfDoc, Nullable`1 isBlob)

7 Replies

RS Renjith Singh Rajendran Syncfusion Team August 6, 2020 12:22 PM UTC

Hi Yaroslav, 

Greetings from Syncfusion support. 

We tried to reproduce the reported problem with our latest version 18.2.0.48, but the export works fine in our sample. We are attaching the sample for your reference. Please download the sample from the link below, 
 
We are not clear about the exact scenario you are facing the reported problem from your side. If you are still facing difficulties, then the following details would be helpful for us to further validate the problem and provide you a solution as early as possible. Kindly get back to us with the following details to proceed further on this, 

  1. Share the sample which you have tried from your side. This would be helpful for us to validate the problem based on your scenario.
  2. Share the complete Grid rendering codes. We need to analyze the properties and GridColumn you have used in Grid.
  3. Share the Grid’s model class code.
  4. Share the exact scenario you are facing this problem.
  5. Share with us a video demo showing the replication procedure for the problem.
  6. And also share the export method codes you are using in your application.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran 



AS ashimaz March 8, 2022 12:31 PM UTC

Hi, I am also having same issue when using Adaptors.CustomAdaptor.

Export is working fine with direct datasource bninding but when used
Adaptors.CustomAdaptor its not working


Syncfusion.Blazor.Grid" Version="19.4.0.43"


Error


blazor.server.js:1 [2022-03-08T07:24:42.995Z] Error: System.NullReferenceException: Object reference not set to an instance of an object.

at Syncfusion.Blazor.Grids.Internal.GridExcelExport`1.System.IDisposable.Dispose()

at Syncfusion.Blazor.Grids.SfGrid`1.ExcelExport(ExcelExportProperties excelExportProperties, Nullable`1 isMultipleExport, Object workbook, Nullable`1 isBlob)

at SystemUsers.ToolbarClickHandler(ClickEventArgs args) in SystemUsers.razor:line 156

at System.Threading.Tasks.Task.<>c.b__128_0(Object state)

at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)

at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

--- End of stack trace from previous location ---

at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)



AS ashimaz March 8, 2022 12:52 PM UTC

Hi, tried with "Syncfusion.Blazor.Grid" Version="19.4.0.55", still same issue.



RG Rachel Gomez March 8, 2022 01:21 PM UTC

Steps To Save Or Export Each Sheet As CSV/PDF File In Excel-

As you know, Microsoft Excel can save current worksheet as an individual .csv file or PDF file. Therefore, you can save or export every sheet as .csv file or PDF file one by one manually.

1. Switch to the sheet that you will save or export as an individual .csv file, and click File (or Office button) > Save As.

2. In the opening dialog box, specify the destination folder that you will save the .csv file into, click the Save as type box and select CSV (Comma delimited) (*.csv) or PDF (*.pdf) from the drop down list, and click the Save button.

3. There will be two warning dialog boxes coming out successively. Please click OK > Yes.

Note: If you save active worksheet as PDF file, these dialog boxes won't pop up. Just go ahead to next step.

4. Repeat above step 1-3 to save other sheets as individual .csv files one by one.


Regards,

Rachel Gomez



SH Shimaz March 9, 2022 07:49 AM UTC

Hi Gomez, Your solution is totally unrelated to above issue, this is not an excel issue.



RS Renjith Singh Rajendran Syncfusion Team March 9, 2022 09:32 AM UTC

Hi ashimaz, 
 
We checked this scenario by creating a sample to export Grid bind with data from CustomAdaptor. But we could not reproduce the reported problem with the sample from our side. We are attaching the sample for your reference. 
 
On further analyzing the shared exception details, we suspect that you might have missed enabling AllowExcelExport property in Grid. So we suggest you to check this scenario by referring the above sample and ensure enabling AllowExcelExport property in Grid. 
 
If you are still facing difficulties then the following details would be helpful for us to proceed further. 
 
  1. Share the exact scenario you are facing this reported problem.
  2. Share a simple issue reproducing sample based on your scenario.
  3. Or if possible reproduce the problem with the above attached sample and share with us for further analysis.
  4. Share the complete grid codes and model class codes
 
The provided information will help us analyze the problem, and provide you a solution as early as possible. 
 
Regards, 
Renjith R 



AS ashimaz March 9, 2022 02:30 PM UTC

Turns out the error was due to this AllowExcelExport="true", I didnt put this on grid.


Loader.
Up arrow icon