# Export PivotGrid

Learn how to export PivotGrid in this tutorial 

## Content


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.

```javascript
// Excel export
import * as wjGridXlsx from '@mescius/wijmo.grid.xlsx';

// PDF Export
import * as wjPdf from '@mescius/wijmo.pdf';
import * as wjGridPdf from '@mescius/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
    book.save('PivotGrid.xlsx');
});
```

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

```javascript
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.

Example:

```javascript
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
		doc.end();
	});
```

Refer to PivotGrid Export [demo](/wijmo/demos/OLAP/PivotGrid/Export/Excel,PDF,CSV/purejs).