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

This example shows how to color the exported grid when WYSIWYG 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 WYSIWYG export mode, handle the ASPxGridView.ExportRenderBrick event.

protected void grid_ExportRenderBrick(object sender, ASPxGridViewExportRenderingEventArgs e) {
    if (e.RowType != GridViewRowType.Data)
        return;
    if ((e.Column as GridViewDataColumn).FieldName == "UnitPrice" && e.RowType != GridViewRowType.Header) {
        if (Convert.ToInt32(e.TextValue) > 15)
            e.BrickStyle.BackColor = Color.Yellow;
        else
            e.BrickStyle.BackColor = Color.Green;
    }
}

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)