diff --git a/formats.png b/formats.png index 60ece9b..0b2cad7 100644 Binary files a/formats.png and b/formats.png differ diff --git a/index.html b/index.html index 9d38ddc..303d2bb 100644 --- a/index.html +++ b/index.html @@ -91,19 +91,19 @@ enhancements, additional features like styling, and dedicated support.
-File format support for known spreadsheet data formats:
-Browser Test and Support Matrix
+ +Supported File Formats
+ - - -Frameworks and APIs
angularjs
angular 2 / 4 / 5 / 6 and ionic
angular and ionic
knockout
meteor
react and react-native
An appropriate version for each dependency is included in the dist/ directory.
The complete single-file version is generated at dist/xlsx.full.min.js
A slimmer build with XLSX / HTML support is generated at dist/xlsx.mini.min.js
A slimmer build is generated at dist/xlsx.mini.min.js
. Compared to full build:
Webpack and Browserify builds include optional modules by default. Webpack can
be configured to remove support with resolve.alias
:
/* uncomment the lines below to remove support */
@@ -482,8 +490,7 @@ includes more examples with XMLHttpRequest
and fetch
.<
req.responseType = "arraybuffer";
req.onload = function(e) {
- var data = new Uint8Array(req.response);
- var workbook = XLSX.read(data, {type:"array"});
+ var workbook = XLSX.read(req.response);
/* DO SOMETHING WITH workbook HERE */
}
@@ -492,14 +499,23 @@ includes more examples with XMLHttpRequest
and fetch
.<
Browser drag-and-drop (click to show)
-Drag-and-drop uses the HTML5 FileReader
API.
+For modern browsers, Blob#arrayBuffer
can read data from files:
+async function handleDropAsync(e) {
+ e.stopPropagation(); e.preventDefault();
+ const f = evt.dataTransfer.files[0];
+ const data = await f.arrayBuffer();
+ const workbook = XLSX.read(data);
+
+ /* DO SOMETHING WITH workbook HERE */
+}
+drop_dom_element.addEventListener('drop', handleDropAsync, false);
+For maximal compatibility, the FileReader
API should be used:
function handleDrop(e) {
e.stopPropagation(); e.preventDefault();
- var files = e.dataTransfer.files, f = files[0];
+ var f = e.dataTransfer.files[0];
var reader = new FileReader();
reader.onload = function(e) {
- var data = new Uint8Array(e.target.result);
- var workbook = XLSX.read(data, {type: 'array'});
+ var workbook = XLSX.read(e.target.result);
/* DO SOMETHING WITH workbook HERE */
};
@@ -509,14 +525,23 @@ includes more examples with XMLHttpRequest
and fetch
.<
Browser file upload form element (click to show)
-Data from file input elements can be processed using the same FileReader
API
-as in the drag-and-drop example:
+Data from file input elements can be processed using the same APIs as in the
+drag-and-drop example.
+Using Blob#arrayBuffer
:
+async function handleFileAsync(e) {
+ const file = e.target.files[0];
+ const data = await file.arrayBuffer();
+ const workbook = XLSX.read(data);
+
+ /* DO SOMETHING WITH workbook HERE */
+}
+input_dom_element.addEventListener('change', handleFileAsync, false);
+Using FileReader
:
function handleFile(e) {
var files = e.target.files, f = files[0];
var reader = new FileReader();
reader.onload = function(e) {
- var data = new Uint8Array(e.target.result);
- var workbook = XLSX.read(data, {type: 'array'});
+ var workbook = XLSX.read(e.target.result);
/* DO SOMETHING WITH workbook HERE */
};
@@ -814,7 +839,7 @@ Stream. They are only exposed in NodeJS.
XLSX.write(wb, write_opts)
attempts to write the workbook wb
XLSX.writeFile(wb, filename, write_opts)
attempts to write wb
to filename
.
In browser-based environments, it will attempt to force a client-side download.
-XLSX.writeFileAsync(filename, wb, o, cb)
attempts to write wb
to filename
.
+
XLSX.writeFileAsync(wb, filename, o, cb)
attempts to write wb
to filename
.
If o
is omitted, the writer will use the third argument as the callback.
XLSX.stream
contains a set of streaming write functions.
Write options are described in the Writing Options section.
@@ -1554,33 +1579,39 @@ prefixed with an apostrophe '
, consistent with Excel's formula bar
A1-style strings
XLSX
-⭕
-⭕
+✔
+✔
RC-style strings
XLML and plain text
-⭕
-⭕
+✔
+✔
BIFF Parsed formulae
XLSB and all XLS formats
-⭕
+✔
OpenFormula formulae
ODS/FODS/UOS
-⭕
-⭕
+✔
+✔
+
+
+Lotus Parsed formulae
+All Lotus WK_ formats
+✔
+
Since Excel prohibits named cells from colliding with names of A1 or RC style
cell references, a (not-so-simple) regex conversion is possible. BIFF Parsed
-formulae have to be explicitly unwound. OpenFormula formulae can be converted
-with regular expressions.
+formulae and Lotus Parsed formulae have to be explicitly unwound. OpenFormula
+formulae can be converted with regular expressions.
@@ -1596,6 +1627,7 @@ objects which have the following properties:
Column Propertieswch?: number; // width in characters
/* other fields for preserving features from files */
+ level?: number; // 0-indexed outline / group level
MDW?: number; // Excel's "Max Digit Width" unit, always integral
};
@@ -1825,18 +1857,42 @@ functions accept the dateNF
option to override the interpretation o
specific format string.
+ Hyperlinks
+ Format Support (click to show)
+Cell Hyperlinks: XLSX/M, XLSB, BIFF8 XLS, XLML, ODS
+Tooltips: XLSX/M, XLSB, BIFF8 XLS, XLML
+
Hyperlinks are stored in the l
key of cell objects. The Target
field of the
hyperlink object is the target of the link, including the URI fragment. Tooltips
are stored in the Tooltip
field and are displayed when you move your mouse
over the text.
For example, the following snippet creates a link from cell A3
to
https://sheetjs.com with the tip "Find us @ SheetJS.com!"
:
-ws['A3'].l = { Target:"https://sheetjs.com", Tooltip:"Find us @ SheetJS.com!" };
+ws['A1'].l = { Target:"https://sheetjs.com", Tooltip:"Find us @ SheetJS.com!" };
Note that Excel does not automatically style hyperlinks -- they will generally
be displayed as normal text.
+Remote Links
+HTTP / HTTPS links can be used directly:
+ws['A2'].l = { Target:"https://docs.sheetjs.com/#hyperlinks" };
+ws['A3'].l = { Target:"http://localhost:7262/yes_localhost_works" };
+Excel also supports mailto
email links with subject line:
+ws['A4'].l = { Target:"mailto:ignored@dev.null" };
+ws['A5'].l = { Target:"mailto:ignored@dev.null?subject=Test Subject" };
+Local Links
+Links to absolute paths should use the file://
URI scheme:
+ws['B1'].l = { Target:"file:///SheetJS/t.xlsx" }; /* Link to /SheetJS/t.xlsx */
+ws['B2'].l = { Target:"file:///c:/SheetJS.xlsx" }; /* Link to c:\SheetJS.xlsx */
+Links to relative paths can be specified without a scheme:
+ws['B3'].l = { Target:"SheetJS.xlsb" }; /* Link to SheetJS.xlsb */
+ws['B4'].l = { Target:"../SheetJS.xlsm" }; /* Link to ../SheetJS.xlsm */
+Relative Paths have undefined behavior in the SpreadsheetML 2003 format. Excel
+2019 will treat a ..\
parent mark as two levels up.
+Internal Links
Links where the target is a cell or range or defined name in the same workbook
("Internal Links") are marked with a leading hash character:
-ws['A2'].l = { Target:"#E2" }; /* link to cell E2 */
+ws['C1'].l = { Target:"#E2" }; /* Link to cell E2 */
+ws['C2'].l = { Target:"#Sheet2!E2" }; /* Link to cell E2 in sheet Sheet2 */
+ws['C3'].l = { Target:"#SomeDefinedName" }; /* Link to Defined Name */
Cell CommentsCell comments are objects stored in the c
array of cell objects. The actual
@@ -2047,6 +2103,11 @@ property set to "macro"
.
false
If true, preserve _xlfn.
prefixes in formulae **
+
+FS
+
+DSV Field Separator override
+
@@ -2156,7 +2217,7 @@ file but Excel will know how to handle it. This library applies similar logic:<
0xD0
CFB Container
-BIFF 5/8 or password-protected XLSX/XLSB or WQ3/QPW
+BIFF 5/8 or protected XLSX/XLSB or WQ3/QPW or XLR
0x09
@@ -2171,7 +2232,7 @@ file but Excel will know how to handle it. This library applies similar logic:<
0x50
ZIP Archive
-XLSB or XLSX/M or ODS or UOS2 or plain text
+XLSB or XLSX/M or ODS or UOS2 or NUMBERS or text
0x49
@@ -2222,6 +2283,7 @@ file but Excel will know how to handle it. This library applies similar logic:<
DBF files are detected based on the first byte as well as the third and fourth
bytes (corresponding to month and day of the file date)
+Works for Windows files are detected based on the BOF record with type 0xFF
Plain text format guessing follows the priority order:
@@ -2242,8 +2304,7 @@ bytes (corresponding to month and day of the file date)
XML
-starts with <
-
+starts with <
and the first tag is valid
RTF
@@ -2256,11 +2317,15 @@ bytes (corresponding to month and day of the file date)
DSV
-more unquoted ";"
chars than "\t"
or ","
in the first 1024
+more unquoted `
+
+
+DSV
+more unquoted ;
chars than \t
or ,
in the first 1024
TSV
-more unquoted "\t"
chars than ","
chars in the first 1024
+more unquoted \t
chars than ,
chars in the first 1024
CSV
@@ -2274,7 +2339,12 @@ bytes (corresponding to month and day of the file date)
PRN
-(default)
+
+PRN
option is set to true
+
+
+CSV
+(fallback)
@@ -2423,6 +2493,20 @@ output formats. The specific file type is controlled with bookType
Excel 5.0/95 Workbook Format
+biff4
+.xls
+none
+single
+Excel 4.0 Worksheet Format
+
+
+biff3
+.xls
+none
+single
+Excel 3.0 Worksheet Format
+
+
biff2
.xls
none
@@ -2451,6 +2535,13 @@ output formats. The specific file type is controlled with bookType
Flat OpenDocument Spreadsheet
+wk3
+.wk3
+none
+single
+Lotus Workbook (WK3)
+
+
csv
.csv
none
@@ -2493,6 +2584,13 @@ output formats. The specific file type is controlled with bookType
dBASE II + VFP Extensions (DBF)
+wk1
+.wk1
+none
+single
+Lotus Worksheet (WK1)
+
+
rtf
.rtf
none
@@ -2604,6 +2702,11 @@ other values are stored as strings. The function takes an options argument:
false
Create cell objects of type z
for null
values
+
+nullError
+false
+If true, emit #NULL!
error cells for null
values
+
@@ -2643,6 +2746,11 @@ accepts an options argument:
Create cell objects of type z
for null
values
+nullError
+false
+If true, emit #NULL!
error cells for null
values
+
+
origin
Use specified cell as starting point (see below)
@@ -2709,7 +2817,7 @@ accepts an options argument:
XLSX.utils.json_to_sheet
takes an array of objects and returns a worksheet
with automatically-generated "headers" based on the keys of the objects. The
default column order is determined by the first appearance of the field using
-Object.keys
, but can be overridden using the options argument:
+Object.keys
. The function accepts an options argument:
@@ -2722,7 +2830,7 @@ default column order is determined by the first appearance of the field using
header
-Use specified column order (default Object.keys
)
+Use specified field order (default Object.keys
) **
dateNF
@@ -2739,8 +2847,21 @@ default column order is determined by the first appearance of the field using
false
If true, do not include header row in output
+
+nullError
+false
+If true, emit #NULL!
error cells for null
values
+
+
+- All fields from each row will be written. If
header
is an array and it does
+not contain a particular field, the key will be appended to the array.
+- Cell types are deduced from the type of each value. For example, a
Date
+object will generate a Date cell, while a string will generate a Text cell.
+- Null values will be skipped by default. If
nullError
is true, an error cell
+corresponding to #NULL!
will be written to the worksheet.
+
Examples (click to show)
The original sheet cannot be reproduced using plain objects since JS object keys
@@ -2789,6 +2910,11 @@ an options argument:
If true, do not include header row in output
+nullError
+false
+If true, emit #NULL!
error cells for null
values
+
+
origin
Use specified cell as starting point (see below)
@@ -3307,43 +3433,43 @@ be true to generate blank rows
Excel 2007+ XML Formats (XLSX/XLSM)
-⭕
-⭕
+✔
+✔
Excel 2007+ Binary Format (XLSB BIFF12)
-⭕
-⭕
+✔
+✔
Excel 2003-2004 XML Format (XML "SpreadsheetML")
-⭕
-⭕
+✔
+✔
Excel 97-2004 (XLS BIFF8)
-⭕
-⭕
+✔
+✔
Excel 5.0/95 (XLS BIFF5)
-⭕
-⭕
+✔
+✔
Excel 4.0 (XLS/XLW BIFF4)
-⭕
-
+✔
+✔
Excel 3.0 (XLS BIFF3)
-⭕
-
+✔
+✔
Excel 2.0/2.1 (XLS BIFF2)
-⭕
-⭕
+✔
+✔
Excel Supported Text Formats
@@ -3352,28 +3478,28 @@ be true to generate blank rows
Delimiter-Separated Values (CSV/TXT)
-⭕
-⭕
+✔
+✔
Data Interchange Format (DIF)
-⭕
-⭕
+✔
+✔
Symbolic Link (SYLK/SLK)
-⭕
-⭕
+✔
+✔
Lotus Formatted Text (PRN)
-⭕
-⭕
+✔
+✔
UTF-16 Unicode Text (TXT)
-⭕
-⭕
+✔
+✔
Other Workbook/Worksheet Formats
@@ -3381,33 +3507,53 @@ be true to generate blank rows
:-----:
+Numbers 3.0+ / iWork 2013+ Spreadsheet (NUMBERS)
+✔
+
+
+
OpenDocument Spreadsheet (ODS)
-⭕
-⭕
+✔
+✔
Flat XML ODF Spreadsheet (FODS)
-⭕
-⭕
+✔
+✔
Uniform Office Format Spreadsheet (标文通 UOS1/UOS2)
-⭕
+✔
dBASE II/III/IV / Visual FoxPro (DBF)
-⭕
-⭕
+✔
+✔
-Lotus 1-2-3 (WKS/WK1/WK2/WK3/WK4/123)
-⭕
+Lotus 1-2-3 (WK1/WK3)
+✔
+✔
+
+
+Lotus 1-2-3 (WKS/WK2/WK4/123)
+✔
Quattro Pro Spreadsheet (WQ1/WQ2/WB1/WB2/WB3/QPW)
-⭕
+✔
+
+
+
+Works 1.x-3.x DOS / 2.x-5.x Windows Spreadsheet (WKS)
+✔
+
+
+
+Works 6.x-9.x Spreadsheet (XLR)
+✔
@@ -3417,18 +3563,18 @@ be true to generate blank rows
HTML Tables
-⭕
-⭕
+✔
+✔
Rich Text Format tables (RTF)
-⭕
+✔
Ethercalc Record Format (ETH)
-⭕
-⭕
+✔
+✔
@@ -3469,11 +3615,35 @@ range limits will be silently truncated:
16384
+Excel 4.0 (XLS BIFF4)
+IV16384
+256
+16384
+
+
+Excel 3.0 (XLS BIFF3)
+IV16384
+256
+16384
+
+
Excel 2.0/2.1 (XLS BIFF2)
IV16384
256
16384
+
+Lotus 1-2-3 R2 - R5 (WK1/WK3/WK4)
+IV8192
+256
+8192
+
+
+Lotus 1-2-3 R1 (WKS)
+IV2048
+256
+2048
+
Excel 2003 SpreadsheetML range limits are governed by the version of Excel and
@@ -3565,6 +3735,8 @@ The main focus is data extraction.
The Lotus formats consist of binary records similar to the BIFF structure. Lotus
did release a specification decades ago covering the original WK1 format. Other
features were deduced by producing files and comparing to Excel support.
+Generated WK1 worksheets are compatible with Lotus 1-2-3 R2 and Excel 5.0.
+Generated WK3 workbooks are compatible with Lotus 1-2-3 R9 and Excel 5.0.
@@ -3575,6 +3747,32 @@ Some of the newer formats (namely WB3 and QPW) use a CFB enclosure just like
BIFF8 XLS.
Quattro Pro (WQ1/WQ2/WB1/WB2/WB3/QPW)
+
+ Works for DOS / Windows Spreadsheet (WKS/XLR)
+ (click to show)
+All versions of Works were limited to a single worksheet.
+Works for DOS 1.x - 3.x and Works for Windows 2.x extends the Lotus WKS format
+with additional record types.
+Works for Windows 3.x - 5.x uses the same format and WKS extension. The BOF
+record has type FF
+Works for Windows 6.x - 9.x use the XLR format. XLR is nearly identical to
+BIFF8 XLS: it uses the CFB container with a Workbook stream. Works 9 saves the
+exact Workbook stream for the XLR and the 97-2003 XLS export. Works 6 XLS
+includes two empty worksheets but the main worksheet has an identical encoding.
+XLR also includes a WksSSWorkBook
stream similar to Lotus FM3/FMT files.
+
+
+
+ Numbers 3.0+ / iWork 2013+ Spreadsheet (NUMBERS)
+ (click to show)
+iWork 2013 (Numbers 3.0 / Pages 5.0 / Keynote 6.0) switched from a proprietary
+XML-based format to the current file format based on the iWork Archive (IWA).
+This format has been used up through the current release (Numbers 11.2).
+The parser focuses on extracting raw data from tables. Numbers technically
+supports multiple tables in a logical worksheet, including custom titles. This
+parser will generate one worksheet per Numbers table.
+
+
OpenDocument Spreadsheet (ODS/FODS)
(click to show)
diff --git a/legend.png b/legend.png
index 9719f96..b531c4f 100644
Binary files a/legend.png and b/legend.png differ