Skip to content

LanaDX/asp-net-web-forms-grid-export-colored-grid-in-data-aware-mode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

[Run Online]

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

About

Color the exported grid when Data Aware export mode is used.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • C# 46.1%
  • Visual Basic .NET 36.3%
  • ASP.NET 17.6%