Articles in this section
Category / Section

How to exclude columns from being exported in Xamarin.Forms DataGrid?

1 min read

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.

 

Order ID

 

 

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.

 

Customer ID

 

Sample Link for Xamarin.Forms:

How to exclude certain columns from being exported in SfDataGrid in Xamarin Forms?

Sample Link for Xamarin.Android:

How to exclude certain columns from being exported in SfDataGrid in Xamarin Android?

 

 

Conclusion

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.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

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 forumsDirect-Trac, or 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)
Please sign in to leave a comment
Access denied
Access denied