- Spreadsheet docs
- Developers
Moving from SpreadJS
How to move an app that embeds SpreadJS to 8sheets: your Excel files, the API calls you use, and what to check.
Most of the work in a spreadsheet app lives in its workbooks: templates, reports and the formulas in them. Those are Excel files, and 8sheets opens them as they are. What changes is the code around the grid, usually a few hundred lines that create the workbook, fill it, listen to it and save it. This page maps those calls one by one.
You don't have to do it alone: with any licence we help your developers build 8sheets in and move from SpreadJS, at no extra cost. Write to hi@8sheets.com.
SpreadJS is a trademark of its owner. 8sheets is not affiliated with it, and this page refers to its public documentation only to help you move.
1. Bring your workbooks
| What you have | What to do |
|---|---|
.xlsx, .xlsm, .xltx templates and reports | Nothing. Open them in 8sheets; try it with a file of your own. |
Workbooks kept as SpreadJS JSON (.sjs, ssjson) | Export them to .xlsx from your current app once, then open the .xlsx. 8sheets does not read SpreadJS's own formats, which aren't documented for other tools. |
| CSV | Open it, or import it with column types under Data > Get Data > From Text/CSV. |
Formulas keep working because 8sheets implements Excel's functions, not a dialect: 502 of them, including dynamic arrays, LET, LAMBDA, XLOOKUP, GROUPBY and PIVOTBY, checked against real Excel results. Parts of a file 8sheets doesn't use, such as VBA projects, Power Query or custom XML, are kept unchanged when it saves.
2. Map the API calls
The left column shows typical SpreadJS calls from its public documentation; the right column is the 8sheets code that does the same job. 8sheets has its own API, so this is a rewrite of these lines, not a drop-in shim. The API reference has every member.
| SpreadJS | 8sheets |
|---|---|
GC.Spread.Sheets.LicenseKey = '...' | Nothing. There is no licence key and no hostname check. |
new GC.Spread.Sheets.Workbook(host) | const wb = await mountWorkbook(host) |
| A workbook with no page | const wb = createWorkbook(), also in Node |
spread.getActiveSheet() | wb.activeSheet |
spread.getSheetFromName('Data') | wb.sheet('Data') |
spread.addSheet(...) | wb.addSheet('Data') |
sheet.setValue(r, c, v) | sheet.cell(r, c).values = v |
sheet.setArray(r, c, rows) | sheet.cell(r, c).values = rows |
sheet.setFormula(r, c, '=SUM(A1:A9)') | sheet.cell(r, c).formulas = '=SUM(A1:A9)' |
sheet.getValue(r, c) | sheet.cell(r, c).values[0][0] |
sheet.getRange(r, c, rows, cols) | sheet.range(r, c, r + rows - 1, c + cols - 1) |
sheet.getRange(...).backColor('#ffeeaa') | sheet.range('A1:D1').style = { fill: '#ffeeaa' } |
sheet.getRange(...).font('bold 12pt Calibri') | range.style = { bold: true, fontSize: 12, fontName: 'Calibri' } |
sheet.frozenRowCount(1) | sheet.freeze(1) |
sheet.setColumnWidth(c, w) | sheet.setColWidth(c, c, w) |
sheet.addSpan(...) | sheet.range('A1:C1').merge() |
sheet.tables.add(...) | sheet.addTable('A1:F60', { name: 'Sales' }) |
sheet.charts.add(...) | sheet.addChart('column', 'A1:C13', { x, y, w, h }), then sheet.chart(record) for a handle; see Charts and shapes from code |
chart.title(...) | sheet.chart('Chart 1').title = 'Sales' |
sheet.shapes.add(...) | sheet.shape(sheet.addShape('roundRect', { x, y, w, h })), with text, fill, setRect |
sheet.pivotTables.add(...) | sheet.addPivotTable('Data!A1:D99', 'A3', { rows, columns, values }); see PivotTables and slicers from code |
sheet.slicers.add(...) | pivot.addSlicer('Region'), then slicer.selected = ['East'] |
sheet.comments.add(...) | sheet.setNote('C4', 'Text') for a note; sheet.addComment('C4', 'Text') for a threaded comment with replies |
sheet.options.isProtected = true | sheet.protect(), or await sheet.protectWithPassword('pw'); await wb.protectStructure() for the workbook; see Protection |
GC.Spread.CalcEngine.Functions.defineGlobalCustomFunction(...) | wb.functions.define({ name, fn, min, max, ... }); see Custom functions |
GC.Spread.Common.CultureManager.culture('de-de') | wb.region = 'de-DE'; see Languages and regions |
sheet.setCellType(r, c, cellType) | sheet.cell(r, c).cellType = { type: 'checkbox' }, or a range; see Cell types |
| Data validation | sheet.setValidation('B2:B9', { type: 'list', formula1: '"a,b"' }) |
| Conditional formatting | sheet.addConditionalFormatRule('C2:C9', { type: 'cellIs', operator: 'greaterThan', formulas: ['100'] }, { fill: '#FFC7CE' }), in Excel's own rule format |
sheet.bind(Events.CellChanged, fn) | wb.events.on('cells-changed', fn), for edits from any path: typing, paste, fill, API, undo |
spread.bind(Events.SelectionChanged, fn) | wb.events.on('selection-changed', fn) |
| Cancelling an action in an event | wb.events.on('before-sheet-remove', (e) => e.cancel()) |
spread.commandManager() | wb.commands: register, execute, bindKey |
spread.undoManager() | wb.history: undo, redo, transaction |
spread.suspendPaint() and resumePaint() | Not needed: drawing costs only the visible area. Group edits with wb.history.transaction for one undo step. |
spread.import(file, ...) | await wb.openFile(file), with a File or a Blob ({ name } names it) |
spread.export(..., { fileType: excel }) | await wb.saveXlsx(sink) |
spread.toJSON() and fromJSON() | wb.toJSON() and wb.fromJSON(), in 8sheets' own published schema |
spread.options.* | mountWorkbook(host, { ...options }), and later wb.setOptions({ ... }); see All options |
| The Designer ribbon | Part of the app: mountWorkbook(host) brings the ribbon, formula bar, tabs and status bar. Leave out any of them with parts, hide single controls with wb.ribbon.hide('ribbon.insert.pivotTable'), and run or cancel any control by id; see Control everything from code. |
For large data, skip the cell-by-cell calls and write typed arrays straight into storage:
sheet.range('A1').setNumbers([prices, quantities]); // one Float64Array per column
sheet.range('C1').setStrings([names]);
3. A first page
JavaScript
import { mountWorkbook } from '@8sheets/core';
const wb = await mountWorkbook(document.querySelector('#sheet'), { chrome: 'light' });
const sheet = wb.activeSheet;
sheet.range('A1').values = [['Item', 'Qty', 'Price'], ['Pens', 4, 1.2], ['Paper', 2, 5.5]];
sheet.range('D2:D3').formulas = '=B2*C2';
sheet.range('A1:D1').style = { bold: true };
wb.events.on('cells-changed', (e) => console.log(`${e.count} cells changed`));React
import { Sheet } from '@8sheets/react';
function fill(wb) {
const sheet = wb.activeSheet;
sheet.range('A1').values = [['Item', 'Qty', 'Price'], ['Pens', 4, 1.2], ['Paper', 2, 5.5]];
sheet.range('D2:D3').formulas = '=B2*C2';
sheet.range('A1:D1').style = { bold: true };
}
export function FirstPage() {
return (
<div style={{ height: 480 }}>
<Sheet options={{ chrome: 'light' }} onReady={fill} onCellsChanged={(e) => console.log(`${e.count} cells changed`)} />
</div>
);
}Vue
<script setup>
import { Sheet } from '@8sheets/vue';
function fill(wb) {
const sheet = wb.activeSheet;
sheet.range('A1').values = [['Item', 'Qty', 'Price'], ['Pens', 4, 1.2], ['Paper', 2, 5.5]];
sheet.range('D2:D3').formulas = '=B2*C2';
sheet.range('A1:D1').style = { bold: true };
}
</script>
<template>
<Sheet :options="{ chrome: 'light' }" style="height: 480px" @ready="fill" @cells-changed="(e) => console.log(`${e.count} cells changed`)" />
</template>Angular
import { Component } from '@angular/core';
import { SheetComponent, SheetEventPayload, SheetsWorkbook } from '@8sheets/angular';
@Component({
selector: 'app-first-page',
imports: [SheetComponent],
template: `<eight-sheet class="grid" [options]="{ chrome: 'light' }" (ready)="fill($event)" (cellsChanged)="log($event)" />`,
styles: `.grid { height: 480px; }`,
})
export class FirstPage {
fill(wb: SheetsWorkbook) {
const sheet = wb.activeSheet;
sheet.range('A1').values = [['Item', 'Qty', 'Price'], ['Pens', 4, 1.2], ['Paper', 2, 5.5]];
sheet.range('D2:D3').formulas = '=B2*C2';
sheet.range('A1:D1').style = { bold: true };
}
log(e: SheetEventPayload) {
console.log(`${e['count']} cells changed`);
}
}The element needs a height. Several workbooks can share a page. Installation covers npm, bundlers and self-hosting, and Embedding and options the options that replace spread.options.
4. Check before you switch
- Packaging.
npm i @8sheets/core, or@8sheets/react,@8sheets/vueor@8sheets/angularwith it. It has no dependencies; licence holders also get the full source. - Frameworks. The licence includes React, Vue and Angular components with options, events and access to the workbook, like SpreadJS's wrappers. Other frameworks mount into an element they own and call
wb.destroy()when it goes away. - Server-side code. The same API runs in Node with no page, for building or calculating workbooks on a server.
- Features you rely on. The feature list and the examples show what is there. Open your own heaviest workbooks in the app before you decide; that is the quickest real test.
- Collaboration. Real-time editing is in the code. There is no hosted collaboration service for embedded workbooks yet; licence holders run the server that comes with the source. See Users, comments and collaboration.
Questions about a move, or a feature you need: see Pricing for how to reach us.