- Spreadsheet docs
- Developers
Moving from Handsontable
How to move an app that embeds Handsontable to 8sheets, as a data grid or as a spreadsheet with xlsx files and formulas - the API calls you use, and what to check.
Handsontable is a data grid that looks like a spreadsheet. 8sheets has both things, and the first step is to choose which one your screen is:
| Your screen | Use | Because |
|---|---|---|
| A table of records from your database: one row per record, typed columns, editing, search, filters, grouping | 8sheets Data Grid, @8sheets/data-grid | It works with records and field names, loads them locally or from your server, and calculates fields from others |
| Something people think of as a workbook: free cells, formulas across rows, several sheets, Excel files in and out | 8sheets Spreadsheet, @8sheets/core | It opens and saves .xlsx, calculates 502 Excel functions, and has charts, PivotTables and printing |
Both come in one licence, so one app can use both. With any licence we help your developers build 8sheets in and move, at no extra cost. Write to hi@8sheets.com.
Handsontable and HyperFormula are trademarks of their owner. 8sheets is not affiliated with it, and this page refers to its public documentation only to help you move. Prices and terms are compared, with sources, on 8sheets vs Handsontable.
1. Bring your data
- Records. An array of objects goes into the Data Grid as it is:
data: rows, withfieldsin place ofcolumns. An array of arrays goes into a sheet as it is:sheet.range('A1').values = rows. - Excel files. If users export from Handsontable to Excel and upload a changed file again, let them open and save the
.xlsxin the Spreadsheet. Nothing is parsed on your server. - Formulas. Formulas written for HyperFormula follow Excel's syntax, and so do 8sheets'. Write them as strings that start with
=. Functions you registered yourself become custom functions.
2. To the Data Grid
| Handsontable | 8sheets Data Grid |
|---|---|
new Handsontable(el, { data, columns }) | const grid = await mountTable(el, { fields, data }) |
licenseKey: '...' | Nothing. There is no licence key. |
columns: [{ data: 'units', type: 'numeric' }] | fields: [{ name: 'units', type: 'number', format: '0' }] |
colHeaders | caption of a field; see Columns |
type: 'dropdown', source: [...] | options: [...] on the field |
type: 'checkbox', type: 'date' | type: 'boolean', type: 'date' |
readOnly: true on a column | readOnly: true on a field |
validator | required, or validator: { type, operator, min, max, message }, as Excel's data validation |
renderer | A cell renderer |
hot.getDataAtRowProp(row, 'units') | await grid.getCell(id, 'units'): records are addressed by id, so a sort or filter doesn't move them |
hot.setDataAtRowProp(row, 'units', 5) | await grid.setCellValue(id, 'units', 5) |
hot.alter('insert_row_below'), 'remove_row' | grid.addRecords([...]), grid.removeRecords([id]) |
hot.loadData(rows), hot.updateData(rows) | grid.setData(rows, { fields }); changes from your server: grid.applyTransaction({ add, update, remove }) |
afterChange | onChange, with the action and its cells or records |
beforeChange returning false | beforeEdit, with e.preventDefault() |
columnSorting, filters, dropdownMenu | Built in: grid.sortBy('units'), grid.addFilter(...), and menus on the headings |
search plugin | Built in: grid.setSearch('text'), and Find |
fixedColumnsStart | Frozen columns; see Columns |
columnSummary | A totals row, totals of groups and a pivot; see Totals |
nestedRows | Tree |
exportFile plugin | grid.download('xlsx') or 'csv', with no extra package |
hot.undo(), hot.redo() | grid.undo(), grid.redo() |
hot.destroy() | grid.destroy() |
Large tables on a server: see Remote data, where the grid asks for the rows it shows.
3. To the Spreadsheet
| Handsontable | 8sheets Spreadsheet |
|---|---|
new Handsontable(el, { data }) | const wb = await mountWorkbook(el), then wb.activeSheet.range('A1').values = data |
hot.getData() | sheet.usedRange.values |
hot.getDataAtCell(r, c), hot.setDataAtCell(r, c, v) | sheet.cell(r, c).values[0][0], sheet.cell(r, c).values = v |
formulas: { engine: HyperFormula } | Nothing to add: sheet.range('D2:D9').formulas = '=B2*C2' |
| Several grids that share an engine | Sheets of one workbook: wb.addSheet('Rates') |
hot.alter('insert_row_above', 3) | sheet.insertRows(3) |
fixedRowsTop: 1, fixedColumnsStart: 1 | sheet.freeze(1, 1) |
mergeCells: [...] | sheet.range('A1:C1').merge() |
cell: [{ row, col, className }], customBorders | sheet.range('A1:C1').style = { bold: true, fill: '#ffeeaa' }, borders included |
numericFormat | style = { numFmt: '#,##0.00' }, in Excel's number formats |
validator, type: 'dropdown' | sheet.setValidation('B2:B9', { type: 'list', formula1: '"a,b"' }) |
type: 'checkbox' | sheet.range('C2:C9').cellType = { type: 'checkbox' } |
comments | sheet.setNote('C4', 'Text'), or threads with sheet.addComment |
hiddenRows, hiddenColumns | sheet.hideRows(3, 5), sheet.hideCols(2, 2) |
readOnly: true | sheet.protect() with unlocked cells; see Protection |
contextMenu: [...] | Context menus |
afterChange | wb.events.on('cells-changed', fn), for typing, paste, fill, code and undo alike |
beforeChange | wb.events.on('before-change', (e) => e.cancel()), or before-commit for one edit |
exportFile with ExcelJS | await wb.saveXlsx(sink), with formulas, formats, charts and PivotTables |
Importing .xlsx with SheetJS | await wb.openFile(file) |
4. A first page
Data Grid
import { mountTable } from '@8sheets/data-grid';
const grid = await mountTable(document.querySelector('#orders'), {
title: 'Orders',
fields: [
{ name: 'id', type: 'number', readOnly: true },
{ name: 'product', type: 'string' },
{ name: 'units', type: 'number' },
{ name: 'price', type: 'number', format: '#,##0.00' },
{ name: 'total', type: 'number', format: '#,##0.00', formula: '[@units]*[@price]' },
],
data: await (await fetch('/api/orders')).json(),
onChange: (change) => console.log(change.action),
});Spreadsheet
import { mountWorkbook } from '@8sheets/core';
const wb = await mountWorkbook(document.querySelector('#sheet'), { chrome: 'light' });
const sheet = wb.activeSheet;
sheet.range('A1').values = [['Product', 'Units', 'Price', 'Total'], ['Pens', 4, 1.2, null], ['Paper', 2, 5.5, null]];
sheet.range('D2:D3').formulas = '=B2*C2';
wb.events.on('cells-changed', (e) => console.log(`${e.count} cells changed`));Both have React, Vue and Angular components.
5. Check before you switch
- Custom editors and renderers written against Handsontable's classes are rewritten. Look at cell types and cell renderers first, as many are built in.
- Rows and records. The Data Grid addresses a record by its id and a field by its name, not by row and column numbers. Code that keeps row numbers gets simpler, but has to change.
- Server-side code. Workbooks open, calculate and save in Node with the same API.
- Long-term support. Handsontable offers 24 months; an 8sheets licence has 12 months of updates and support, renewable if you want them.
- Try it with your own data in the Data Grid and the Spreadsheet apps, which run the code you would license.