How to exclude columns from being exported in Xamarin.Android Grid?
SfDataGrid allows you to exclude certain columns from being exporting to Excel or PDF.
Export to PDF
- You can achieve the requirement when exporting to PDF by adding the column to be excluded in the ExcludeColumns property of the DataGridPdfExportOption.
- You can then pass the created DataGridPdfExportOption instance as a parameter to the function ExportToPdf().
The below code illustrates how excludes certain columns from being Export to PDF.
DataGridPdfExportOption exportOption = new DataGridPdfExportOption(); exportOption.FitAllColumnsInOnePage = true; exportOption.ExcludeColumns.Add("OrderID"); var doc = pdfExport.ExportToPdf(this.dataGrid,exportOption);
The following screenshot shows the outcome on executing the above code. Note that OrderID has been excluded in the exported grid.
Export to Excel
Similarly, you can achieve the requirement when exporting to Excel by adding the column to be excluded in the ExcludeColumns property of the DataGridExcelExportingOption.
The below code illustrates how to excludes certain columns from being Export to Excel.
DataGridExcelExportingOption exportOption = new DataGridExcelExportingOption(); exportOption.ExcludedColumns.Add("CustomerID"); var excelEngine = excelExport.ExportToExcel(this.dataGrid,exportOption);
The following screenshot shows the final outcome on executing the above code. Note that CustomerID has been excluded in the exported grid.
Sample Link for Xamarin.Forms:
Sample Link for Xamarin.Android:
I hope you enjoyed learning on how to exclude certain columns from being exported in SfDataGrid.
You can refer to our Xamarin.Forms DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!