Supported formats
read detects a format from file content. For output, set bookType on write
or let writeFile infer the format from the filename.
Full distribution
Section titled “Full distribution”| Format | bookType |
Read | Write |
|---|---|---|---|
| Excel workbook 2007+ | xlsx |
Yes | Yes |
| Excel macro workbook / add-in | xlsm, xlam |
Yes | Yes |
| Excel binary workbook 2007+ | xlsb |
Yes | Yes |
| Excel 97–2004 / BIFF8 | xls, biff8 |
Yes | Yes |
| Earlier Excel BIFF versions | biff5, biff4, biff3, biff2 |
Yes | Yes |
| Excel 97 add-in | xla |
Yes | Yes |
| Excel 2003 XML | xlml |
Yes | Yes |
| OpenDocument spreadsheet | ods |
Yes | Yes |
| Flat OpenDocument spreadsheet | fods |
Yes | Yes |
| Apple Numbers | numbers |
Yes | Yes, with payload |
| Comma-separated values | csv |
Yes | Yes |
| Tab-delimited text | txt |
Yes | Yes |
| Formatted/fixed-width text | prn |
Yes | Yes |
| SYLK | sylk (slk alias) |
Yes | Yes |
| Data Interchange Format | dif |
Yes | Yes |
| dBASE table | dbf |
Yes | Yes |
| Ethercalc | eth |
Yes | Yes |
| HTML table | html |
Yes | Yes |
| RTF table | rtf |
Yes | Yes |
| Lotus 1-2-3 | wk1, wk3 |
Yes | Yes |
Some runtime-supported identifiers are missing from the TypeScript BookType
union. See TypeScript before using xlam, biff3,
biff4, wk1, or wk3 in typed code.
Choose an output format
Section titled “Choose an output format”const XLSX = require("@agent-sheet/wasm");const assert = require("node:assert/strict");const workbook = XLSX.utils.book_new();XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet([["Name", "Score"], ["Lee", 9]]), "Results");for (const bookType of ["xlsx", "xlsb", "xls", "ods"]) { const data = XLSX.write(workbook, { type: "buffer", bookType }); const result = XLSX.read(data); assert.equal(result.Sheets[result.SheetNames[0]].B2.v, 9);}Text formats generally hold one sheet. Select it with the write option sheet
(name or zero-based index); the default is the first worksheet. CSV has no
representation for workbook styles, formulas, merges, or extra worksheets.
Numbers writing requires the numbers option. See
Distribution files.
Reduced mini distribution
Section titled “Reduced mini distribution”dist/xlsx.mini.min.js has the same reduced format coverage as the original
@agent-sheet/wasm mini distribution:
- Reads: XLSX, ODS, CSV, text, SYLK, DIF, DBF, PRN and Ethercalc.
- Writes: those formats and XLSM.
- Omits
streamandparse_xlscfb.
Do not infer mini support from the full distribution’s table. An omitted format throws an error.
Data support is not full metadata preservation
Section titled “Data support is not full metadata preservation”A format can support a successful read and write while losing features that are not represented by the ordinary JavaScript workbook model or its writer.
- XLSX supports values, formulas, cell styles and many sheet properties. The ordinary JavaScript model does not represent every possible package part.
- XLS, XLSB, XLML and ODS have different representations and metadata coverage. Do not assume that styling or worksheet properties survive equally in each.
- A writer storing a formula does not mean the library calculates that formula. Use a cached value if your output consumer needs one immediately.
- Use XLSX/XLSM template mode to preserve existing package parts that an ordinary read-edit-write would discard.
Validate a representative round trip for the exact format and metadata you need. Opening output in Microsoft Excel, Apple Numbers or other spreadsheet applications is a separate compatibility check and is not claimed as tested.
Encryption
Section titled “Encryption”Encrypted workbook input and output are not available. Worksheet protection flags are supported separately; they are not file encryption.