Grid Export to excel when dataset is a list of expandoobjects

Hi, I'm traying to expeort to excel from a grid when the datasource is a list of expando objects and it doesn't work. Can't find any example. Need some help.


The grid shows correctly but as I said can't export to excel.

                <SfGrid ID="Grid" Height="100%" EnableVirtualization="false" DataSource="@GridDataSource" @ref="Grid"

                        AllowPaging="true" AllowResizing="true" AllowExcelExport="true" Toolbar="@(new List<string>() { "ExcelExport" })">

                    <GridEvents OnToolbarClick="ToolbarClick" TValue="ExpandoObject"></GridEvents>

                    <GridColumns>

                        @for (int igr = 0; igr < ColumnsNamesNum; igr++)

                        {



                            <GridColumn Field=@ColumnsNames[igr] HeaderText=@ColumnsNames[igr] Width="150" ></GridColumn>


                        }

                    </GridColumns>

                </SfGrid>


3 Replies

RN Rahul Narayanasamy Syncfusion Team October 25, 2021 12:40 PM UTC

Hi Onesimo, 

Greetings from Syncfusion. 

Query: Grid Export to excel when dataset is a list of expandoobjects 

We have validated your query and checked the reported problem at our end. We could not face any problem while excel exporting with list of ExpandoObject as Grid Datasource. Find the below sample for your reference. 


If you are still facing the problem, then could you please share the below details regarding your query. It will be helpful to validate and provide a better solution. 

  • Share the exception details.
  • Full Grid code snippets.
  • Video demonstration of the problem.
  • Reproduce the problem in the provided sample and revert back to us.
  • Share a simple reproduceable sample if possible.

Regards, 
Rahul 



ON Onesimo replied to Rahul Narayanasamy October 25, 2021 01:07 PM UTC

Thank you very much.


I found the solution. Just have to define the column names in the ExcelExportProperties column property before calling the export to excel function.

I also define the dataset in the DataSource parameter.




VN Vignesh Natarajan Syncfusion Team October 26, 2021 03:40 AM UTC

Hi Onesimo,  

Thanks for the update.  

We are glad to hear that you have resolved your query on your own.  

Kindly get back to us if you have further queries. 

Regards, 
Vignesh Natarajan  


Loader.
Up arrow icon