[]
        
(Showing Draft Content)

Excel.IO-1

Class: IO

Excel.IO

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new IO()

Represents an excel import and export class.

Properties

pivotTableThemes

Static pivotTableThemes: Object

Build in pivot table themes.

Index signature

▪ [key: string]: any


slicerStyles

Static slicerStyles: Object

Build in item slicer themes.

Index signature

▪ [key: string]: any


tableThemes

Static tableThemes: Object

Build in table themes.

Index signature

▪ [key: string]: any


timelineStyles

Static timelineStyles: Object

Build in timeline slicer themes.

Index signature

▪ [key: string]: any

Methods

open

open(file, successCallBack, errorCallBack?, options?): void

Imports an excel file.

example

var workbook = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var excelIO = new GC.Spread.Excel.IO();
var excelFile = document.getElementById("fileDemo").files[0];
excelIO.open(excelFile, function (json) {
   workbook.fromJSON(json);
}, function (e) {
   console.log(e);
}, {
   password: "password",
   importPictureAsFloatingObject: false
});

Parameters

Name Type Description
file Blob The excel file.
successCallBack Function Call this function after successfully loading the file. function (json) { }.
errorCallBack? Function Call this function if an error occurs. The exception parameter object structure { errorCode: GC.Spread.Excel.IO.ErrorCode, errorMessage: string}.
options? OpenOptions The options for import excel.

Returns

void


registerMaxDigitWidth

registerMaxDigitWidth(fontFamily, fontSize, maxDigitWidth): void

Register a unknown max digit width info to ExcelIO.

example

GC.Spread.Excel.IO.registerMaxDigitWidth("\ub3cb\uc6c0", 11, Math.floor(80/8.11));

Parameters

Name Type Description
fontFamily string The font family of default style's font.
fontSize number The font size of default style's font(in point).
maxDigitWidth number The max digit width of default style's font.

Returns

void


save

save(json, successCallBack, errorCallBack?, options?): void

Creates and saves an excel file with the SpreadJS json.

example

var workbook = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var excelIO = new GC.Spread.Excel.IO();
var json = JSON.stringify(workbook.toJSON());
excelIO.save(json, function (blob) {
   saveAs(blob, fileName); //saveAs is from FileSaver.
}, function (e) {
   console.log(e);
}, {
   password: "password",
   xlsxStrictMode: false
});

Parameters

Name Type Description
json string | object The spread sheets json object, or string.
successCallBack Function Call this function after successfully exporting the file. function (blob) { }.
errorCallBack? Function Call this function if an error occurs. The exception parameter object structure { errorCode: GC.Spread.Excel.IO.ErrorCode, errorMessage: string}.
options? SaveOptions The options for export excel.

Returns

void