40_interface.md 1.9 KB
Newer Older
S
SheetJS 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
## Interface

`XLSX` is the exposed variable in the browser and the exported node variable

`XLSX.version` is the version of the library (added by the build script).

`XLSX.SSF` is an embedded version of the [format library](http://git.io/ssf).

### Parsing functions

`XLSX.read(data, read_opts)` attempts to parse `data`.

`XLSX.readFile(filename, read_opts)` attempts to read `filename` and parse.

Parse options are described in the [Parsing Options](#parsing-options) section.

### Writing functions

`XLSX.write(wb, write_opts)` attempts to write the workbook `wb`

`XLSX.writeFile(wb, filename, write_opts)` attempts to write `wb` to `filename`

S
SheetJS 已提交
23 24 25
`XLSX.writeFileAsync(filename, wb, o, cb)` attempts to write `wb` to `filename`.
If `o` is omitted, the writer will use the third argument as the callback.

26 27
`XLSX.stream` contains a set of streaming write functions.

S
SheetJS 已提交
28 29 30 31
Write options are described in the [Writing Options](#writing-options) section.

### Utilities

S
SheetJS 已提交
32 33
Utilities are available in the `XLSX.utils` object and are described in the
[Utility Functions](#utility-functions) section:
S
SheetJS 已提交
34

S
SheetJS 已提交
35 36 37
**Importing:**

- `aoa_to_sheet` converts an array of arrays of JS data to a worksheet.
38
- `json_to_sheet` converts an array of JS objects to a worksheet.
S
SheetJS 已提交
39
- `table_to_sheet` converts a DOM TABLE element to a worksheet.
S
SheetJS 已提交
40

S
SheetJS 已提交
41

S
SheetJS 已提交
42 43 44 45
**Exporting:**

- `sheet_to_json` converts a worksheet object to an array of JSON objects.
- `sheet_to_csv` generates delimiter-separated-values output.
S
SheetJS 已提交
46
- `sheet_to_html` generates HTML output.
S
SheetJS 已提交
47 48 49 50 51
- `sheet_to_formulae` generates a list of the formulae (with value fallbacks).


**Cell and cell address manipulation:**

S
SheetJS 已提交
52 53 54 55 56
- `format_cell` generates the text value for a cell (using number formats).
- `encode_row / decode_row` converts between 0-indexed rows and 1-indexed rows.
- `encode_col / decode_col` converts between 0-indexed columns and column names.
- `encode_cell / decode_cell` converts cell addresses.
- `encode_range / decode_range` converts cell ranges.
S
SheetJS 已提交
57