This commit is contained in:
SheetJS 2023-10-24 02:20:57 -04:00
parent 66c787222e
commit 4b984058b5
12 changed files with 109 additions and 38 deletions

@ -4,7 +4,6 @@ pagination_prev: demos/net/index
pagination_next: demos/mobile/index
---
import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
With the advent of server-side frameworks and content management systems, it is

@ -1,5 +1,5 @@
{
"label": "Common Use Cases",
"collapsed": true,
"position": 6
"position": 5
}

@ -1,4 +1,4 @@
{
"label": "SheetJS Data Model",
"position": 7
"position": 6
}

@ -1,4 +1,4 @@
{
"label": "API Reference",
"position": 8
"position": 7
}

@ -154,6 +154,6 @@ ESM helper functions are described in the ["NodeJS" Installation section](/docs/
:::
`XLSX.SSF` is an embedded version of the [format library](https://git.sheetjs.com/sheetjs/sheetjs/src/branch/master/packages/ssf).
`XLSX.SSF` is an embedded version of the [format library](/docs/constellation/ssf).
`XLSX.CFB` is an embedded version of the [container library](https://git.sheetjs.com/sheetjs/js-cfb).

@ -0,0 +1,26 @@
---
title: SSF Number Formatter
---
As explained in ["Number Formats"](/docs/csf/features/nf), modern spreadsheet
file formats separate "content" from "presentation". Instead of storing a
formatted value like `$3.50`, applications will store the underlying value
(`3.50`) and the number format (`$0.00`). Parsers are expected to render values.
The SheetJS `SSF` ("SpreadSheet Formatter") library formats numbers according
to the number formatting rules defined in Excel and other spreadsheet software[^1]
A version of the library ships with the main file processing library. It is
deeply integrated in SheetJS CE API functions including `read`[^2], `write`[^3],
and `sheet_to_json`[^4].
The library is also available for standalone use on the SheetJS CDN[^5].
The source code and project documentation is hosted on the SheetJS git server at
<https://git.sheetjs.com/sheetjs/sheetjs/src/branch/master/packages/ssf>
[^1]: The number formatting rules are sketched in ECMA-376. A rough grammar is defined in the MS-XLS specification.
[^2]: See [`read` in "Reading Files"](/docs/api/parse-options)
[^3]: See [`write` in "Writing Files"](/docs/api/write-options)
[^4]: See [`sheet_to_json` in "Utilities"](/docs/api/utilities/array#array-output)
[^5]: See <https://cdn.sheetjs.com/ssf/> for more details.

@ -0,0 +1,4 @@
{
"label": "Constellation",
"position": 9
}

@ -0,0 +1,20 @@
---
title: SheetJS Constellation
pagination_prev: miscellany/index
---
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
Many related projects have been separated into dedicated libraries.
### Contents
<ul>{useCurrentSidebarCategory().items.map(globalThis.lambda = (item, index) => {
const listyle = (item.customProps?.icon) ? {
listStyleImage: `url("${item.customProps.icon}")`
} : {};
return (<li style={listyle} {...(item.customProps?.class ? {className: item.customProps.class}: {})}>
<a href={item.href}>{item.label}</a>{item.customProps?.summary && (" - " + item.customProps.summary)}
<ul>{item.items && item.items.map(lambda)}</ul>
</li>);
})}</ul>

@ -1,15 +1,10 @@
---
title: File Formats
sidebar_position: 1
hide_table_of_contents: true
pagination_prev: api/utilities/index
---
# File Formats
![graph of format support](pathname:///formats.png)
![graph legend](pathname:///legend.png)
SheetJS supports reading and writing a number of spreadsheet file formats.
| Format | Read | Write |
|:-------------------------------------------------------------|:-----:|:-----:|
@ -45,8 +40,16 @@ pagination_prev: api/utilities/index
| Rich Text Format tables (RTF) | ✔ | ✔ |
| Ethercalc Record Format (ETH) | ✔ | ✔ |
Features not supported by a given file format will not be written. Formats with
range limits will be silently truncated:
![graph of format support](pathname:///formats.png)
![graph legend](pathname:///legend.png)
Features not supported by a given file format will not be written.
## Worksheet Range Limits
Formats with range limits will be silently truncated. For example, the Lotus WKS
format has a limit of 2048 rows, so data after the 2048th row will not be saved.
| Format | Last Cell | Max Cols | Max Rows |
|:------------------------------------------|:-----------|---------:|---------:|
@ -65,7 +68,9 @@ range limits will be silently truncated:
Excel 2003 SpreadsheetML range limits are governed by the version of Excel and
are not enforced by the writer.
### Excel 2007+ XML (XLSX/XLSM)
## Common File Formats
#### Excel 2007+ XML (XLSX/XLSM)
XLSX and XLSM files are ZIP containers containing a series of XML files in
accordance with the Open Packaging Conventions (OPC). The XLSM format, almost
@ -75,7 +80,7 @@ The format is standardized in `ECMA-376` and `ISO/IEC 29500`. Excel does not
follow the specification, and there are additional documents discussing how
Excel deviates from the specification.
### Excel 2.0-95 (BIFF2/BIFF3/BIFF4/BIFF5)
#### Excel 2.0-95 (BIFF2/BIFF3/BIFF4/BIFF5)
BIFF 2/3 XLS are single-sheet streams of binary records. Excel 4 introduced
the concept of a workbook (`XLW` files) but also had single-sheet `XLS` format.
@ -92,7 +97,7 @@ files in these formats, so record lengths and fields were determined by writing
in all of the supported formats and comparing files. Excel 2016 can generate
BIFF5 files, enabling a full suite of file tests starting from XLSX or BIFF2.
### Excel 97-2004 Binary (BIFF8)
#### Excel 97-2004 Binary (BIFF8)
BIFF8 exclusively uses the Compound File Binary container format, splitting some
content into streams within the file. At its core, it still uses an extended
@ -101,14 +106,14 @@ version of the binary record format from older versions of BIFF.
The `MS-XLS` specification covers the basics of the file format, and other
specifications expand on serialization of features like properties.
### Excel 2003-2004 (SpreadsheetML)
#### Excel 2003-2004 (SpreadsheetML)
Predating XLSX, SpreadsheetML files are simple XML files. There is no official
and comprehensive specification, although MS has released documentation on the
format. Since Excel 2016 can generate SpreadsheetML files, mapping features is
pretty straightforward.
### Excel 2007+ Binary (XLSB, BIFF12)
#### Excel 2007+ Binary (XLSB, BIFF12)
Introduced in parallel with XLSX, the XLSB format combines the BIFF architecture
with the content separation and ZIP container of XLSX. For the most part nodes
@ -117,7 +122,7 @@ in an XLSX sub-file can be mapped to XLSB records in a corresponding sub-file.
The `MS-XLSB` specification covers the basics of the file format, and other
specifications expand on serialization of features like properties.
### Delimiter-Separated Values (CSV/TXT)
#### Delimiter-Separated Values (CSV/TXT)
Excel CSV deviates from RFC4180 in a number of important ways. The generated
CSV files should generally work in Excel although they may not work in RFC4180
@ -132,7 +137,18 @@ will be proactively reinterpreted as CSV. There are some files with semicolon
delimiter that align with a valid SYLK file. For the broadest compatibility,
all cells with the value of `ID` are automatically wrapped in double-quotes.
### Miscellaneous Workbook Formats
#### HTML
Excel HTML worksheets include special metadata encoded in styles. For example,
`mso-number-format` is a localized string containing the number format. Despite
the metadata the output is valid HTML, although it does accept bare `&` symbols.
The writer adds type metadata to the TD elements via the `t` tag. The parser
looks for those tags and overrides the default interpretation. For example, text
like `<td>12345</td>` will be parsed as numbers but `<td t="s">12345</td>` will
be parsed as text.
## Miscellaneous Workbook Formats
Support for other formats is generally far behind XLS/XLSB/XLSX support, due in
part to a lack of publicly available documentation. Test files were produced in
@ -202,16 +218,16 @@ is in the names of tags and attributes.
ET is the native format for WPS Office Spreadsheet. It extends the BIFF8 XLS
format with proprietary extensions.
### Miscellaneous Worksheet Formats
## Miscellaneous Worksheet Formats
Many older formats supported only one worksheet:
#### dBASE and Visual FoxPro (DBF)
DBF is really a typed table format: each column can only hold one data type and
each record omits type information. The parser generates a header row and
inserts records starting at the second row of the worksheet. The writer makes
files compatible with Visual FoxPro extensions.
DBF is a typed table format: each column can only hold one data type and each
record omits type information. The parser generates a header row and inserts
records starting at the second row of the worksheet. The writer makes files
compatible with Visual FoxPro extensions.
Multi-file extensions like external memos and tables are currently unsupported,
limited by the general ability to read arbitrary files in the web browser. The
@ -241,17 +257,6 @@ behavior from Excel. In particular, Excel extends DIF in incompatible ways:
- DIF technically has no support for formulae, but Excel will automatically
convert plain formulae. Array formulae are not preserved.
#### HTML
Excel HTML worksheets include special metadata encoded in styles. For example,
`mso-number-format` is a localized string containing the number format. Despite
the metadata the output is valid HTML, although it does accept bare `&` symbols.
The writer adds type metadata to the TD elements via the `t` tag. The parser
looks for those tags and overrides the default interpretation. For example, text
like `<td>12345</td>` will be parsed as numbers but `<td t="s">12345</td>` will
be parsed as text.
#### Rich Text Format (RTF)
Excel RTF worksheets are stored in clipboard when copying cells or ranges from a

@ -1,4 +1,4 @@
{
"label": "Miscellany",
"position": 9
"position": 8
}

@ -0,0 +1,16 @@
---
title: Miscellany
pagination_next: constellation/index
---
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
<ul>{useCurrentSidebarCategory().items.map(globalThis.lambda = (item, index) => {
const listyle = (item.customProps?.icon) ? {
listStyleImage: `url("${item.customProps.icon}")`
} : {};
return (<li style={listyle} {...(item.customProps?.class ? {className: item.customProps.class}: {})}>
<a href={item.href}>{item.label}</a>{item.customProps?.summary && (" - " + item.customProps.summary)}
<ul>{item.items && item.items.map(lambda)}</ul>
</li>);
})}</ul>

@ -181,6 +181,7 @@ const config = {
{ from: '/docs/demos/vue', to: '/docs/demos/frontend/vue/' },
{ from: '/docs/demos/bundler', to: '/docs/demos/frontend/bundler/' },
{ from: '/docs/demos/legacy', to: '/docs/demos/frontend/legacy/' },
{ from: '/docs/getting-started/demos/legacy', to: '/docs/demos/frontend/legacy/' },
/* cloud */
{ from: '/docs/demos/salesforce', to: '/docs/demos/cloud/salesforce/' },
{ from: '/docs/demos/aws', to: '/docs/demos/cloud/aws/' },