Skip to content

Commit

Permalink
version bump 0.8.0: unification with js-xls 0.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
SheetJSDev committed Apr 2, 2015
1 parent 61b17e6 commit 0d38d4c
Show file tree
Hide file tree
Showing 70 changed files with 20,750 additions and 843 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ misc/coverage.html
misc/prof.js
v8.log
tmp
*.txt
*.csv
*.dif
*.prn
*.slk
*.socialcalc
*.xls
*.xlsb
*.xlsm
*.xlsx
*.xlsm
*.xlsb
*.xml
*.htm
*.html
*.sheetjs
4 changes: 4 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"bitwise": false,
"curly": false
}
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ index.html
misc/
node_modules
tmp
*.txt
*.csv
*.dif
*.prn
*.slk
*.socialcalc
*.xls
*.xlsb
*.xlsm
*.xlsx
*.xml
*.htm
*.html
*.sheetjs
.gitignore
.jshintrc
CONTRIBUTING.md
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- "0.11"
- "iojs"
- "0.11.14"
- "0.10"
- "0.8"
before_install:
Expand Down
18 changes: 14 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ order to maintain that, every contributor must be vigilant.

There have been many projects in the past that have been very lax regarding
licensing, and we are of the opinion that those are ticking timebombs and that
no corporate product should depend on them.
no commercial product should depend on them.


# Required Reading
Expand All @@ -17,6 +17,17 @@ These are pretty short reads and emphasize the importance of proper licensing:
- http://www.codinghorror.com/blog/2007/04/pick-a-license-any-license.html


# Raising Issues

Issues should generally be accompanied by test files. Since github does not
support attachments, the best method is to send files to <[email protected]>
(subject line should contain issue number or message) or to share using some
storage service. Unless expressly permitted, any attachments will not be
shared or included in a test suite (although I will ask :)

If sending email to a gmail account is problematic, the <[email protected]> email
inbox is self-hosted.

# Pre-Contribution Checklist

Before thinking about contributing, make sure that:
Expand All @@ -27,7 +38,7 @@ Before thinking about contributing, make sure that:
Corporation or a subsidiary

- You have not consulted any existing relevant codebase (if you have, please
take note of which codebases were consulted).
take note of which codebases were consulted).

If you cannot attest to each of these items, the best approach is to raise an
issue. If it is a particularly high-priority issue, please drop an email to
Expand All @@ -45,9 +56,8 @@ Keep these in mind as you work:
- You are working on your own time. Unless they explicitly grant permission,
your employer may be the ultimate owner of your IP


# Post-Contribution

Before contributions are merged, you will receive an email (at the address
associated with the git commit) and will be asked to confirm the aforementioned
items.
items. Ensure that the email addresses associated with the commits is valid.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2012-2014 SheetJS
Copyright (C) 2012-2015 SheetJS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LIB=xlsx
FMT=xlsx xlsm xlsb ods misc full
FMT=xlsx xlsm xlsb ods xls xml misc full
REQS=jszip.js
ADDONS=dist/cpexcel.js
AUXTARGETS=ods.js
Expand All @@ -17,6 +17,9 @@ $(TARGET): $(DEPS)
bits/01_version.js: package.json
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@

bits/18_cfb.js: node_modules/cfb/dist/xlscfb.js
cp $^ $@

.PHONY: clean
clean:
rm -f $(TARGET)
Expand Down Expand Up @@ -88,8 +91,11 @@ dist: dist-deps $(TARGET) bower.json
cp $(TARGET) dist/
cp LICENSE dist/
uglifyjs $(TARGET) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).min.js
uglifyjs $(REQS) $(TARGET) -o dist/$(LIB).core.min.js --source-map dist/$(LIB).core.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).core.min.js
uglifyjs $(REQS) $(ADDONS) $(TARGET) -o dist/$(LIB).full.min.js --source-map dist/$(LIB).full.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).full.min.js

.PHONY: aux
aux: $(AUXTARGETS)
Expand Down
92 changes: 70 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
# xlsx

Parser and writer for Excel 2007+ (XLSX/XLSM/XLSB) files and parser for ODS.
Pure-JS cleanroom implementation from the Office Open XML spec, [MS-XLSB], ODF
specifications and related documents.
Parser and writer for various spreadsheet formats. Pure-JS cleanroom
implementation from official specifications and related documents.

Supported read formats:

- Excel 2007+ XML Formats (XLSX/XLSM)
- Excel 2007+ Binary Format (XLSB)
- Excel 2003-2004 XML Format (XML "SpreadsheetML")
- Excel 97-2004 (XLS BIFF8)
- Excel 5.0/95 (XLS BIFF5)
- OpenDocument Spreadsheet (ODS)

