Excel workbooks
Open .xlsx and .xlsb workbooks, edit them with commands, save .xlsx or print to PDF.
Open, edit, save
const book = ExcelDocument.open(bytes); // or ExcelDocument.create()book.command({ cmd: 'select', cell: 'B2' });book.command({ cmd: 'enter', text: '1250', then: 'down' });book.command({ cmd: 'enter', text: '=SUM(B2:B6)' });book.command({ cmd: 'format', bold: 'toggle', fill: '#e8f5e9' });const xlsx = book.save();const pdf = book.pdf({ all: true }); // every visible sheet, with its page setupconst sheets = book.pdf({ view: true }); // the sheet pages the viewer keeps annotations on| Command | Does |
|---|---|
select, move, selectAll, home, end | Select cells, ranges or a name; move like the arrow keys |
enter, clear | Type a value or a formula; clear contents, formats or both |
format, borders, merge | Fonts, colours, fills, alignment, wrapping, number formats; borders; merging |
colWidth, rowHeight, autofit, hide, unhide | Sizes and visibility |
insert, delete | Rows and columns |
sheet | Add, rename, delete, move, duplicate, hide, colour and select sheets |
copy, cut, paste, fill, sort | Clipboard (with paste values or formats), fill handle, sorting |
freeze, zoom, grid, find | View settings and search |
evaluate | Calculate a formula without changing the sheet |
undo, redo, state | History and the current state |
Drawing a sheet
render(sheet, x, y, width, height, scale) draws part of a sheet to RGBA pixels, for your own grid. The viewer uses it with tiles.
What is supported
- About 170 functions, shared and array formulas, defined names, structured references.
- Conditional formatting (including the Excel 2010 rules), tables with styles and filters, data validation, notes and threaded comments.
- Number formats, fonts, borders, fills, merges, frozen panes, charts and pictures.
- .xlsb workbooks open and are saved as .xlsx.