Grid export to excel generates error

Hi,

I am trying to export grid to excel and I am following instructions found in https://help.syncfusion.com/aspnetmvc/grid/exporting?cs-save-lang=1&cs-lang=csharp , but I am getting an error:  Object reference not set to an instance of an object. 
in Line 358: exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron");
I don´t know what object is not referenced. I am attaching snapshoots where you can see objects required by the instruction are instantiated.

Help will be appreciated.

Kind regards,

Juan J. Uribe



Attachment: Obj1_dea4215d.zip

3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team January 22, 2018 11:57 AM UTC

Hi Juan, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we are unable to reproduce the reported issue “Object reference not set to an instance of an object” from our end.  

So, we have prepared a sample with excel exporting and it can be downloadable from the below location. 


The mentioned issue will occurred when the columns bound to the Grid are not defined in the Grid dataSource. We have already discussed the same issue in following knowledge base document.  
 
 
For example if the column field name “Employee1” is not defined in Grid dataSource, the null exception will be thrown while exporting the Grid dataSource. So, please ensure the columns bound to the Grid are defined in the Grid dataSource before exporting the Grid. Still if you face the issue, kindly share the following information.  
 
1.     Scenario to reproduce the issue.  
2.     Essential studio and browser version details.  
3.     Share sample if possible or modify the attached sample as issue reproducible.  
 
Regards, 
Thavasianand S. 



JJ Juan Jose Uribe January 22, 2018 02:06 PM UTC

Hi,

I found out that the problem is this:
I have a view with a tab control with two items.
Each tab has a grid. The grid in the first tab (tabindex =0) does not have export tool. The grid in the second tab (tabindex = 1) does have the excel export tool.
After click in excel export button, I look at the GridModel that the controller receives and found that is the model of the first grid, not the grid that have the export button.
If I put the tab item with the grid that have the export button as the frist tab item, problem solved. So, what if I need to export from both grids?  Probably I have to do it, so I will appreciate your help.

Kind regards,

Juan J. Uribe

 


TS Thavasianand Sankaranarayanan Syncfusion Team January 23, 2018 12:02 PM UTC

Hi Juan, 

We have analyzed your query and we are unable to reproduce the reported issue “While exporting second Grid first Grid model get passed to the Export” from our end. 

We have prepared a sample based on your given detail and it can be downloadable from the below location. 


Provide the following details for better assistance. 

  1. Screenshot or video demonstration of the issue.
  2. Share full Grid client and server side code example.
  3. If you enable any adaptors in your sample ?
  4. If possible share the sample or reproduce the issue in the attached sample.
  5. Essential studio and browser version details.

Regards, 
Thavasianand S. 


Loader.
Up arrow icon