Supported write formats:

- XLSX
- CSV (and general DSV)
- JSON and JS objects (various styles)

Demo: <http://oss.sheetjs.com/js-xlsx>

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

## Installation

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

npm install xlsx

In the browser:

<script lang="javascript" src="dist/xlsx.core.min.js"></script>

In [bower](http://bower.io/search/?q=js-xlsx):
With [bower](http://bower.io/search/?q=js-xlsx):

bower install js-xlsx

Expand All @@ -27,7 +41,7 @@ CDNjs automatically pulls the latest version and makes all versions available at

## Optional Modules

The nodejs version automatically requires modules for additional features. Some
The node version automatically requires modules for additional features. Some
of these modules are rather large in size and are only needed in special
circumstances, so they do not ship with the core. For browser use, they must
be included directly:
Expand Down Expand Up @@ -56,7 +70,7 @@ To use the shim, add the shim before the script tag that loads xlsx.js:
For parsing, the first step is to read the file. This involves acquiring the
data and feeding it into the library. Here are a few common scenarios:

- nodejs readFile:
- node readFile:

```
if(typeof require !== 'undefined') XLSX = require('xlsx');
Expand Down Expand Up @@ -142,13 +156,32 @@ input_dom_element.addEventListener('change', handleFile, false);

## Working with the Workbook

This example walks through every cell of every sheet and dumps the values:
The full object format is described later in this README.

This example extracts the value stored in cell A1 from the first worksheet:

```
var first_sheet_name = workbook.SheetNames[0];
var address_of_cell = 'A1';
/* Get worksheet */
var worksheet = workbook.Sheets[first_sheet_name];
/* Find desired cell */
var desired_cell = worksheet[address_of_cell];
/* Get the value */
var desired_value = desired_cell.v;
```

This example iterates through every nonempty of every sheet and dumps values:

```
var sheet_name_list = workbook.SheetNames;
sheet_name_list.forEach(function(y) {
sheet_name_list.forEach(function(y) { /* iterate through sheets */
var worksheet = workbook.Sheets[y];
for (z in worksheet) {
/* all keys that do not begin with "!" correspond to cell addresses */
if(z[0] === '!') continue;
console.log(y + "!" + z + "=" + JSON.stringify(worksheet[z].v));
}
Expand All @@ -166,9 +199,9 @@ mode is provided for testing. On OSX you can get the base64 encoding with:

- <http://oss.sheetjs.com/js-xlsx/ajax.html> XMLHttpRequest

- <https://github.com/SheetJS/js-xlsx/blob/master/bin/xlsx.njs> nodejs
- <https://github.com/SheetJS/js-xlsx/blob/master/bin/xlsx.njs> node

The nodejs version installs a binary `xlsx` which can read XLSX/XLSM/XLSB
The node version installs a command line tool `xlsx` which can read spreadsheet
files and output the contents in various formats. The source is available at
`xlsx.njs` in the bin directory.

Expand Down Expand Up @@ -220,7 +253,7 @@ Complete examples:

## Interface

`XLSX` is the exposed variable in the browser and the exported nodejs variable
`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).

Expand Down Expand Up @@ -374,7 +407,8 @@ Special worksheet keys (accessible as `worksheet[key]`, each starting with `!`):
`wb.Sheets[sheetname]` returns an object representing the worksheet.

`wb.Props` is an object storing the standard properties. `wb.Custprops` stores
custom properties.
custom properties. Since the XLS standard properties deviate from the XLSX
standard, XLS parsing stores core properties in both places. .


## Parsing Options
Expand All @@ -383,7 +417,7 @@ The exported `read` and `readFile` functions accept an options argument:

| Option Name | Default | Description |
| :---------- | ------: | :---------- |
| cellFormula | true | Save formulae to the .f field |
| cellFormula | true | Save formulae to the .f field ** |
| cellHTML | true | Parse rich text and save HTML to the .h field |
| cellNF | false | Save number format string to the .z field |
| cellStyles | false | Save style/theme info to the .s field |
Expand All @@ -395,17 +429,24 @@ The exported `read` and `readFile` functions accept an options argument:
| bookProps | false | If true, only parse enough to get book metadata ** |
| 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 ** |

- `cellFormula` option only applies to formats that require extra processing to
parse formulae (XLS/XLSB).
- Even if `cellNF` is false, formatted text will be generated and saved to `.w`
- In some cases, sheets may be parsed even if `bookSheets` is false.
- `bookSheets` and `bookProps` combine to give both sets of information
- `Deps` will be an empty object if `bookDeps` is falsy
- `bookFiles` adds a `keys` array (paths in the ZIP) and a `files` hash (whose
keys are paths and values are objects representing the files)
- `bookFiles` behavior depends on file type:
* `keys` array (paths in the ZIP) for ZIP-based formats
* `files` hash (mapping paths to objects representing the files) for ZIP
* `cfb` object for formats using CFB containers
- `sheetRows-1` rows will be generated when looking at the JSON object output
(since the header row is counted as a row when parsing the data)
- `bookVBA` merely exposes the raw vba object. It does not parse the data.
- `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.

The defaults are enumerated in bits/84_defaults.js

Expand All @@ -430,7 +471,7 @@ The exported `write` and `writeFile` functions accept an options argument:

## Tested Environments

- NodeJS 0.8, 0.10 (latest release), 0.11 (unstable)
- NodeJS 0.8, 0.10 (latest release), 0.11.14 (unstable), io.js
- IE 6/7/8/9/10/11 using Base64 mode (IE10/11 using HTML5 mode)
- FF 18 using Base64 or HTML5 mode
- Chrome 24 using Base64 or HTML5 mode
Expand All @@ -449,7 +490,7 @@ Running `make init` will refresh the `test_files` submodule and get the files.

## Testing

`make test` will run the nodejs-based tests. To run the in-browser tests, clone
`make test` will run the node-based tests. 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`):

Expand Down Expand Up @@ -481,10 +522,6 @@ $ diff xlsx.js xlsx.new.js
To produce the dist files, run `make dist`. The dist files are updated in each
version release and should not be committed between versions.

## XLS Support

XLS is available in [js-xls](http://git.io/xls).

## License

Please consult the attached LICENSE file for details. All rights not explicitly
Expand All @@ -506,7 +543,18 @@ OSP-covered specifications:
- [MS-XLSB]: Excel (.xlsb) Binary File Format
- [MS-XLSX]: Excel (.xlsx) Extensions to the Office Open XML SpreadsheetML File Format
- [MS-OE376]: Office Implementation Information for ECMA-376 Standards Support
- [MS-CFB]: Compound File Binary File Format
- [MS-XLS]: Excel Binary File Format (.xls) Structure Specification
- [MS-ODATA]: Open Data Protocol (OData)
- [MS-OFFCRYPTO]: Office Document Cryptography Structure
- [MS-OLEDS]: Object Linking and Embedding (OLE) Data Structures
- [MS-OLEPS]: Object Linking and Embedding (OLE) Property Set Data Structures
- [MS-OSHARED]: Office Common Data Types and Objects Structures
- [MS-OVBA]: Office VBA File Format Structure
- [MS-CTXLS]: Excel Custom Toolbar Binary File Format
- [MS-XLDM]: Spreadsheet Data Model File Format
- [MS-EXSPXML3]: Excel Calculation Version 2 Web Service XML Schema
- [XLS]: Microsoft Office Excel 97-2007 Binary File Format Specification

Open Document Format for Office Applications Version 1.2 (29 September 2011)

Expand Down
4 changes: 3 additions & 1 deletion bin/xlsx.njs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
/* xlsx.js (C) 2013-2015 SheetJS -- http://sheetjs.com */
var n = "xlsx";
/* vim: set ts=2 ft=javascript: */
var X = require('../');
Expand All @@ -9,6 +9,7 @@ program
.usage('[options] <file> [sheetname]')
.option('-f, --file <file>', 'use specified workbook')
.option('-s, --sheet <sheet>', 'print specified sheet (default first sheet)')
.option('-p, --password <pw>', 'if file is encrypted, try with specified pw')
.option('-l, --list-sheets', 'list sheet names and exit')
.option('-o, --output <file>', 'output to specified file')
.option('-B, --xlsb', 'emit XLSB to <sheetname> or <file>.xlsb')
Expand Down Expand Up @@ -67,6 +68,7 @@ if(!fs.existsSync(filename)) {
var opts = {}, wb;
if(program.listSheets) opts.bookSheets = true;
if(program.sheetRows) opts.sheetRows = program.sheetRows;
if(program.password) opts.password = program.password;
if(program.xlsx || program.xlsm || program.xlsb) {
opts.cellNF = true;
if(program.output) sheetname = program.output;
Expand Down
1 change: 1 addition & 0 deletions bits/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js
5 changes: 3 additions & 2 deletions bits/00_header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
/* xlsx.js (C) 2013-2015 SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*jshint -W041 */
/*jshint funcscope:true, eqnull:true */
var XLSX = {};
(function(XLSX){
(function make_xlsx(XLSX){
2 changes: 1 addition & 1 deletion bits/01_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
XLSX.version = '0.7.12';
XLSX.version = '0.8.0';
Loading

0 comments on commit 0d38d4c

Please sign in to comment.