Coder Social home page Coder Social logo

devexpress-examples / asp-net-mvc-grid-export-colored-grid-in-data-aware-mode Goto Github PK

View Code? Open in Web Editor NEW
0.0 54.0 1.0 502 KB

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

License: Other

C# 36.79% HTML 14.55% ASP.NET 0.58% Visual Basic .NET 48.07%
dotnet mvc-gridview asp-net-mvc export grid

asp-net-mvc-grid-export-colored-grid-in-data-aware-mode's Introduction

Grid View for MVC - 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.

public ActionResult ExportTo() {
    XlsxExportOptionsEx exportOptions = new XlsxExportOptionsEx();
    exportOptions.CustomizeCell += new DevExpress.Export.CustomizeCellEventHandler(exportOptions_CustomizeCell);
    return GridViewExtension.ExportToXlsx(GridViewHelper.ExportGridViewSettings, MyModel.GetProducts(), exportOptions);
}
void exportOptions_CustomizeCell(DevExpress.Export.CustomizeCellEventArgs ea) {
    if(ea.AreaType != DevExpress.Export.SheetAreaType.Header && ea.ColumnFieldName == "UnitPrice") {
        if(Convert.ToDecimal(ea.Value) > 15)
            ea.Formatting.BackColor = System.Drawing.Color.Yellow;
        else
            ea.Formatting.BackColor = System.Drawing.Color.Green;
        ea.Handled = true;
    }
}

Note
Starting from v15.2, the grid maintains conditional formatting styles in the exported document. You can use the GridViewSettings.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

asp-net-mvc-grid-export-colored-grid-in-data-aware-mode's People

Contributors

devexpressexamplebot avatar lanadx avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lanadx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.