Skip to main content Skip to footer

Wijmo 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.

Full Wijmo OLAP series:

Add a reference to the wijmo.grid.xlsx module to the page, and then create a 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 = wijmo.grid.xlsx.FlexGridXlsxConverter.save(thePivotGrid, {  
includeColumnHeaders: true,  
includeRowHeaders: true  
});  
book.sheets[0].name = 'Main View';  

// add sheet with raw data  
if (theRawGrid.rows.length <= 20000) {  
var raw = wijmo.grid.xlsx.FlexGridXlsxConverter.save(theRawGrid, {  
includeColumnHeaders: true,  
includeRowHeaders: false  
});  
raw.sheets[0].name = 'Raw Data';  
book.sheets.push(raw.sheets[0]);  
}  

// save book  
book.save('wijmo.olap.xlsx');  
}  

More from the Wijmo OLAP series

  1. Getting Started with Wijmo's HTML5 OLAP Module: Create Basic Pivot Tables
  2. Answer Recurring Questions with Pre-Defined Views
  3. Filtering Data in a PivotGrid
  4. Exporting a PivotGrid to Excel
  5. Customizing the UI and PivotGrid

See Angular OLAP demo | See JS OLAP Demo

MESCIUS inc.

comments powered by Disqus