Articles in this section

How to exclude columns from being exported in .NET MAUI DataGrid(SfDataGrid)?

The .NET MAUI DataGrid allows you to exclude specific columns from being exported to Excel or PDF.

Export to PDF:

You can fulfill this requirement when exporting to PDF by adding the column to be excluded in the ExcludeColumns property of the DataGridPdfExportOption.

The following code illustrates how to exclude certain columns from being exported to PDF.

C#:
DataGridPdfExportingOption option = new DataGridPdfExportingOption();
var list = new List<string>();
list.Add("EmployeeID");
option.ExcludedColumns = list;

The screenshot below displays the result of executing the aforementioned code. Please observe that the EmployeeID has been excluded from the exported grid.

Export to Excel:

Similarly, you can meet the requirement for exporting to Excel by adding the column to be excluded in the ExcludeColumns property of the DataGridExcelExportingOption.

The following code illustrates how to exclude certain columns from being exported to Excel.

C#:
DataGridExcelExportingOption option = new DataGridExcelExportingOption();
var list = new List<string>();
list.Add("EmployeeID");
option.ExcludedColumns = list; 

The screenshot below displays the result of executing the aforementioned code. Please observe that the EmployeeID has been excluded from the exported grid.

Download the complete sample from GitHub.

Conclusion

I hope you enjoyed learning how to exclude columns from being exported in .NET MAUI DataGrid (SfDataGrid).

You can refer to our .NET MAUI DataGrid’s feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to explore our .NET MAUI DataGrid and other .NET MAUI components.
Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac or feedback portal, or the feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied