Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 3.69 KB

File metadata and controls

58 lines (43 loc) · 3.69 KB

Grid View for ASP.NET Web Forms - How to export a colored grid in Data Aware export mode

This example shows how to color the exported grid when Data Aware export mode is used.

Export colored grid

The grid does not export cell styles applied in the HtmlDataCellPrepared event.

To color the exported grid in Data Aware export mode, handle the XlsxExportOptionsEx.CustomizeCell event.

void ExportOptions_CustomizeCell(DevExpress.Export.CustomizeCellEventArgs ea) {
	if (ea.ColumnFieldName != "UnitsOnOrder" || ea.AreaType != DevExpress.Export.SheetAreaType.DataArea) return;
	int cellValue = 0;
	if (int.TryParse(ea.Value.ToString(), out cellValue) && cellValue == 0) {
		ea.Formatting.BackColor = Color.Salmon;
		ea.Formatting.Font.Color = Color.Blue;
		ea.Formatting.Font.Bold = true;
	}
	else
		ea.Formatting.BackColor = Color.LightBlue;
	ea.Handled = true;
}

Note
Starting from v15.2, the grid maintains conditional formatting styles in the exported document. You can use the ASPxGridView.FormatConditions rules to define conditional formatting in browse mode and keep the applied appearance in the exported document.

Files to Review

Documentation

Technical Demos

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)