ASP.NET MVC Controls
FlexGridXlsxConverter Class
File
wijmo.grid.xlsx.js
Module
wijmo.grid.xlsx

This class provides static load and save methods for loading and saving FlexGrid controls from and to Excel xlsx files.

Methods

Methods

Static load

load(grid: FlexGrid, workbook: any, options?: IFlexGridXlsxOptions): void

Loads a Workbook instance or a Blob object containing xlsx file content to the FlexGrid instance. This method works with JSZip 2.5.

For example:

// This sample opens an xlsx file chosen through Open File
// dialog and fills FlexGrid with the content of the first

// sheet.
 

// HTML
<input type="file" 
    id="importFile" 
    accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" 
/>
<div id="flexHost"></>
 

// JavaScript
var flexGrid = new wijmo.grid.FlexGrid("#flexHost"),
    importFile = document.getElementById('importFile');
 
importFile.addEventListener('change', function () {
    loadWorkbook();
});
 
function loadWorkbook() {
    var reader,
        file = importFile.files[0];
    if (file) {
        reader = new FileReader();
        reader.onload = function (e) {
            wijmo.grid.xlsx.FlexGridXlsxConverter.load(flexGrid, reader.result,
                { includeColumnHeaders: true });
        };
        reader.readAsArrayBuffer(file);
    }
}
Parameters
Returns
void

Static loadAsync

loadAsync(grid: FlexGrid, workbook: any, options?: IFlexGridXlsxOptions, onLoaded?: Workbook), onError?: (reason?: any)): void

Asynchronously loads a Workbook or a Blob representing an xlsx file into a FlexGrid.

This method requires JSZip 3.0.

Parameters
  • grid: FlexGrid

    FlexGrid that loads the workBook object.

  • workbook: any

    Workbook, Blob, base-64 string, or ArrayBuffer representing the xlsx file content.

  • options: IFlexGridXlsxOptions Optional

    IFlexGridXlsxOptions object specifying the load options.

  • onLoaded: (workbook: wijmo.xlsx.Workbook) Optional

    Callback invoked when the method finishes executing. The callback provides access to the workbook that was loaded (passed as a parameter to the callback).

  • onError: (reason?: any) Optional

    Callback invoked when there are errors saving the file. The error is passed as a parameter to the callback.

    For example:

    wijmo.grid.xlsx.FlexGridXlsxConverter.loadAsync(grid, blob, null, function (workbook) {
    
         // user can access the loaded workbook instance in this callback.
         var app = worksheet.application ;
         ...
    }, function (reason) {
    
         // User can catch the failure reason in this callback.
         console.log('The reason of save failure is ' + reason);
    });
    
Returns
void

Static save

save(grid: FlexGrid, options?: IFlexGridXlsxOptions, fileName?: string): Workbook

Save the FlexGrid instance to the Workbook instance. This method works with JSZip 2.5.

For example:

// This sample exports FlexGrid content to an xlsx file.
// click.
 

// HTML
<button 
    onclick="saveXlsx('FlexGrid.xlsx')">
    Save
</button>
 

// JavaScript
function saveXlsx(fileName) {

    // Save the flexGrid to xlsx file.
    wijmo.grid.xlsx.FlexGridXlsxConverter.save(flexGrid,
            { includeColumnHeaders: true }, fileName);
}
Parameters
Returns
Workbook

Static saveAsync

saveAsync(grid: FlexGrid, options?: IFlexGridXlsxOptions, fileName?: string, onSaved?: (base64: string), onError?: (reason?: any)): Workbook

Asynchronously saves the content of a FlexGrid to a file.

This method requires JSZip 3.0.

Parameters
  • grid: FlexGrid

    FlexGrid that will be saved.

  • options: IFlexGridXlsxOptions Optional

    IFlexGridXlsxOptions object specifying the save options.

  • fileName: string Optional

    Name of the file that will be generated.

  • onSaved: (base64: string) Optional

    Callback invoked when the method finishes executing. The callback provides access to the content of the saved workbook (encoded as a base-64 string and passed as a parameter to the callback).

  • onError: (reason?: any) Optional

    Callback invoked when there are errors saving the file. The error is passed as a parameter to the callback.

    For example: < } reason); + ? is failure of reason console.log(?The callback. this in the catch can User { (reason) function }, base64; ?base64,? document.getElementByID(?export?).href="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;" string base64 access (base64) ?FlexGrid.xlsx?, true includeColumnHeaders:>

Returns
Workbook

 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback