export to excel specific columns

How can I avoid to export to Excel in a Net Maui Core 9 project the DataTemplate Columns ?

I found in the documentation this example

        DataGridExcelExportingOption option = new DataGridExcelExportingOption();

        var list = new List<string>();

        list.Add("OrderID");

        list.Add("Customer");

        option.ExcludedColumns = list;

but the DataTemplate columns don't have a mapping name

and if I simply use these lines on the export function when the datagrid has datatemplate columns I receive a null object reference in the second line


        DataGridExcelExportingController excelExport = new DataGridExcelExportingController();

        DataGridExcelExportingOption option = new DataGridExcelExportingOption();


Thanks


5 Replies 1 reply marked as answer

RM RiyasHameed MohamedAbdulKhader Syncfusion Team June 24, 2025 12:19 PM UTC

Hi Walter Martin,
We have reviewed your reported query and prepared a sample using the provided code snippet and information. The sample works as expected and does not encounter any crashes.

Additionally, you mentioned that you have not set a mapping name for the DataGridTemplateColumn. Please note that it is necessary to set a mapping name for the template column. During export, columns are included or excluded based on their mapping names, so it is not recommended to use a template column without a mapping name.

We have attached the tested sample for your reference. If you are still experiencing issues, could you please modify the attached sample to reproduce the problem? This will help us further validate and resolve your query.


Regards,
Riyas Hameed M


Attachment: DataGridMAUI_cfd14c11.zip

Marked as answer

WM Walter Martin June 24, 2025 08:53 PM UTC

It works perfectly thanks



RM RiyasHameed MohamedAbdulKhader Syncfusion Team June 25, 2025 01:52 PM UTC

Walter Martin,

We are pleased to hear that the provided solution is working well for you. Please feel free to reach out if you require any further assistance.



SR Sophie Raymond June 27, 2025 02:04 AM UTC

Alternatively, instead of excluding, you could build a custom export logic that only includes desired mapped columns and ignores template-based ones Sprunki Game.



RM RiyasHameed MohamedAbdulKhader Syncfusion Team June 27, 2025 11:41 AM UTC

Hi Sophie Raymond,

We would like to inform you that SfDataGridExport allows you to export the data displayed in the SfDataGrid. It also supports customization of the export logic based on your specific requirements.

Export to Excel in MAUI DataGrid control | Syncfusion®

Additionally, we have reviewed the link you provided, and it does not appear to be related to SfDataGrid. If you have any further questions, please feel free to ask.


Regards,
Riyas Hameed M


Loader.
Up arrow icon