Migrating to version 8

Overview

We believe that the version upgrades should be as smooth as possible. We have managed to keep an outstanding level of compatibility so far. But, version 8 brings some new concepts and possibilities but with some fundamental changes and additions. This document brings a summary of the most important aspects the developer should be aware of when migrating from previous versions to version 8.

In previous versions, the Jspreadsheet (former Jexcel) brings the component structure based only on worksheets, so there was no proper way to hold common elements between the worksheets causing unnecessary duplications. To improve that, we introduced the spreadsheet object as a parent. The spreadsheet object will be the container of common attributes and elements, so the worksheets are available through the property worksheet (array).

Example


Up to version 7
jspreadsheet(document.getElementById('spreadsheet'), {
    minDimensions: [10, 10],
    toolbar: true,
    onchange: function() {
        // Do something
    },
    // Declare for each worksheet
    license: 'your-license'
});

From version 8
jspreadsheet(document.getElementById('spreadsheet'), {
    // Create 3 blank worksheets
    worksheets: [
        { minDimensions: [10, 10] },
        { minDimensions: [10, 10] }
        { minDimensions: [10, 10] }
    ],
    // One toolbar to serve all worksheets
    toolbar: true,
    // Events need to be declared just on the spreadsheet level only once
    onchange: function() {
        // Do something
    },
    // Declare just once on the spreadsheet level
    license: 'your-license'
});

Global license declaration

From version 8, it is possible to declare the license just once. That will be valid for all spreadsheets, worksheets and extensions.
// Declare the license just once
jspreadsheet.license = 'your-license-here';

// Use the spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
    worksheets: [{
        minDimensions: [10, 10],
        columns: [
            { type: 'text', width:300 },
            { type: 'text', width:80 },
        ],
    }],
});



CSS Class names

We renamed all CSS class prefix names from .jexcel to .jss. That represents better the new product name.

Spreadsheet configuration updates

options updated

From version 8, there are two attributes for the configuration. Common attributes, such as the events, toolbar, among others, have been moved to the spreadsheet.config. All other worksheet-specific attributes would be available as before in the worksheet.options.

updateTable updated

If you use updateTable for automation, you must update the arguments to:

text deprecated

The property text for translations is deprecated. Please use Jsuites.dictionary for translations, click here for more information.

json deprecated

Up to version 7, there were different properties when loading the data from JSON or array. From version 8, please use the data property.

internationalKeyboard deprecated

This property is deprecated since the new editors are compliance with foreign languages and IME.

tableOverflowResizable deprecated

This property is not implemented. For resize: setViewport(w,h) is available.

copyCompatibility deprecated

This property was introduced to keep compatibility with older versions. The developer could choose between the raw data or the processed data when the user was copying or exporting the data from the spreadsheet. The behavior should be similar to other spreadsheet software such as Excel or Google Spreadsheet.

columns.editor deprecated

The property editor from the column settings is deprecated. To create custom editors please use the type property. The template for the editors has also changed, and more information can be found in the custom editors documentation page.

lazyLoading deprecated

The smart DOM managment would be enabled when pagination, fullscreen or tableOverflow is used.

lazyColumns deprecated

The smart DOM managment would be enabled when pagination, fullscreen or tableOverflow is used.

colHeaders deprecated

Please use: columns.title

colWidths deprecated

Please use: columns.width

colAlignments deprecated

Please use: columns.align

cache deprecated

Cache now is default for all operations. Cached values are available at worksheets.records[y][x].v



Spreadsheet features


Toolbars

In previous versions, there where one toolbar per worksheet. From version 8, the toolbar element is accessible from the spreadsheet object and will be the same for all worksheets.

Editors

In previous versions, a new DOM element is created for every cell edition. From version 8, the same DOM element will be used during the edition. This element is floating in the viewport and not linked to the cell as before. The object is available using the path spreadsheet.input or worksheet.parent.input

Instance shortcut

The following property brings an array with the worksheets. document.getElementById('spreadsheet').jexcel - (Deprected).

Please use

document.getElementById('spreadsheet').jspreadsheet or
document.getElementById('spreadsheet').spreadsheet.worksheets


Events

In previous versions, the first argument for each event was the DOMElement element. From version 8, the first argument in each event will gives the worksheet object which originate the event.

onchangestyle

The arguments have changed to onchangestyle(worksheet Object, newValue Array, oldValue Array);

onchange

The properties col and row is no longer available. Please, use x and y. { x: x, y: y, value: value, col: col, row, row }



Methods


getWorksheetActive

From version 8 would return the worksheet index number.




Helpers

We have grouped the helpers in a single object. For example to convert a number in a spreadsheet like cellName.

jspreadsheet.helpers.getColumnNameFromCoords(x, y);
jspreadsheet.helpers.getCoordsFromColumName(cellName); // Such as A1, A2...

jspreadsheeet.helpers.guid() deprecated
Replaced by jSuites.guid()

parseType and parseNumber are deprected

Please use jSuites.mask.extract() .