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.

In-Browser Demos

Source Code

Issues and Bug Reports

-

File format support for known spreadsheet data formats:

-
- Graph of supported formats (click to show) +

License +Build Status +Snyk Vulnerabilities +npm Downloads +jsDelivr Downloads +Analytics

+

Browser Test and Support Matrix

+

Build Status

+

Supported File Formats

circo graph of format support

+
Diagram Legend (click to show)

graph legend

-

Browser Test

-

Build Status

-

Build Status -Coverage Status -Dependencies Status -npm Downloads -Analytics

Table of Contents

@@ -241,6 +241,8 @@ enhancements, additional features like styling, and dedicated support.

@@ -326,7 +328,7 @@ enhancements, additional features like styling, and dedicated support.

Frameworks and APIs

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.

Column Properties

@@ -1596,6 +1627,7 @@ objects which have the following properties:

wch?: 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 Comments

Cell 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 +