[]
        
(Showing Draft Content)

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 '@mescius/wijmo.grid';
import * as wjGridXlsx from '@mescius/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');

Customize the Workbook Before Saving

The FlexGridXlsxConverter.save method returns a Workbook instance. You can modify workbook-level properties before calling save.

For example, to customize workbook metadata and worksheet settings before export:

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

// Export an existing FlexGrid instance
const book = wjGridXlsx.FlexGridXlsxConverter.save(theGrid, {
    includeColumnHeaders: true,
    includeRowHeaders: true
});

// Customize workbook metadata and worksheet settings.
book.company = 'MESCIUS';
book.sheets[0].name = 'FlexGrid Data';

// Export the file.
book.save('FlexGrid-Export.xlsx');

For a complete list of available properties and options, see the Workbook and WorkSheet API reference.