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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:





125403 Aug 14,2016 07:38 PM UTC Aug 16,2016 12:34 PM UTC ASP.NET MVC 3
Tags: Grid
Jeffrey Stone
Asked On August 14, 2016 07:38 PM UTC

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;

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

Regards, Jeff

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On 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. 

Seeni Sakthi Kumar S. 

Jeffrey Stone
Replied On August 16, 2016 01:31 AM UTC


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

Mani Sankar Durai [Syncfusion]
Replied On 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.  
Manisankar Durai. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon