We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid Export To Excel Error Object reference not set to an instance of an object

I am receiving an Object reference not set to an instance of an object when trying to export data from the Grid to Excel.

Here is the stack trace:
[NullReferenceException: Object reference not set to an instance of an object.]
   Syncfusion.EJ.Export.GridExcelExport.Export(GridProperties gridModel, Object dataSource, Boolean multipleExport) +101
   Syncfusion.EJ.Export.ExcelExport.Export(GridProperties gridmaodel, Object datasource, String excelname, ExcelVersion excelversion, Boolean isHideColumnIncude, Boolean isTemplateColumnIclude, String theme, Boolean multipleExport) +104
   Syncfusion.EJ.Export.ExcelExport.Export(GridProperties gridmaodel, IEnumerable datasource, String excelname, ExcelVersion excelversion, Boolean isHideColumnIncude, Boolean isTemplateColumnIclude, String theme, Boolean multipleExport) +35
   Shared.ExportSyncFusionGrid.ExportToExcel(IEnumerable rows, GridProperties gridProperties, String fileName) in ExportSyncFusionGrid.cs:133
   Controllers.<ExportExitTradesToExcel>d__19.MoveNext() in BacktestResultController.cs:520
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +17
Here is the calling code:
Line 132:            var exp = new ExcelExport();
Line 133:            exp.Export(gridProperties, rows, fileName, ExcelVersion.Excel2010, false, false, "default-theme", false);

And the javascript code that calls the controller (I am passing an additonal parameter):

function onExitTradesToolbarClick(args) {
switch (args.itemName) {
case "Excel Export":
this.export(settings.exportExitTradesToExcelUrl + "/" + currentBacktestResultId);
args.cancel = true;
break;
default:
this.refreshContent();
break;
}
}


I am using the latest version of Syncfusion on Windows 10.

Regards, Jeff

3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team August 15, 2016 07:25 AM UTC

Hi Jeffrey, 

Thanks for contacting Syncfusion Support. 

We are unable to reproduce the issue at our end. We have prepare a sample that can be downloaded from the following location. 


Please share the following information to analyze the reported issue and provide you solution as early as possible. 

1)      Code example of Grid and code behind 
2)      Modify the attached sample and replicate the issue. 

We also suggest to ensure the whether the following dlls/assemblies of same version were referred in your application. 

1.  Syncfusion.EJ 
2.  Syncfusion.EJ.Export 
3.  Syncfusion.Linq.Base 
4.  Syncfusion.Compression.Base 
5.  Syncfusion.DocIO.Base 
6.  Syncfusion.XlsIO.Base 
7.  Syncfusion.PDF.Base 

Refer to the following Help Document.  


Please ensure whether the older dlls/assemblies referred from the bin folders. So we suggest to clear the bin folders and run your application. 

Regards, 
Seeni Sakthi Kumar S. 



JS Jeffrey Stone August 16, 2016 01:31 AM UTC

Seeni,

Thank you for the quick response.

I figured out the problem.

The controller had been changed to async and the row retrieving the data had .ConfigureAwait(false). The exporting worked after removing .ConfigureAwait(false).
I also tested this out on several other grids in my project and had the same behavior.

public async Task ExportToExcel(string GridModel)
{
            var gridProperties = ExportSyncFusionGrid.ConvertGridObject(GridModel);
            // this does not work - var rows = await GetBacktestRowsAsync().ConfigureAwait(false);
            var rows = await GetBacktestsAsync(); // this works!
            ExportSyncFusionGrid.ExportToExcel(rows, gridProperties);
}

Regards, Jeff


MS Mani Sankar Durai Syncfusion Team August 16, 2016 12:34 PM UTC

Hi Jeffrey,  
 
Thanks for your feedback. 
 
We have happy to hear that your requirement is achieved. 
 
Please let us know if you need further assistance.  
 
 
Regards, 
Manisankar Durai. 
                                                                                                                  


Loader.
Up arrow icon