Export PivotGrid

The PivotGrid exends the FlexGrid, so you can export it to XLSX and PDF as you would export a regular FlexGrid:

Export to Excel (XLSX)

Exporting to excel is simple. The wijmo.grid.xlsx module can perform this function via the FlexGridXlsxConverter.save() function. However, this process requires the wijmo.xlsx module as well.

wijmo.xlsx is dependent on jszip. You will need this script included in your project also.

// Excel export
import * as wjGridXlsx from '@grapecity/wijmo.grid.xlsx';

// PDF Export
import * as wjPdf from '@grapecity/wijmo.pdf';
import * as wjGridPdf from '@grapecity/wijmo.grid.pdf';

document.getElementById('xlsx').addEventListener('click', function() {

    // create book with current view
    var book = wjGridXlsx.FlexGridXlsxConverter.save(pivotGrid, {
        includeColumnHeaders: true,
        includeRowHeaders: true
    book.sheets[0].name = 'PivotGrid';

    // save the book

Export to PDF

To export to a PDF, use the wijmo.grid.pdf module. Similar to the excel exporting, the wijmo.grid.pdf module is dependent on wijmo.pdf.The FlexGridPdfConverter class has an export() function that takes the grid instance, a file name and a JSON object to configure the documents settings.

Here is an example.

document.getElementById('pdf').addEventListener('click', function() {
    wjGridPdf.FlexGridPdfConverter.export(pivotGrid, 'PivotGrid.pdf', {
        maxPages: 10,
        scaleMode: wjGridPdf.ScaleMode.PageWidth,
        documentOptions: {
            compress: true,
            header: { 
                declarative: { text: '\t&[Page] of &[Pages]' }
            footer: { 
                declarative: { text: '\t&[Page] of &[Pages]' }
            info: { author: 'GrapeCity', title: 'PivotGrid' }
        styles: {
            cellStyle: {
                backgroundColor: '#ffffff',
                borderColor: '#c6c6c6'
            altCellStyle: { backgroundColor: '#f9f9f9' },
            groupCellStyle: { backgroundColor: '#dddddd' },
            headerCellStyle: { backgroundColor: '#eaeaea' }

Add content to PDF Export

In some cases, you may want to add additional content to the exported PDF document. The wijmo.pdf module gives you the ability to do this. Create a PdfDocument and use functions like draw() to add additional content.


document.getElementById('pdfdoc').addEventListener('click', function() {

    // create the document
    var doc = new wjPdf.PdfDocument({
        compress: true, 
        header: { declarative: { text: '\t&[Page]\\&[Pages]' } },
        ended: function (sender, args) {
            wjPdf.saveBlob(args.blob, 'PivotGridDoc.pdf');

    // add some content
    doc.drawText('This is a PivotGrid control:');

    // add the grid (400pt wide)
    wjGridPdf.FlexGridPdfConverter.draw(pivotGrid, doc, 400);

    // finish document

Refer to PivotGrid Export demo.