Gantt Chart Export Excel Feature Not Working

Hi Syncfusion Team,

I was trying to implement the Export to Excel feature of the Gantt chart component, but the operation does not work. Instead, it produces the exception message below.

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 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 Syncfusion.Blazor.TreeGrid.SfTreeGrid`1.ExcelExport(ExcelExportProperties excelExportProperties, Nullable`1 isMultipleExport, Object workbook, Nullable`1 i
sBlob)
at Syncfusion.Blazor.Gantt.SfGantt`1.ExportToExcelAsync(ExcelExportProperties excelExportProperties)
at <Application>.Pages.Test.Sample.ExportCalendarToExcel() in <ApplicationDirectory>\Pages\Test\Sample.ra
zor:line 172


I did a quick debug but the Gantt object is not null nor the ExportProperties object.

One thing to note is that I'm not using the toolbar click event to trigger the Export operation but rather on a simple button click. I'm not sure how much of an impact that entails but we are not using the Gantt chart's toolbar generally.

Please advise as to how to resolve this issue. I'm attaching the razor page file where I'm experiencing the issue.

Many thanks!
Denzel


Attachment: Syncfusion_Query__Gantt_Chart_Export_to_Excel_not_working_c3233ddb.zip

3 Replies 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team September 10, 2021 05:16 AM UTC

Hi Denzel, 
 
Greetings from Syncfusion support. 
 
Thank you for sharing the issue reproducible sample. We were able to replicate the issue you reported. On analyzing the file you shared, we noticed that you did not set the AllowExcelExport property to true. This is the reason for the issue you reported. To enable Excel export in the Gantt chart, set the AllowExcelExport property as true. Once this property is set to true, we are able to perform Excel Export operations without any issues. The following snippets demonstrate the solution. 
 
Index.razor 
 
<SfGantt @ref="Gantt" 
    DataSource="@TaskCollection" 
    ProjectStartDate="@ProjectStart" 
    ProjectEndDate="@ProjectEnd" 
    GridLines="Syncfusion.Blazor.Gantt.GridLine.Both" 
    Height="600px" 
    TaskMode="ScheduleMode.Manual" 
    AllowExcelExport="true" 
    AllowUnscheduledTasks="true" 
    AllowFiltering="true"> 
 
 
We have modified the file you shared with the above code snippets and also prepared a sample for your reference. Please find them from the below links. 
 
 
To learn more about Excel Export in Gantt Chart, please refer our Online Documentation and Sample. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Marked as answer

RS Roy Sunga replied to Monisha Sivanthilingam September 10, 2021 01:34 PM UTC

Hi Monisha,

Thank you! I missed the AllowExcelExport property from the article as they have emphasized the ExportToExcelAsync() method more.

Anyway, the export function is now working on my end as well. Thank you for pointing out what I'm missing in code.

Best regards,

Denzel



MS Monisha Sivanthilingam Syncfusion Team September 13, 2021 05:00 AM UTC

Hi Denzel, 
 
You are welcome. 
 
We are glad that our solution worked for you. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Loader.
Up arrow icon