How to Format cell in exported excel document based on value of another cell in same row in WinForms DataGrid(SfDataGrid)?
WinForms DataGrid (SfDataGrid) allows you to format cells in the exported excel document based on the value of another cell in same row by using ExcelExportingOptions.CellExporting event.
Var options = new ExcelExportingOptions();
options.CellExporting += OnCellExporting;
var excelEngine = sfDataGrid1.ExportToExcel(sfDataGrid1.View, options);
var workBook = excelEngine.Excel.Workbooks[0];
workBook.SaveAs("Sample.xlsx");
private void OnCellExporting(object sender, Syncfusion.WinForms.DataGridConverter.Events.DataGridCellExcelExportingEventArgs e)
{
var record = e.NodeEntry as OrderInfo;
// Style for OrderID column is changed based on the values in CustomerID column
if(e.ColumnName == "OrderID")
{
if(record != null && record.CustomerID == "FRANS")
{
e.Range.CellStyle.Color = Color.SkyBlue;
e.Range.CellStyle.Font.Color = ExcelKnownColors.Red;
e.Range.CellStyle.Font.FontName = "Arial";
e.Range.CellStyle.Font.Bold = true;
}
}
}

Take a moment to peruse the documentation, where you can find about Excel exporting in SfDataGrid, with code examples.
You can download the example from GitHub