SpreadJS 13
GC.Spread.Sheets Namespace / Workbook type / toJSON Method
The serialization options.
Whether to include the binding source when converting the workbook to json.
Whether to ignore the style when converting the workbook to json.
Whether to ignore the formula when converting the workbook to json.
Whether to ignore the format string when converting the workbook to json.
Whether to treat the row headers as frozen columns when converting the workbook to json.
Whether to treat the column headers as frozen rows when converting the workbook to json.
Whether to include the automatically merged cells when converting the workbook to json.
In This Topic
    toJSON Method
    In This Topic
    Saves the object state to a JSON string.
    Syntax
    var instance = new GC.Spread.Sheets.Workbook(host,
                                                options,
                                                options.sheetCount,
                                                options.font,
                                                options.allowUserDragMerge,
                                                options.allowUserDragDrop,
                                                options.allowUserDragFill,
                                                options.allowUserZoom,
                                                options.allowUserResize,
                                                options.allowUndo,
                                                options.allowSheetReorder,
                                                options.allowContextMenu,
                                                options.allowUserDeselect,
                                                options.defaultDragFillType,
                                                options.showDragFillSmartTag,
                                                options.showHorizontalScrollbar,
                                                options.showVerticalScrollbar,
                                                options.scrollbarShowMax,
                                                options.scrollbarMaxAlign,
                                                options.tabStripVisible,
                                                options.tabStripRatio,
                                                options.tabEditable,
                                                options.newTabVisible,
                                                options.tabNavigationVisible,
                                                options.cutCopyIndicatorVisible,
                                                options.cutCopyIndicatorBorderColor,
                                                options.backColor,
                                                options.backgroundImage,
                                                options.backgroundImageLayout,
                                                options.grayAreaBackColor,
                                                options.showResizeTip,
                                                options.showDragDropTip,
                                                options.showDragFillTip,
                                                options.showScrollTip,
                                                options.scrollIgnoreHidden,
                                                options.highlightInvalidData,
                                                options.useTouchLayout,
                                                options.hideSelection,
                                                options.resizeZeroIndicator,
                                                options.allowUserEditFormula,
                                                options.enableFormulaTextbox,
                                                options.autoFitType,
                                                options.referenceStyle,
                                                options.calcOnDemand,
                                                options.allowCopyPasteExcelStyle,
                                                options.allowExtendPasteRange,
                                                options.copyPasteHeaderOptions,
                                                options.scrollByPixel,
                                                options.scrollPixel,
                                                options.allowAutoCreateHyperlink,
                                                options.columnResizeMode,
                                                options.rowResizeMode,
                                                options.customList,
                                                options.scrollbarAppearance);
    var value; // Type: Object
    value = instance.toJSON(                                            serializationOption,
                                                serializationOption.includeBindingSource,
                                                serializationOption.ignoreStyle,
                                                serializationOption.ignoreFormula,
                                                serializationOption.saveAsView,
                                                serializationOption.rowHeadersAsFrozenColumns,
                                                serializationOption.columnHeadersAsFrozenRows,
                                                serializationOption.includeAutoMergedCells);
    function toJSON( 
       serializationOption : Object,
       (optional) serializationOption.includeBindingSource : boolean,
       (optional) serializationOption.ignoreStyle : boolean,
       (optional) serializationOption.ignoreFormula : boolean,
       (optional) serializationOption.saveAsView : boolean,
       (optional) serializationOption.rowHeadersAsFrozenColumns : boolean,
       (optional) serializationOption.columnHeadersAsFrozenRows : boolean,
       (optional) serializationOption.includeAutoMergedCells : boolean
    ) : Object;

    Parameters

    serializationOption
    The serialization options.
    serializationOption.includeBindingSource
    Whether to include the binding source when converting the workbook to json.
    serializationOption.ignoreStyle
    Whether to ignore the style when converting the workbook to json.
    serializationOption.ignoreFormula
    Whether to ignore the formula when converting the workbook to json.
    serializationOption.saveAsView
    Whether to ignore the format string when converting the workbook to json.
    serializationOption.rowHeadersAsFrozenColumns
    Whether to treat the row headers as frozen columns when converting the workbook to json.
    serializationOption.columnHeadersAsFrozenRows
    Whether to treat the column headers as frozen rows when converting the workbook to json.
    serializationOption.includeAutoMergedCells
    Whether to include the automatically merged cells when converting the workbook to json.

    Return Value

    The spreadsheet data.
    Example
    This example uses the toJSON method.
    activeSheet.getCell(0,0).value(123);
    var jsonStr = null;
    //export
    jsonStr = JSON.stringify(spread.toJSON(false));
    //import
    spread.fromJSON(JSON.parse(jsonStr));
    alert(jsonStr);
    Remarks

    SpreadJS serializes the sheet's data source and the table's data source as a cell value if the includeBindingSource argument of the toJSON method is true.

    The serializationOption parameter has the following arguments:

    Name

    Type

    Description

    serializationOption

    Object

    The serialization options.

    Name

    Type

    Description

    includeBindingSource

    boolean

    optional Whether to include the binding source when converting the workbook to json.
    ignoreStyle

    boolean

    optional Whether to ignore the style when converting the workbook to json.
    ignoreFormula

    boolean

    optional Whether to ignore the formula when converting the workbook to json.
    rowHeadersAsFrozenColumns

    boolean

    optional Whether to treat the row headers as frozen columns when converting the workbook to json.
    columnHeadersAsFrozenRows

    boolean

    optional Whether to treat the column headers as frozen rows when converting the workbook to json.

     

    See Also

    Reference

    Workbook type