Skip to content

Commit

Permalink
version bump 0.9.2: more bugfixes
Browse files Browse the repository at this point in the history
- decode sheet name for XLSX and XLML (fixes #203 h/t @rocketmonkeys)
- XFExt (fixes #298 h/t @aetna-softwares @aimcom @baharudinafif)
- handle truly empty `<is>` elements (fixes #506 h/t @asksahil)
- pin version numbers for dependencies (fixes #469 h/t @nhtera)
- sed usage fix (see #572 h/t @Liryna)
- fix hex2RGB substr indices (fixes #294 h/t @kamorahul)
- removed stale typescript files (see #442)
- reworked shift formula regex (fixed #551 h/t @SheetJSDev)
- README note on webpack codepage suppression (fixes #438 h/t @rusty1s)
- README note on WTF (fixes #487 h/t @livesoftware)
  • Loading branch information
SheetJSDev committed Mar 13, 2017
1 parent 8cd9e81 commit 456ab63
Show file tree
Hide file tree
Showing 29 changed files with 422 additions and 531 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
node_modules
*.tgz
misc/coverage.html
misc/prof.js
v8.log
Expand Down
2 changes: 2 additions & 0 deletions .npmignore
Expand Up @@ -4,6 +4,7 @@ demos/
index.html
misc/
node_modules
*.tgz
tmp
*.txt
*.[cC][sS][vV]
Expand All @@ -20,6 +21,7 @@ tmp
*.htm
*.html
*.sheetjs
*.exe
.gitignore
.jshintrc
CONTRIBUTING.md
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,18 @@ but not limited to API changes and file location changes. Minor behavioral
changes may not be included if they are not expected to break existing code.


## 0.9.2 (2017-03-13)

* Removed stale TypeScript definition files. Flowtype comments are used in the
`xlsx.flow.js` source and stripped to produce `xlsx.js`.
* sed usage reworked to support GNU sed in-place form. BSD sed seems to work,
but the build script has not been tested on other sed variants:

```bash
$ sed -i.ext [...] # GNU
$ sed -i .ext [...] # bsd
```

## 0.9.0 (2017-03-09)

* Removed ods.js source. The xlsx.js source absorbed the ODS logic and exposes
Expand Down
182 changes: 129 additions & 53 deletions README.md
Expand Up @@ -5,36 +5,68 @@ implementation from official specifications, related documents, and test files.
Emphasis on parsing and writing robustness, cross-format feature compatibility
with a unified JS representation, and ES3/ES5 browser compatibility back to IE6.

File format support for known spreadsheet data formats:
[**In-Browser Demo**](http://oss.sheetjs.com/js-xlsx)

| Format | Read | Write |
|:-------------------------------------------------------------|:-----:|:-----:|
| **Excel Worksheet/Workbook Formats** |:-----:|:-----:|
| Excel 2007+ XML Formats (XLSX/XLSM) | :o: | :o: |
| Excel 2007+ Binary Format (XLSB BIFF12) | :o: | :o: |
| Excel 2003-2004 XML Format (XML "SpreadsheetML") | :o: | |
| Excel 97-2004 (XLS BIFF8) | :o: | |
| Excel 5.0/95 (XLS BIFF5) | :o: | |
| Excel 4.0 (XLS/XLW BIFF4) | :o: | |
| Excel 3.0 (XLS BIFF3) | :o: | |
| Excel 2.0/2.1 (XLS BIFF2) | :o: | :o: |
| **Excel Supported Text Formats** |:-----:|:-----:|
| Delimiter-Separated Values (CSV/TSV/DSV) | | :o: |
| **Other Workbook/Worksheet Formats** |:-----:|:-----:|
| OpenDocument Spreadsheet (ODS) | :o: | :o: |
| Flat XML ODF Spreadsheet (FODS) | :o: | :o: |
| Uniform Office Format Spreadsheet (标文通 UOS1/UOS2) | :o: | |
| **Other Common Spreadsheet Output Formats** |:-----:|:-----:|
| HTML Tables | :o: | |
[**Source Code**](http://git.io/xlsx)

![circo graph of format support](formats.png)
[**Commercial Support**](http://sheetjs.com/reinforcements)

Demo: <http://oss.sheetjs.com/js-xlsx>
[**File format support for known spreadsheet data formats:**](#file-formats)

![circo graph of format support](formats.png)

Source: <http://git.io/xlsx>

Paid support available through the [reinforcements program](http://sheetjs.com/reinforcements)

## Table of Contents

<!-- toc -->

- [Installation](#installation)
* [JS Ecosystem Demos](#js-ecosystem-demos)
* [Optional Modules](#optional-modules)
* [ECMAScript 5 Compatibility](#ecmascript-5-compatibility)
- [Parsing Workbooks](#parsing-workbooks)
- [Working with the Workbook](#working-with-the-workbook)
- [Writing Workbooks](#writing-workbooks)
- [Interface](#interface)
* [Parsing functions](#parsing-functions)
* [Writing functions](#writing-functions)
* [Utilities](#utilities)
- [Workbook / Worksheet / Cell Object Description](#workbook--worksheet--cell-object-description)
* [General Structures](#general-structures)
* [Cell Object](#cell-object)
* [Data Types](#data-types)
* [Formulae](#formulae)
* [Worksheet Object](#worksheet-object)
* [Workbook Object](#workbook-object)
- [Parsing Options](#parsing-options)
* [Input Type](#input-type)
* [Guessing File Type](#guessing-file-type)
- [Writing Options](#writing-options)
* [Supported Output Formats](#supported-output-formats)
* [Output Type](#output-type)
- [Utility Functions](#utility-functions)
* [Formulae Output](#formulae-output)
* [CSV and general DSV Output](#csv-and-general-dsv-output)
* [JSON](#json)
- [File Formats](#file-formats)
* [Excel 2007+ XML (XLSX/XLSM)](#excel-2007-xml-xlsxxlsm)
* [Excel 2.0-95 (BIFF2/BIFF3/BIFF4/BIFF5)](#excel-20-95-biff2biff3biff4biff5)
* [Excel 97-2004 Binary (BIFF8)](#excel-97-2004-binary-biff8)
* [Excel 2003-2004 (SpreadsheetML)](#excel-2003-2004-spreadsheetml)
* [Excel 2007+ Binary (XLSB, BIFF12)](#excel-2007-binary-xlsb-biff12)
* [OpenDocument Spreadsheet (ODS/FODS) and Uniform Office Spreadsheet (UOS1/2)](#opendocument-spreadsheet-odsfods-and-uniform-office-spreadsheet-uos12)
* [Comma-Separated Values](#comma-separated-values)
* [HTML](#html)
- [Testing](#testing)
* [Tested Environments](#tested-environments)
* [Test Files](#test-files)
- [Contributing](#contributing)
- [License](#license)
- [References](#references)
- [Badges](#badges)

<!-- tocstop -->

## Installation

Expand Down Expand Up @@ -83,6 +115,17 @@ 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`

Webpack and browserify builds include optional modules by default. Webpack can
be configured to remove support with `resolve.alias`:

```js
/* uncomment the lines below to remove support */
resolve: {
alias: { "./dist/cpexcel.js": "" } // <-- omit international support
}
```


### ECMAScript 5 Compatibility

Since xlsx.js uses ES5 functions like `Array#forEach`, older browsers require
Expand Down Expand Up @@ -143,10 +186,10 @@ oReq.send();
```js
/* processing array buffers, only required for readAsArrayBuffer */
function fixdata(data) {
var o = "", l = 0, w = 10240;
for(; l<data.byteLength/w; ++l) o+=String.fromCharCode.apply(null,new Uint8Array(data.slice(l*w,l*w+w)));
o+=String.fromCharCode.apply(null, new Uint8Array(data.slice(l*w)));
return o;
var o = "", l = 0, w = 10240;
for(; l<data.byteLength/w; ++l) o+=String.fromCharCode.apply(null,new Uint8Array(data.slice(l*w,l*w+w)));
o+=String.fromCharCode.apply(null, new Uint8Array(data.slice(l*w)));
return o;
}

var rABS = true; // true: readAsBinaryString ; false: readAsArrayBuffer
Expand Down Expand Up @@ -528,6 +571,7 @@ The exported `read` and `readFile` functions accept an options argument:
| bookSheets | false | If true, only parse enough to get the sheet names |
| bookVBA | false | If true, expose vbaProject.bin to `vbaraw` field ** |
| password | "" | If defined and file is encrypted, use password ** |
| WTF | false | If true, throw errors on unexpected file features ** |

- `cellFormula` option only applies to formats that require extra processing to
parse formulae (XLS/XLSB).
Expand All @@ -545,6 +589,9 @@ The exported `read` and `readFile` functions accept an options argument:
- `cellDates` currently does not convert numerical dates to JS dates.
- Currently only XOR encryption is supported. Unsupported error will be thrown
for files employing other encryption methods.
- WTF is mainly for development. By default, the parser will suppress read
errors on single worksheets, allowing you to read from the worksheets that do
parse properly. Setting `WTF:1` forces those errors to be thrown.

The defaults are enumerated in bits/84\_defaults.js

Expand Down Expand Up @@ -754,8 +801,37 @@ Example showing the effect of `raw`:

## File Formats

Despite the fact that the name of the library is `xlsx`, it supports numerous
non-XLSX file formats:
Despite the library name `xlsx`, it supports numerous spreadsheet file formats:

| Format | Read | Write |
|:-------------------------------------------------------------|:-----:|:-----:|
| **Excel Worksheet/Workbook Formats** |:-----:|:-----:|
| Excel 2007+ XML Formats (XLSX/XLSM) | :o: | :o: |
| Excel 2007+ Binary Format (XLSB BIFF12) | :o: | :o: |
| Excel 2003-2004 XML Format (XML "SpreadsheetML") | :o: | |
| Excel 97-2004 (XLS BIFF8) | :o: | |
| Excel 5.0/95 (XLS BIFF5) | :o: | |
| Excel 4.0 (XLS/XLW BIFF4) | :o: | |
| Excel 3.0 (XLS BIFF3) | :o: | |
| Excel 2.0/2.1 (XLS BIFF2) | :o: | :o: |
| **Excel Supported Text Formats** |:-----:|:-----:|
| Delimiter-Separated Values (CSV/TSV/DSV) | | :o: |
| **Other Workbook/Worksheet Formats** |:-----:|:-----:|
| OpenDocument Spreadsheet (ODS) | :o: | :o: |
| Flat XML ODF Spreadsheet (FODS) | :o: | :o: |
| Uniform Office Format Spreadsheet (标文通 UOS1/UOS2) | :o: | |
| **Other Common Spreadsheet Output Formats** |:-----:|:-----:|
| HTML Tables | :o: | |

### 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 filetype, almost
identical to XLSX, is used for files containing macros.

The format is standardized in ECMA-376 and later in 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)

Expand Down Expand Up @@ -816,26 +892,6 @@ 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.

## Tested Environments

- NodeJS 0.8, 0.9, 0.10, 0.11, 0.12, 4.x, 5.x, 6.x, 7.x
- IE 6/7/8/9/10/11 (IE6-9 browsers require shims for interacting with client)
- Chrome 24+
- Safari 6+
- FF 18+

Tests utilize the mocha testing framework. Travis-CI and Sauce Labs links:

- <https://travis-ci.org/SheetJS/js-xlsx> for XLSX module in nodejs
- <https://travis-ci.org/SheetJS/SheetJS.github.io> for XLS\* modules
- <https://saucelabs.com/u/sheetjs> for XLS\* modules using Sauce Labs

## Test Files

Test files are housed in [another repo](https://github.com/SheetJS/test_files).

Running `make init` will refresh the `test_files` submodule and get the files.

## Testing

`make test` will run the node-based tests. By default it runs tests on files in
Expand Down Expand Up @@ -865,16 +921,36 @@ $ make lint # JSHint and JSCS checks
$ make flow # make lint + Flow checking
```

To run the in-browser tests, clone
[The oss.sheetjs.com repo](https://github.com/SheetJS/SheetJS.github.io) and
replace the xlsx.js file (then fire up the browser and go to `stress.html`):
To run the in-browser tests, clone the repo for
[oss.sheetjs.com](https://github.com/SheetJS/SheetJS.github.io) and replace
the xlsx.js file (then fire up the browser and go to `stress.html`):

```bash
$ cp xlsx.js ../SheetJS.github.io
$ cd ../SheetJS.github.io
$ simplehttpserver # or "python -mSimpleHTTPServer" or "serve"
$ open -a Chromium.app http://localhost:8000/stress.html
```
### Tested Environments

- NodeJS 0.8, 0.9, 0.10, 0.11, 0.12, 4.x, 5.x, 6.x, 7.x
- IE 6/7/8/9/10/11 (IE6-9 browsers require shims for interacting with client)
- Chrome 24+
- Safari 6+
- FF 18+

Tests utilize the mocha testing framework. Travis-CI and Sauce Labs links:

- <https://travis-ci.org/SheetJS/js-xlsx> for XLSX module in nodejs
- <https://travis-ci.org/SheetJS/SheetJS.github.io> for XLS\* modules
- <https://saucelabs.com/u/sheetjs> for XLS\* modules using Sauce Labs

### Test Files

Test files are housed in [another repo](https://github.com/SheetJS/test_files).

Running `make init` will refresh the `test_files` submodule and get the files.



## Contributing
Expand Down
2 changes: 1 addition & 1 deletion bits/01_version.js
@@ -1 +1 @@
XLSX.version = '0.9.1';
XLSX.version = '0.9.2';
1 change: 0 additions & 1 deletion bits/30_ctype.js
Expand Up @@ -193,7 +193,6 @@ function parse_ct(data/*:?string*/, opts) {
case '<Default': ctext[y.Extension] = y.ContentType; break;
case '<Override':
if(ct[ct2type[y.ContentType]] !== undefined) ct[ct2type[y.ContentType]].push(y.PartName);
else if(opts.WTF) console.error(y);
break;
}
});
Expand Down
2 changes: 1 addition & 1 deletion bits/34_extprops.js
Expand Up @@ -70,7 +70,7 @@ function write_ext_props(cp, opts)/*:string*/ {

/* TODO: HeadingPairs, TitlesOfParts */
o[o.length] = (W('HeadingPairs', W('vt:vector', W('vt:variant', '<vt:lpstr>Worksheets</vt:lpstr>')+W('vt:variant', W('vt:i4', String(cp.Worksheets))), {size:2, baseType:"variant"})));
o[o.length] = (W('TitlesOfParts', W('vt:vector', cp.SheetNames.map(function(s) { return "<vt:lpstr>" + s + "</vt:lpstr>"; }).join(""), {size: cp.Worksheets, baseType:"lpstr"})));
o[o.length] = (W('TitlesOfParts', W('vt:vector', cp.SheetNames.map(function(s) { return "<vt:lpstr>" + escapexml(s) + "</vt:lpstr>"; }).join(""), {size: cp.Worksheets, baseType:"lpstr"})));
if(o.length>2){ o[o.length] = ('</Properties>'); o[1]=o[1].replace("/>",">"); }
return o.join("");
}
1 change: 0 additions & 1 deletion bits/39_xlsbiff.js
Expand Up @@ -34,7 +34,6 @@ function parse_XTI(blob, length) {
function parse_RkRec(blob, length) {
var ixfe = blob.read_shift(2);
var RK = parse_RkNumber(blob);
//console.log("::", ixfe, RK,";;");
return [ixfe, RK];
}

Expand Down
2 changes: 1 addition & 1 deletion bits/45_styutils.js
@@ -1,6 +1,6 @@
function hex2RGB(h) {
var o = h.substr(h[0]==="#"?1:0,6);
return [parseInt(o.substr(0,2),16),parseInt(o.substr(0,2),16),parseInt(o.substr(0,2),16)];
return [parseInt(o.substr(0,2),16),parseInt(o.substr(2,2),16),parseInt(o.substr(4,2),16)];
}
function rgb2Hex(rgb) {
for(var i=0,o=1; i!=3; ++i) o = o*256 + (rgb[i]>255?255:rgb[i]<0?0:rgb[i]);
Expand Down
9 changes: 7 additions & 2 deletions bits/50_styxls.js
Expand Up @@ -68,10 +68,15 @@ function update_xfext(xf, xfext) {
switch(xfe[0]) { /* 2.5.108 extPropData */
case 0x04: break; /* foreground color */
case 0x05: break; /* background color */
case 0x07: case 0x08: case 0x09: case 0x0a: break;
case 0x06: break; /* gradient fill */
case 0x07: break; /* top cell border color */
case 0x08: break; /* bottom cell border color */
case 0x09: break; /* left cell border color */
case 0x0a: break; /* right cell border color */
case 0x0b: break; /* diagonal cell border color */
case 0x0d: break; /* text color */
case 0x0e: break; /* font scheme */
default: throw "bafuq" + xfe[0].toString(16);
case 0x0f: break; /* indentation level */
}
});
}
Expand Down
5 changes: 3 additions & 2 deletions bits/61_fcommon.js
Expand Up @@ -16,9 +16,10 @@ var rc_to_a1 = (function(){
};
})();

/* TODO actually parse the formula */
/* no defined name can collide with a valid cell address A1:XFD1048576 ... except LOG10! */
var crefregex = /(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)([1-9]\d{0,5}|10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6])(?![_.\(A-Za-z0-9])/g;
function shift_formula_str(f/*:string*/, delta/*:Cell*/)/*:string*/ {
return f.replace(/(^|[^A-Z0-9])([$]?)([A-Z]+)([$]?)(\d+)/g, function($0, $1, $2, $3, $4, $5, off, str) {
return f.replace(crefregex, function($0, $1, $2, $3, $4, $5, off, str) {
return $1+($2=="$" ? $2+$3 : encode_col(decode_col($3)+delta.c))+($4=="$" ? $4+$5 : encode_row(decode_row($5) + delta.r));
});
}
Expand Down
2 changes: 1 addition & 1 deletion bits/67_wsxml.js
Expand Up @@ -265,7 +265,7 @@ return function parse_ws_xml_data(sdata, s, opts, guess) {
case 'inlineStr':
cref = d.match(isregex);
p.t = 's';
if(cref != null) { if((sstr = parse_si(cref[1]))) p.v = sstr.t; } else p.v = "";
if(cref != null && (sstr = parse_si(cref[1]))) p.v = sstr.t; else p.v = "";
break; // inline string
case 'b': p.v = parsexmlbool(p.v); break;
case 'd':
Expand Down
4 changes: 2 additions & 2 deletions bits/72_wbxml.js
Expand Up @@ -41,7 +41,7 @@ function parse_wb_xml(data, opts)/*:WorkbookFile*/ {
/* 18.2.20 sheets CT_Sheets 1 */
case '<sheets>': case '</sheets>': break; // aggregate sheet
/* 18.2.19 sheet CT_Sheet + */
case '<sheet': delete y[0]; y.name = utf8read(y.name); wb.Sheets.push(y); break;
case '<sheet': delete y[0]; y.name = unescapexml(utf8read(y.name)); wb.Sheets.push(y); break;
case '</sheet>': break;

/* 18.2.15 functionGroups CT_FunctionGroups ? */
Expand Down Expand Up @@ -140,7 +140,7 @@ function write_wb_xml(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:string*/ {
o[o.length] = (writextag('workbookPr', null, {date1904:safe1904(wb)}));
o[o.length] = "<sheets>";
for(var i = 0; i != wb.SheetNames.length; ++i)
o[o.length] = (writextag('sheet',null,{name:wb.SheetNames[i].substr(0,31), sheetId:""+(i+1), "r:id":"rId"+(i+1)}));
o[o.length] = (writextag('sheet',null,{name:escapexml(wb.SheetNames[i].substr(0,31)), sheetId:""+(i+1), "r:id":"rId"+(i+1)}));
o[o.length] = "</sheets>";
if(o.length>2){ o[o.length] = '</workbook>'; o[1]=o[1].replace("/>",">"); }
return o.join("");
Expand Down
2 changes: 1 addition & 1 deletion bits/75_xlml.js
Expand Up @@ -237,7 +237,7 @@ function parse_xlml_xml(d, opts)/*:Workbook*/ {
r = c = 0;
state.push([Rn[3], false]);
tmp = xlml_parsexmltag(Rn[0]);
sheetname = tmp.Name;
sheetname = unescapexml(tmp.Name);
cursheet = {};
mergecells = [];
}
Expand Down
22 changes: 11 additions & 11 deletions dist/xlsx.core.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/xlsx.core.min.map

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions dist/xlsx.full.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/xlsx.full.min.map

Large diffs are not rendered by default.

0 comments on commit 456ab63

Please sign in to comment.