Skip to content

SyncfusionExamples/How-to-apply-the-conditional-format-for-excel-sheet-exported-from-SfDataGrid-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to Apply the Conditional Format for Excel Sheet Exported from WPF DataGrid?

This example illustrates how to apply the conditional formatting to the exported excel in WPF DataGrid (SfDataGrid).

DataGrid does not provide direct support to the conditional formatting while exporting from the grid to excel sheet. But you can achieve this by applying the conditional formatting to the exported worksheet.

 var options = new ExcelExportingOptions();
 options.ExcelVersion = ExcelVersion.Excel2013;
 var excelEngine = sfDataGrid.ExportToExcel(sfDataGrid.View, options);
 var workBook = excelEngine.Excel.Workbooks[0];
 //Apply conditional format to worksheet
 IWorksheet worksheet = workBook.Worksheets[0];
 IConditionalFormats formats = worksheet["F2:F11"].ConditionalFormats;
 IConditionalFormat format = formats.AddCondition();
 format.FormatType = ExcelCFType.DataBar;
 IDataBar dataBar = format.DataBar;
 dataBar.BarColor = Color.Blue;
 workBook.SaveAs("Sample.xlsx");

Excel file with conditional formating during exporting excel

Take a moment to peruse the Excel To Export Customization documentation for more information.

About

This repository contains how to apply the conditional format for excel sheet exported from SfDataGrid

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 9

Languages