ASP.NET MVC OLAP: Exporting a PivotGrid to Excel

The PivotGrid control extends the FlexGrid, so you can export its contents to XLSX files in the same way you would export regular FlexGrid controls.

We'll create a client-side JavaScript function to build the XLSX file you want. You have complete control of the output. For example, you may add sheets containing the current view, any pre-defined views, and the raw data. Here’s an example:

 function exportToXlsx() {  
        // create book with current view  
        var book =, {  
            includeColumnHeaders: true,  
            includeRowHeaders: true  
        book.sheets[0].name = 'Main View';  
        // add sheet with raw data  
        if (theRawGrid.rows.length <= 20000) {  
            var raw =, {  
                includeColumnHeaders: true,  
                includeRowHeaders: false  
            raw.sheets[0].name = 'Raw Data';  
        // save book 'olap.xlsx');  

More from the ASP.NET MVC OLAP

Demos: ASP.NET 4.0 | ASP.NET Core

Take a look at the documentation for more details.

Download C1Studio

Full OLAP series:


GrapeCity Developer Tools
comments powered by Disqus