Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
version bump 0.10.0: cleanup
- updated SSF to 0.9.2
- XLSB style records and number format writing
- CSV avoid parseFloat (fixes #646 h/t @jabbermarky)
- CSV recognize mac line ending (fixes #648 h/t @charlesread)
- BIFF2 format table refactored to align with SSF
- BIFF5 image data exposure
- SSF custom format auto table update (fixes #267 h/t @Fangmingdu)
- eslint more checks
- browser test timeout extended to 10 seconds
  • Loading branch information
SheetJSDev committed May 9, 2017
1 parent 810c447 commit a873658
Show file tree
Hide file tree
Showing 62 changed files with 3,891 additions and 1,728 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Expand Up @@ -5,10 +5,12 @@
"ecmaVersion": 3,
},
"plugins": [ "html", "json" ],
"!extends": "eslint:recommended",
"rules": {
"no-use-before-define": [ 1, {
"functions":false, "classes":true, "variables":false
}],
"no-console": 0,
"no-bitwise": 0,
"curly": 0,
"comma-style": [ 2, "last" ],
Expand Down
110 changes: 73 additions & 37 deletions README.md
Expand Up @@ -6,7 +6,8 @@ Emphasis on parsing and writing robustness, cross-format feature compatibility
with a unified JS representation, and ES3/ES5 browser compatibility back to IE6.

This is the community version. We also offer a pro version with performance
enhancements and additional features by request.
enhancements, additional features by request, and dedicated support.


[**Pro Version**](http://sheetjs.com/pro)

Expand All @@ -18,17 +19,33 @@ enhancements and additional features by request.

[**Source Code**](http://git.io/xlsx)

[**File format support for known spreadsheet data formats:**](#file-formats)
[**Issues and Bug Reports**](https://github.com/sheetjs/js-xlsx/issues)

![circo graph of format support](formats.png)
[**Other General Support Issues**](https://discourse.sheetjs.com)

[**File format support for known spreadsheet data formats:**](#file-formats)

<details>
<summary>Graph Legend</summary>
<summary><b>Graph of supported formats</b> (click to show)</summary>

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

![graph legend](legend.png)

</details>

[**Browser Test**](http://oss.sheetjs.com/js-xlsx/tests/)

[![Build Status](https://saucelabs.com/browser-matrix/sheetjs.svg)](https://saucelabs.com/u/sheetjs)

[![Build Status](https://travis-ci.org/SheetJS/js-xlsx.svg?branch=master)](https://travis-ci.org/SheetJS/js-xlsx)
[![Build Status](https://semaphoreci.com/api/v1/sheetjs/js-xlsx/branches/master/shields_badge.svg)](https://semaphoreci.com/sheetjs/js-xlsx)
[![Coverage Status](http://img.shields.io/coveralls/SheetJS/js-xlsx/master.svg)](https://coveralls.io/r/SheetJS/js-xlsx?branch=master)
[![Dependencies Status](https://david-dm.org/sheetjs/js-xlsx/status.svg)](https://david-dm.org/sheetjs/js-xlsx)
[![NPM Downloads](https://img.shields.io/npm/dt/xlsx.svg)](https://npmjs.org/package/xlsx)
[![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/js-xlsx)](https://ghit.me/repo/sheetjs/js-xlsx)
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx)

## Table of Contents

<details>
Expand All @@ -40,6 +57,7 @@ enhancements and additional features by request.
* [JS Ecosystem Demos](#js-ecosystem-demos)
* [Optional Modules](#optional-modules)
* [ECMAScript 5 Compatibility](#ecmascript-5-compatibility)
- [Philosophy](#philosophy)
- [Parsing Workbooks](#parsing-workbooks)
* [Complete Examples](#complete-examples)
* [Note on Streaming Read](#note-on-streaming-read)
Expand Down Expand Up @@ -114,24 +132,23 @@ enhancements and additional features by request.
* [Windows](#windows)
- [License](#license)
- [References](#references)
- [Badges](#badges)

<!-- tocstop -->

</details>

## Installation

With [npm](https://www.npmjs.org/package/xlsx):
In the browser, just add a script tag:

```bash
$ npm install xlsx
```html
<script lang="javascript" src="dist/xlsx.full.min.js"></script>
```

In the browser:
With [npm](https://www.npmjs.org/package/xlsx):

```html
<script lang="javascript" src="dist/xlsx.core.min.js"></script>
```bash
$ npm install xlsx
```

With [bower](http://bower.io/search/?q=js-xlsx):
Expand Down Expand Up @@ -194,6 +211,41 @@ To use the shim, add the shim before the script tag that loads xlsx.js:
<script type="text/javascript" src="/path/to/shim.js"></script>
```

## Philosophy

<details>
<summary><b>Philosophy</b> (click to show)</summary>

Prior to SheetJS, APIs for processing spreadsheet files were format-specific.
Third-party libraries either supported one format, or they involved a separate
set of classes for each supported file type. Even though XLSB was introduced in
Excel 2007, nothing outside of SheetJS or Excel supported the format.

To promote a format-agnostic view, js-xlsx starts from a pure-JS representation
that we call the ["Common Spreadsheet Format"](#common-spreadsheet-format).
Emphasizing a uniform object representation enables radical features like format
conversion (e.g. reading an XLSX template and saving as XLS) and circumvents the
"class trap". By abstracting the complexities of the various formats, tools
need not worry about the specific file type!

A simple object representation combined with careful coding practices enables
use cases in older browsers and in alternative environments like ExtendScript
and Web Workers. It is always tempting to use the latest and greatest features,
but they tend to require the latest versions of browsers, limiting usability.

Utility functions capture common use cases like generating JS objects or HTML.
Most simple operations should only require a few lines of code. More complex
operations generally should be straightforward to implement.

Excel pushes the XLSX format as default starting in Excel 2007. However, there
are other formats with more appealing properties. For example, the XLSB format
is spiritually similar to XLSX but files often tend up taking less than half the
space and open much faster! Even though an XLSX writer is available, other
format writers are available so users can take advantage of the unique
characteristics of each format.

</details>

## Parsing Workbooks

For parsing, the first step is to read the file. This involves acquiring the
Expand Down Expand Up @@ -505,7 +557,6 @@ Utilities are available in the `XLSX.utils` object:
**Exporting:**

- `sheet_to_json` converts a worksheet object to an array of JSON objects.
`sheet_to_row_object_array` is an alias that will be removed in the future.
- `sheet_to_csv` generates delimiter-separated-values output.
- `sheet_to_formulae` generates a list of the formulae (with value fallbacks).

Expand Down Expand Up @@ -1008,17 +1059,14 @@ at index 164. The following example creates a custom format from scratch:

```js
var tbl = {};
XLSX.SSF.init_table(tbl); // <-- load builtin formats
tbl[164] = "\"T\"\ #0.00";
var wb = {
SSF: tbl,
SheetNames: ["Sheet1"],
Sheets: {
Sheet1: {
"!ref":"A1:C1",
A1: { t:"n", v:10000 }, // <-- General format
B1: { t:"n", v:10000, z: tbl[4] }, // <-- Builtin format
C1: { t:"n", v:10000, z: tbl[164] } // <-- Custom format
A1: { t:"n", v:10000 }, // <-- General format
B1: { t:"n", v:10000, z: "0%" }, // <-- Builtin format
C1: { t:"n", v:10000, z: "\"T\"\ #0.00" } // <-- Custom format
}
}
}
Expand Down Expand Up @@ -1439,8 +1487,8 @@ the output will be encoded in codepage `1200` and the BOM will be prepended.

### JSON

`XLSX.utils.sheet_to_json` and the alias `XLSX.utils.sheet_to_row_object_array`
generate different types of JS objects. The function takes an options argument:
`XLSX.utils.sheet_to_json` generates different types of JS objects. The function
takes an options argument:

| Option Name | Default | Description |
| :---------- | :------: | :-------------------------------------------------- |
Expand Down Expand Up @@ -1834,6 +1882,9 @@ $ open -a Chromium.app http://localhost:8000/stress.html

### Tested Environments

<details>
<summary>(click to show)</summary>

- 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+
Expand All @@ -1847,6 +1898,8 @@ Tests utilize the mocha testing framework. Travis-CI and Sauce Labs links:
- <https://travis-ci.org/SheetJS/SheetJS.github.io> for XLS\* modules
- <https://saucelabs.com/u/sheetjs> for XLS\* modules using Sauce Labs

</details>

### Test Files

Test files are housed in [another repo](https://github.com/SheetJS/test_files).
Expand Down Expand Up @@ -1980,20 +2033,3 @@ granted by the Apache 2.0 License are reserved by the Original Author.
- Worksheet File Format (From Lotus) December 1984


## Badges

[![Build Status](https://saucelabs.com/browser-matrix/sheetjs.svg)](https://saucelabs.com/u/sheetjs)

[![Build Status](https://travis-ci.org/SheetJS/js-xlsx.svg?branch=master)](https://travis-ci.org/SheetJS/js-xlsx)

[![Build Status](https://semaphoreci.com/api/v1/sheetjs/js-xlsx/branches/master/shields_badge.svg)](https://semaphoreci.com/sheetjs/js-xlsx)

[![Coverage Status](http://img.shields.io/coveralls/SheetJS/js-xlsx/master.svg)](https://coveralls.io/r/SheetJS/js-xlsx?branch=master)

[![NPM Downloads](https://img.shields.io/npm/dt/xlsx.svg)](https://npmjs.org/package/xlsx)

[![Dependencies Status](https://david-dm.org/sheetjs/js-xlsx/status.svg)](https://david-dm.org/sheetjs/js-xlsx)

[![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/js-xlsx)](https://ghit.me/repo/sheetjs/js-xlsx)

[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx)
7 changes: 4 additions & 3 deletions bin/xlsx.njs
@@ -1,5 +1,6 @@
#!/usr/bin/env node
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
var n = "xlsx";
/* vim: set ts=2 ft=javascript: */
var X = require('../');
Expand Down Expand Up @@ -176,9 +177,9 @@ var oo = "";
var strm = false;
if(!program.quiet) console.error(target_sheet);
if(program.formulae) oo = X.utils.get_formulae(ws).join("\n");
else if(program.json) oo = JSON.stringify(X.utils.sheet_to_row_object_array(ws));
else if(program.rawJs) oo = JSON.stringify(X.utils.sheet_to_row_object_array(ws,{raw:true}));
else if(program.arrays) oo = JSON.stringify(X.utils.sheet_to_row_object_array(ws,{raw:true, header:1}));
else if(program.json) oo = JSON.stringify(X.utils.sheet_to_json(ws));
else if(program.rawJs) oo = JSON.stringify(X.utils.sheet_to_json(ws,{raw:true}));
else if(program.arrays) oo = JSON.stringify(X.utils.sheet_to_json(ws,{raw:true, header:1}));
else {
strm = true;
var stream = X.stream.to_csv(ws, {FS:program.fieldSep, RS:program.rowSep});
Expand Down
1 change: 1 addition & 0 deletions bits/00_header.js
Expand Up @@ -3,5 +3,6 @@
/*jshint -W041 */
/*jshint funcscope:true, eqnull:true */
/*exported XLSX */
/*global exports, module, require:false, process:false, Buffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
2 changes: 1 addition & 1 deletion bits/01_version.js
@@ -1 +1 @@
XLSX.version = '0.9.13';
XLSX.version = '0.10.0';
6 changes: 3 additions & 3 deletions bits/02_codepage.js
@@ -1,8 +1,8 @@
var current_codepage = 1200, current_cptable;
var current_codepage = 1200;
/*:: declare var cptable:any; */
/*global cptable:true */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
if(typeof cptable === 'undefined') cptable = require('./dist/cpexcel.js');
current_cptable = cptable[current_codepage];
}
function reset_cp() { set_cp(1200); }
var set_cp = function(cp) { current_codepage = cp; };
Expand All @@ -18,7 +18,7 @@ var debom = function(data/*:string*/)/*:string*/ {

var _getchar = function _gc1(x) { return String.fromCharCode(x); };
if(typeof cptable !== 'undefined') {
set_cp = function(cp) { current_codepage = cp; current_cptable = cptable[cp]; };
set_cp = function(cp) { current_codepage = cp; };
debom = function(data) {
if(data.charCodeAt(0) === 0xFF && data.charCodeAt(1) === 0xFE) { return cptable.utils.decode(1200, char_codes(data.substr(2))); }
return data;
Expand Down
4 changes: 2 additions & 2 deletions bits/04_base64.js
@@ -1,7 +1,7 @@
var Base64 = (function make_b64(){
var map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
return {
encode: function(input/*:string*/, utf8)/*:string*/ {
encode: function(input/*:string*/)/*:string*/ {
var o = "";
var c1, c2, c3, e1, e2, e3, e4;
for(var i = 0; i < input.length; ) {
Expand All @@ -18,7 +18,7 @@ var Base64 = (function make_b64(){
}
return o;
},
decode: function b64_decode(input/*:string*/, utf8)/*:string*/ {
decode: function b64_decode(input/*:string*/)/*:string*/ {
var o = "";
var c1, c2, c3;
var e1, e2, e3, e4;
Expand Down

0 comments on commit a873658

Please sign in to comment.