5.20231.904
5.20231.904

Export FlexGrid to Excel (XSLX)

To export FlexGrid controls to the XLSX format, you should include three extra modules in your application:

  1. wijmo.xlsx.js: Provides general methods for saving and loading XLSX files.
  2. wijmo.grid.xlsx.js: Contains the FlexGridXlsxConverter class that uses wijmo.xlsx.js to save FlexGrid controls as XLSX or to load XLSX files into FlexGrid controls.
  3. jszip.js: Javascript library for creating, reading and editing ZIP files..

To export a FlexGrid to XLSX, call the FlexGridXlsxConverter.save method to obtain a 'book' object. You may modify the book object before saving it, by adding or renaming sheets for example. Once the 'book' is ready, call its save method to create the XLSX file.

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

// create book with current view
var book = wjGridXlsx.FlexGridXlsxConverter.save(theGrid, { includeColumnHeaders: true, 
includeRowHeaders: true });
//name the sheet
book.sheets[0].name = 'FlexGrid Data';
// save the book
book.save('FlexGrid-Export.xlsx');