version bump 0.12.4: zip cleanup

- PK magic number bound (fixes #1013 h/t @wlpeter)
- removed JSZip conflict (fixes #1017 h/t @seanmars)
- updated CFB to 1.0.5
- demo HTML conversion `string`
This commit is contained in:
SheetJS 2018-03-05 19:34:04 -05:00
parent 5dd16ae640
commit 7149728c7c
36 changed files with 322 additions and 254 deletions

@ -4,6 +4,10 @@ This log is intended to keep track of backwards-incompatible changes, including
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.12.4 (2018-03-04)
* `JSZip` renamed to `JSZipSync`
## 0.12.0 (2018-02-08)
* Extendscript target script in NPM package

@ -192,7 +192,7 @@ tslint: $(TARGET) ## Run typescript checks
.PHONY: flow
flow: lint ## Run flow checker
@flow check --all --show-all-errors
@flow check --all --show-all-errors --include-warnings
.PHONY: cov
cov: misc/coverage.html ## Run coverage test

@ -1720,7 +1720,7 @@ expected number of rows or columns. Extracting the range is extremely simple:
```js
var range = XLSX.utils.decode_range(worksheet['!ref']);
var ncols = range.e.c - range.r.c + 1, nrows = range.e.r - range.s.r + 1;
var ncols = range.e.c - range.s.c + 1, nrows = range.e.r - range.s.r + 1;
```
</details>

@ -1 +1 @@
XLSX.version = '0.12.3';
XLSX.version = '0.12.4';

@ -6,12 +6,14 @@ var Base64 = (function make_b64(){
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
for(var i = 0; i < input.length; ) {
c1 = input.charCodeAt(i++);
e1 = (c1 >> 2);
c2 = input.charCodeAt(i++);
c3 = input.charCodeAt(i++);
e1 = c1 >> 2;
e2 = ((c1 & 3) << 4) | (c2 >> 4);
c3 = input.charCodeAt(i++);
e3 = ((c2 & 15) << 2) | (c3 >> 6);
e4 = c3 & 63;
e4 = (c3 & 63);
if (isNaN(c2)) { e3 = e4 = 64; }
else if (isNaN(c3)) { e4 = 64; }
o += map.charAt(e1) + map.charAt(e2) + map.charAt(e3) + map.charAt(e4);
@ -20,19 +22,20 @@ var Base64 = (function make_b64(){
},
decode: function b64_decode(input/*:string*/)/*:string*/ {
var o = "";
var c1=0, c2=0, c3=0;
var e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^\w\+\/\=]/g, "");
for(var i = 0; i < input.length;) {
e1 = map.indexOf(input.charAt(i++));
e2 = map.indexOf(input.charAt(i++));
e3 = map.indexOf(input.charAt(i++));
e4 = map.indexOf(input.charAt(i++));
c1 = (e1 << 2) | (e2 >> 4);
c2 = ((e2 & 15) << 4) | (e3 >> 2);
c3 = ((e3 & 3) << 6) | e4;
o += String.fromCharCode(c1);
e3 = map.indexOf(input.charAt(i++));
c2 = ((e2 & 15) << 4) | (e3 >> 2);
if (e3 !== 64) { o += String.fromCharCode(c2); }
e4 = map.indexOf(input.charAt(i++));
c3 = ((e3 & 3) << 6) | e4;
if (e4 !== 64) { o += String.fromCharCode(c3); }
}
return o;

@ -35,10 +35,10 @@ type SectorList = {
}
type CFBFiles = {[n:string]:CFBEntry};
*/
/* [MS-CFB] v20130118 */
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
exports.version = '1.0.3';
exports.version = '1.0.5';
/* [MS-CFB] 2.6.4 */
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
var L = l.split("/"), R = r.split("/");
@ -62,6 +62,7 @@ function filename(p/*:string*/)/*:string*/ {
var fs/*:: = require('fs'); */;
function get_fs() { return fs || (fs = require('fs')); }
function parse(file/*:RawBytes*/, options/*:CFBReadOpts*/)/*:CFBContainer*/ {
if(file.length < 512) throw new Error("CFB file size " + file.length + " < 512");
var mver = 3;
var ssz = 512;
var nmfs = 0; // number of mini FAT sectors
@ -218,7 +219,7 @@ function build_full_paths(FI/*:CFBFileIndex*/, FP/*:Array<string>*/, Paths/*:Arr
if(L !== -1) { dad[L] = dad[i]; q.push(L); }
if(R !== -1) { dad[R] = dad[i]; q.push(R); }
}
for(i=1; i !== pl; ++i) if(dad[i] === i) {
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
else if(L !== -1 && dad[L] !== L) dad[i] = dad[L];
}
@ -610,7 +611,6 @@ function _write(cfb/*:CFBContainer*/, options/*:CFBWriteOpts*/)/*:RawBytes*/ {
}
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
function find(cfb/*:CFBContainer*/, path/*:string*/)/*:?CFBEntry*/ {
//return cfb.find(path);
var UCFullPaths/*:Array<string>*/ = cfb.FullPaths.map(function(x) { return x.toUpperCase(); });
var UCPaths/*:Array<string>*/ = UCFullPaths.map(function(x) { var y = x.split("/"); return y[y.length - (x.slice(-1) == "/" ? 2 : 1)]; });
var k/*:boolean*/ = false;
@ -620,10 +620,12 @@ function find(cfb/*:CFBContainer*/, path/*:string*/)/*:?CFBEntry*/ {
var w/*:number*/ = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
if(w !== -1) return cfb.FileIndex[w];
UCPath = UCPath.replace(chr0,'').replace(chr1,'!');
var m = !UCPath.match(chr1);
UCPath = UCPath.replace(chr0,'');
if(m) UCPath = UCPath.replace(chr1,'!');
for(w = 0; w < UCFullPaths.length; ++w) {
if(UCFullPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if(UCPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if((m ? UCFullPaths[w].replace(chr1,'!') : UCFullPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
if((m ? UCPaths[w].replace(chr1,'!') : UCPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
}
return null;
}

@ -58,9 +58,9 @@ function zipentries(zip) {
}
var jszip;
/*:: declare var JSZip:any; */
/*global JSZip:true */
if(typeof JSZip !== 'undefined') jszip = JSZip;
/*:: declare var JSZipSync:any; */
/*global JSZipSync:true */
if(typeof JSZipSync !== 'undefined') jszip = JSZipSync;
if(typeof exports !== 'undefined') {
if(typeof module !== 'undefined' && module.exports) {
if(typeof jszip === 'undefined') jszip = require('./jszip.js');

@ -648,7 +648,6 @@ function parse_Rgce(blob, length, opts) {
R = PtgTypes[id];
if(id === 0x18 || id === 0x19) R = (id === 0x18 ? Ptg18 : Ptg19)[blob[blob.l + 1]];
if(!R || !R.f) { /*ptgs.push*/(parsenoop(blob, length)); }
// $FlowIgnore
else { ptgs.push([R.n, R.f(blob, length, opts)]); }
}
return ptgs;

@ -343,7 +343,6 @@ function parse_BrtBeginWsView(data/*::, length, opts*/) {
function write_BrtBeginWsView(ws, Workbook, o) {
if(o == null) o = new_buf(30);
var f = 0x39c;
// $FlowIgnore
if((((Workbook||{}).Views||[])[0]||{}).RTL) f |= 0x20;
o.write_shift(2, f); // bit flag
o.write_shift(4, 0);

@ -952,7 +952,6 @@ function write_ws_xlml_wsopts(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workb
/* LeftColumnVisible */
// $FlowIgnore
if(((((wb||{}).Workbook||{}).Views||[])[0]||{}).RTL) o.push("<DisplayRightToLeft/>");
/* GridlineColorIndex */

@ -19,7 +19,6 @@ var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
// $FlowIgnore
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);

@ -91,7 +91,7 @@ function readSync(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
case 0x3C: return parse_xlml(d, o);
case 0x49: if(n[1] === 0x44) return read_wb_ID(d, o); break;
case 0x54: if(n[1] === 0x41 && n[2] === 0x42 && n[3] === 0x4C) return DIF.to_workbook(d, o); break;
case 0x50: if(n[1] === 0x4B && n[2] < 0x20 && n[3] < 0x20) return read_zip(d, o); break;
case 0x50: return (n[1] === 0x4B && n[2] < 0x09 && n[3] < 0x09) ? read_zip(d, o) : read_prn(data, d, o, str);
case 0xEF: return n[3] === 0x3C ? parse_xlml(d, o) : read_prn(data, d, o, str);
case 0xFF: if(n[1] === 0xFE) { return read_utf16(d, o); } break;
case 0x00: if(n[1] === 0x00 && n[2] >= 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o); break;

@ -13,7 +13,6 @@ function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
}
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
var out = z.generate(oopts);
// $FlowIgnore
return o.type == "string" ? utf8read(out) : out;
}
@ -90,7 +89,6 @@ function writeSync(wb/*:Workbook*/, opts/*:?WriteOpts*/) {
case 'txt': return write_stxt_type(write_txt_str(wb, o), o);
case 'csv': return write_string_type(write_csv_str(wb, o), o, "\ufeff");
case 'dif': return write_string_type(write_dif_str(wb, o), o);
// $FlowIgnore
case 'dbf': return write_binary_type(write_dbf_buf(wb, o), o);
case 'prn': return write_string_type(write_prn_str(wb, o), o);
case 'rtf': return write_string_type(write_rtf_str(wb, o), o);

@ -62,7 +62,7 @@ var process_wb = (function() {
var to_html = function to_html(workbook) {
HTMLOUT.innerHTML = "";
workbook.SheetNames.forEach(function(sheetName) {
var htmlstr = X.write(workbook, {sheet:sheetName, type:'binary', bookType:'html'});
var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'});
HTMLOUT.innerHTML += htmlstr;
});
return "";

@ -55,7 +55,7 @@ var process_wb = (function() {
var to_html = function to_html(workbook) {
HTMLOUT.innerHTML = "";
workbook.SheetNames.forEach(function(sheetName) {
var htmlstr = X.write(workbook, {sheet:sheetName, type:'binary', bookType:'html'});
var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'});
HTMLOUT.innerHTML += htmlstr;
});
return "";

@ -54,7 +54,7 @@ var process_wb = (function() {
var to_html = function to_html(workbook) {
HTMLOUT.innerHTML = "";
workbook.SheetNames.forEach(function(sheetName) {
var htmlstr = X.write(workbook, {sheet:sheetName, type:'binary', bookType:'html'});
var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'});
HTMLOUT.innerHTML += htmlstr;
});
return "";

@ -55,7 +55,7 @@ var process_wb = (function() {
var to_html = function to_html(workbook) {
HTMLOUT.innerHTML = "";
workbook.SheetNames.forEach(function(sheetName) {
var htmlstr = X.write(workbook, {sheet:sheetName, type:'binary', bookType:'html'});
var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'});
HTMLOUT.innerHTML += htmlstr;
});
return "";

@ -55,7 +55,7 @@ var process_wb = (function() {
var to_html = function to_html(workbook) {
HTMLOUT.innerHTML = "";
workbook.SheetNames.forEach(function(sheetName) {
var htmlstr = X.write(workbook, {sheet:sheetName, type:'binary', bookType:'html'});
var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'});
HTMLOUT.innerHTML += htmlstr;
});
return "";
@ -92,33 +92,15 @@ var do_file = (function() {
var domrabs = document.getElementsByName("userabs")[0];
if(!rABS) domrabs.disabled = !(domrabs.checked = false);
var use_worker = typeof Worker !== 'undefined';
var domwork = document.getElementsByName("useworker")[0];
if(!use_worker) domwork.disabled = !(domwork.checked = false);
var xw = function xw(data, cb) {
var worker = new Worker(XW.worker);
worker.onmessage = function(e) {
switch(e.data.t) {
case 'ready': break;
case 'e': console.error(e.data.d); break;
case XW.msg: cb(JSON.parse(e.data.d)); break;
}
};
worker.postMessage({d:data,b:rABS?'binary':'array'});
};
return function do_file(files) {
rABS = domrabs.checked;
use_worker = domwork.checked;
var f = files[0];
var reader = new FileReader();
reader.onload = function(e) {
if(typeof console !== 'undefined') console.log("onload", new Date(), rABS, use_worker);
if(typeof console !== 'undefined') console.log("onload", new Date(), rABS);
var data = e.target.result;
if(!rABS) data = new Uint8Array(data);
if(use_worker) xw(data, process_wb);
else process_wb(X.read(data, {type: rABS ? 'binary' : 'array'}));
process_wb(X.read(data, {type: rABS ? 'binary' : 'array'}));
};
if(rABS) reader.readAsBinaryString(f);
else reader.readAsArrayBuffer(f);

@ -0,0 +1,78 @@
<!DOCTYPE html>
<!-- xlsx.js (C) 2013-present SheetJS http://sheetjs.com -->
<!-- vim: set ts=2: -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SheetJS Live Demo</title>
<style>
#drop{
border:2px dashed #bbb;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
padding:25px;
text-align:center;
font:20pt bold,"Vollkorn";color:#bbb
}
#b64data{
width:100%;
}
a { text-decoration: none }
</style>
</head>
<body>
<pre>
<b><a href="http://sheetjs.com">SheetJS Data Preview Live Demo</a></b>
(Base64 text works back to IE6; drag and drop works back to IE10)
<a href="https://github.com/SheetJS/js-xlsx">Source Code Repo</a>
<a href="https://github.com/SheetJS/js-xlsx/issues">Issues? Something look weird? Click here and report an issue</a>
Output Format: <select name="format" onchange="setfmt()">
<option value="csv" selected> CSV</option>
<option value="json"> JSON</option>
<option value="form"> FORMULAE</option>
<option value="html"> HTML</option>
</select><br />
<div id="drop">Drop a spreadsheet file here to see sheet data</div>
<input type="file" name="xlfile" id="xlf" /> ... or click here to select a file
<textarea id="b64data">... or paste a base64-encoding here</textarea>
<input type="button" id="dotext" value="Click here to process the base64 text" onclick="b64it();"/><br />
<b>Advanced Demo Options:</b>
Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked>
</pre>
<pre id="out"></pre>
<div id="htmlout"></div>
<br />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.20.16/system.js"></script>
<script>
SystemJS.config({
meta: {
'xlsx': {
exports: 'XLSX'
}
},
map: {
'xlsx': 'xlsx.full.min.js',
'fs': '',
'crypto': '',
'stream': ''
}
});
SystemJS.import('main.js');
</script>
<script type="text/javascript">
/* eslint no-use-before-define:0 */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

@ -54,7 +54,7 @@ var process_wb = (function() {
var to_html = function to_html(workbook) {
HTMLOUT.innerHTML = "";
workbook.SheetNames.forEach(function(sheetName) {
var htmlstr = X.write(workbook, {sheet:sheetName, type:'binary', bookType:'html'});
var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'});
HTMLOUT.innerHTML += htmlstr;
});
return "";

29
dist/jszip.js generated vendored

@ -8,16 +8,19 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js
JSZip uses the library pako released under the MIT license :
https://github.com/nodeca/pako/blob/master/LICENSE
Note: since JSZip 3 removed critical functionality, this version assigns to the
`JSZipSync` variable. Another JSZip version can be loaded in parallel.
*/
(function(e){
if("object"==typeof exports&&"undefined"!=typeof module&&"undefined"==typeof DO_NOT_EXPORT_JSZIP)module.exports=e();
else if("function"==typeof define&&define.amd){JSZip=e();define([],e);}
else if("function"==typeof define&&define.amd){JSZipSync=e();define([],e);}
else{
var f;
"undefined"!=typeof window?f=window:
"undefined"!=typeof global?f=global:
"undefined"!=typeof $ && $.global?f=$.global:
"undefined"!=typeof self&&(f=self),f.JSZip=e()
"undefined"!=typeof self&&(f=self),f.JSZipSync=e()
}
}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
@ -505,9 +508,9 @@ Usage:
* @param {String=|ArrayBuffer=|Uint8Array=} data the data to load, if any (optional).
* @param {Object=} options the options for creating this objects (optional).
*/
function JSZip(data, options) {
function JSZipSync(data, options) {
// if this constructor is used without `new`, it adds `new` before itself:
if(!(this instanceof JSZip)) return new JSZip(data, options);
if(!(this instanceof JSZipSync)) return new JSZipSync(data, options);
// object containing the files :
// {
@ -524,7 +527,7 @@ function JSZip(data, options) {
this.load(data, options);
}
this.clone = function() {
var newObj = new JSZip();
var newObj = new JSZipSync();
for (var i in this) {
if (typeof this[i] !== "function") {
newObj[i] = this[i];
@ -533,18 +536,18 @@ function JSZip(data, options) {
return newObj;
};
}
JSZip.prototype = _dereq_('./object');
JSZip.prototype.load = _dereq_('./load');
JSZip.support = _dereq_('./support');
JSZip.defaults = _dereq_('./defaults');
JSZipSync.prototype = _dereq_('./object');
JSZipSync.prototype.load = _dereq_('./load');
JSZipSync.support = _dereq_('./support');
JSZipSync.defaults = _dereq_('./defaults');
/**
* @deprecated
* This namespace will be removed in a future version without replacement.
*/
JSZip.utils = _dereq_('./deprecatedPublicUtils');
JSZipSync.utils = _dereq_('./deprecatedPublicUtils');
JSZip.base64 = {
JSZipSync.base64 = {
/**
* @deprecated
* This method will be removed in a future version without replacement.
@ -560,8 +563,8 @@ JSZip.base64 = {
return base64.decode(input);
}
};
JSZip.compressions = _dereq_('./compressions');
module.exports = JSZip;
JSZipSync.compressions = _dereq_('./compressions');
module.exports = JSZipSync;
},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(_dereq_,module,exports){
'use strict';

28
dist/xlsx.core.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.core.min.map generated vendored

File diff suppressed because one or more lines are too long

82
dist/xlsx.extendscript.js generated vendored

@ -154,16 +154,19 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js
JSZip uses the library pako released under the MIT license :
https://github.com/nodeca/pako/blob/master/LICENSE
Note: since JSZip 3 removed critical functionality, this version assigns to the
`JSZipSync` variable. Another JSZip version can be loaded in parallel.
*/
(function(e){
if("object"==typeof exports&&"undefined"!=typeof module&&"undefined"==typeof DO_NOT_EXPORT_JSZIP)module.exports=e();
else if("function"==typeof define&&define.amd){JSZip=e();define([],e);}
else if("function"==typeof define&&define.amd){JSZipSync=e();define([],e);}
else{
var f;
"undefined"!=typeof window?f=window:
"undefined"!=typeof global?f=global:
"undefined"!=typeof $ && $.global?f=$.global:
"undefined"!=typeof self&&(f=self),f.JSZip=e()
"undefined"!=typeof self&&(f=self),f.JSZipSync=e()
}
}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
@ -651,9 +654,9 @@ Usage:
* @param {String=|ArrayBuffer=|Uint8Array=} data the data to load, if any (optional).
* @param {Object=} options the options for creating this objects (optional).
*/
function JSZip(data, options) {
function JSZipSync(data, options) {
// if this constructor is used without `new`, it adds `new` before itself:
if(!(this instanceof JSZip)) return new JSZip(data, options);
if(!(this instanceof JSZipSync)) return new JSZipSync(data, options);
// object containing the files :
// {
@ -670,7 +673,7 @@ function JSZip(data, options) {
this.load(data, options);
}
this.clone = function() {
var newObj = new JSZip();
var newObj = new JSZipSync();
for (var i in this) {
if (typeof this[i] !== "function") {
newObj[i] = this[i];
@ -679,18 +682,18 @@ function JSZip(data, options) {
return newObj;
};
}
JSZip.prototype = _dereq_('./object');
JSZip.prototype.load = _dereq_('./load');
JSZip.support = _dereq_('./support');
JSZip.defaults = _dereq_('./defaults');
JSZipSync.prototype = _dereq_('./object');
JSZipSync.prototype.load = _dereq_('./load');
JSZipSync.support = _dereq_('./support');
JSZipSync.defaults = _dereq_('./defaults');
/**
* @deprecated
* This namespace will be removed in a future version without replacement.
*/
JSZip.utils = _dereq_('./deprecatedPublicUtils');
JSZipSync.utils = _dereq_('./deprecatedPublicUtils');
JSZip.base64 = {
JSZipSync.base64 = {
/**
* @deprecated
* This method will be removed in a future version without replacement.
@ -706,8 +709,8 @@ JSZip.base64 = {
return base64.decode(input);
}
};
JSZip.compressions = _dereq_('./compressions');
module.exports = JSZip;
JSZipSync.compressions = _dereq_('./compressions');
module.exports = JSZipSync;
},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(_dereq_,module,exports){
'use strict';
@ -9138,7 +9141,7 @@ module.exports = ZStream;
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.12.3';
XLSX.version = '0.12.4';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -9220,12 +9223,14 @@ var Base64 = (function make_b64(){
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
for(var i = 0; i < input.length; ) {
c1 = input.charCodeAt(i++);
e1 = (c1 >> 2);
c2 = input.charCodeAt(i++);
c3 = input.charCodeAt(i++);
e1 = c1 >> 2;
e2 = ((c1 & 3) << 4) | (c2 >> 4);
c3 = input.charCodeAt(i++);
e3 = ((c2 & 15) << 2) | (c3 >> 6);
e4 = c3 & 63;
e4 = (c3 & 63);
if (isNaN(c2)) { e3 = e4 = 64; }
else if (isNaN(c3)) { e4 = 64; }
o += map.charAt(e1) + map.charAt(e2) + map.charAt(e3) + map.charAt(e4);
@ -9234,19 +9239,20 @@ var Base64 = (function make_b64(){
},
decode: function b64_decode(input) {
var o = "";
var c1=0, c2=0, c3=0;
var e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^\w\+\/\=]/g, "");
for(var i = 0; i < input.length;) {
e1 = map.indexOf(input.charAt(i++));
e2 = map.indexOf(input.charAt(i++));
e3 = map.indexOf(input.charAt(i++));
e4 = map.indexOf(input.charAt(i++));
c1 = (e1 << 2) | (e2 >> 4);
c2 = ((e2 & 15) << 4) | (e3 >> 2);
c3 = ((e3 & 3) << 6) | e4;
o += String.fromCharCode(c1);
e3 = map.indexOf(input.charAt(i++));
c2 = ((e2 & 15) << 4) | (e3 >> 2);
if (e3 !== 64) { o += String.fromCharCode(c2); }
e4 = map.indexOf(input.charAt(i++));
c3 = ((e3 & 3) << 6) | e4;
if (e4 !== 64) { o += String.fromCharCode(c3); }
}
return o;
@ -10252,10 +10258,10 @@ var DO_NOT_EXPORT_CFB = true;
/*exported CFB */
/*global module, require:false, process:false, Buffer:false, Uint8Array:false */
/* [MS-CFB] v20130118 */
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.0.3';
exports.version = '1.0.5';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -10279,6 +10285,7 @@ function filename(p) {
var fs;
function get_fs() { return fs || (fs = require('fs')); }
function parse(file, options) {
if(file.length < 512) throw new Error("CFB file size " + file.length + " < 512");
var mver = 3;
var ssz = 512;
var nmfs = 0; // number of mini FAT sectors
@ -10435,7 +10442,7 @@ function build_full_paths(FI, FP, Paths) {
if(L !== -1) { dad[L] = dad[i]; q.push(L); }
if(R !== -1) { dad[R] = dad[i]; q.push(R); }
}
for(i=1; i !== pl; ++i) if(dad[i] === i) {
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
else if(L !== -1 && dad[L] !== L) dad[i] = dad[L];
}
@ -10822,7 +10829,6 @@ if(file.size > 0 && file.size < 0x1000) {
}
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
function find(cfb, path) {
//return cfb.find(path);
var UCFullPaths = cfb.FullPaths.map(function(x) { return x.toUpperCase(); });
var UCPaths = UCFullPaths.map(function(x) { var y = x.split("/"); return y[y.length - (x.slice(-1) == "/" ? 2 : 1)]; });
var k = false;
@ -10832,10 +10838,12 @@ function find(cfb, path) {
var w = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
if(w !== -1) return cfb.FileIndex[w];
UCPath = UCPath.replace(chr0,'').replace(chr1,'!');
var m = !UCPath.match(chr1);
UCPath = UCPath.replace(chr0,'');
if(m) UCPath = UCPath.replace(chr1,'!');
for(w = 0; w < UCFullPaths.length; ++w) {
if(UCFullPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if(UCPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if((m ? UCFullPaths[w].replace(chr1,'!') : UCFullPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
if((m ? UCPaths[w].replace(chr1,'!') : UCPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
}
return null;
}
@ -11215,8 +11223,8 @@ function zipentries(zip) {
}
var jszip;
/*global JSZip:true */
if(typeof JSZip !== 'undefined') jszip = JSZip;
/*global JSZipSync:true */
if(typeof JSZipSync !== 'undefined') jszip = JSZipSync;
if(typeof exports !== 'undefined') {
if(typeof module !== 'undefined' && module.exports) {
if(typeof jszip === 'undefined') jszip = undefined;
@ -19066,7 +19074,6 @@ function parse_Rgce(blob, length, opts) {
R = PtgTypes[id];
if(id === 0x18 || id === 0x19) R = (id === 0x18 ? Ptg18 : Ptg19)[blob[blob.l + 1]];
if(!R || !R.f) { /*ptgs.push*/(parsenoop(blob, length)); }
// $FlowIgnore
else { ptgs.push([R.n, R.f(blob, length, opts)]); }
}
return ptgs;
@ -21869,7 +21876,6 @@ function parse_BrtBeginWsView(data) {
function write_BrtBeginWsView(ws, Workbook, o) {
if(o == null) o = new_buf(30);
var f = 0x39c;
// $FlowIgnore
if((((Workbook||{}).Views||[])[0]||{}).RTL) f |= 0x20;
o.write_shift(2, f); // bit flag
o.write_shift(4, 0);
@ -24218,7 +24224,6 @@ function write_ws_xlml_wsopts(ws, opts, idx, wb) {
/* LeftColumnVisible */
// $FlowIgnore
if(((((wb||{}).Workbook||{}).Views||[])[0]||{}).RTL) o.push("<DisplayRightToLeft/>");
/* GridlineColorIndex */
@ -27864,7 +27869,6 @@ var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
// $FlowIgnore
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
@ -28348,7 +28352,7 @@ function readSync(data, opts) {
case 0x3C: return parse_xlml(d, o);
case 0x49: if(n[1] === 0x44) return read_wb_ID(d, o); break;
case 0x54: if(n[1] === 0x41 && n[2] === 0x42 && n[3] === 0x4C) return DIF.to_workbook(d, o); break;
case 0x50: if(n[1] === 0x4B && n[2] < 0x20 && n[3] < 0x20) return read_zip(d, o); break;
case 0x50: return (n[1] === 0x4B && n[2] < 0x09 && n[3] < 0x09) ? read_zip(d, o) : read_prn(data, d, o, str);
case 0xEF: return n[3] === 0x3C ? parse_xlml(d, o) : read_prn(data, d, o, str);
case 0xFF: if(n[1] === 0xFE) { return read_utf16(d, o); } break;
case 0x00: if(n[1] === 0x00 && n[2] >= 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o); break;
@ -28379,7 +28383,6 @@ function write_zip_type(wb, opts) {
}
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
var out = z.generate(oopts);
// $FlowIgnore
return o.type == "string" ? utf8read(out) : out;
}
@ -28456,7 +28459,6 @@ function writeSync(wb, opts) {
case 'txt': return write_stxt_type(write_txt_str(wb, o), o);
case 'csv': return write_string_type(write_csv_str(wb, o), o, "\ufeff");
case 'dif': return write_string_type(write_dif_str(wb, o), o);
// $FlowIgnore
case 'dbf': return write_binary_type(write_dbf_buf(wb, o), o);
case 'prn': return write_string_type(write_prn_str(wb, o), o);
case 'rtf': return write_string_type(write_rtf_str(wb, o), o);

32
dist/xlsx.full.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.full.min.map generated vendored

File diff suppressed because one or more lines are too long

53
dist/xlsx.js generated vendored

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.12.3';
XLSX.version = '0.12.4';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -86,12 +86,14 @@ var Base64 = (function make_b64(){
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
for(var i = 0; i < input.length; ) {
c1 = input.charCodeAt(i++);
e1 = (c1 >> 2);
c2 = input.charCodeAt(i++);
c3 = input.charCodeAt(i++);
e1 = c1 >> 2;
e2 = ((c1 & 3) << 4) | (c2 >> 4);
c3 = input.charCodeAt(i++);
e3 = ((c2 & 15) << 2) | (c3 >> 6);
e4 = c3 & 63;
e4 = (c3 & 63);
if (isNaN(c2)) { e3 = e4 = 64; }
else if (isNaN(c3)) { e4 = 64; }
o += map.charAt(e1) + map.charAt(e2) + map.charAt(e3) + map.charAt(e4);
@ -100,19 +102,20 @@ var Base64 = (function make_b64(){
},
decode: function b64_decode(input) {
var o = "";
var c1=0, c2=0, c3=0;
var e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^\w\+\/\=]/g, "");
for(var i = 0; i < input.length;) {
e1 = map.indexOf(input.charAt(i++));
e2 = map.indexOf(input.charAt(i++));
e3 = map.indexOf(input.charAt(i++));
e4 = map.indexOf(input.charAt(i++));
c1 = (e1 << 2) | (e2 >> 4);
c2 = ((e2 & 15) << 4) | (e3 >> 2);
c3 = ((e3 & 3) << 6) | e4;
o += String.fromCharCode(c1);
e3 = map.indexOf(input.charAt(i++));
c2 = ((e2 & 15) << 4) | (e3 >> 2);
if (e3 !== 64) { o += String.fromCharCode(c2); }
e4 = map.indexOf(input.charAt(i++));
c3 = ((e3 & 3) << 6) | e4;
if (e4 !== 64) { o += String.fromCharCode(c3); }
}
return o;
@ -1118,10 +1121,10 @@ var DO_NOT_EXPORT_CFB = true;
/*exported CFB */
/*global module, require:false, process:false, Buffer:false, Uint8Array:false */
/* [MS-CFB] v20130118 */
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.0.3';
exports.version = '1.0.5';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -1145,6 +1148,7 @@ function filename(p) {
var fs;
function get_fs() { return fs || (fs = require('fs')); }
function parse(file, options) {
if(file.length < 512) throw new Error("CFB file size " + file.length + " < 512");
var mver = 3;
var ssz = 512;
var nmfs = 0; // number of mini FAT sectors
@ -1301,7 +1305,7 @@ function build_full_paths(FI, FP, Paths) {
if(L !== -1) { dad[L] = dad[i]; q.push(L); }
if(R !== -1) { dad[R] = dad[i]; q.push(R); }
}
for(i=1; i !== pl; ++i) if(dad[i] === i) {
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
else if(L !== -1 && dad[L] !== L) dad[i] = dad[L];
}
@ -1688,7 +1692,6 @@ if(file.size > 0 && file.size < 0x1000) {
}
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
function find(cfb, path) {
//return cfb.find(path);
var UCFullPaths = cfb.FullPaths.map(function(x) { return x.toUpperCase(); });
var UCPaths = UCFullPaths.map(function(x) { var y = x.split("/"); return y[y.length - (x.slice(-1) == "/" ? 2 : 1)]; });
var k = false;
@ -1698,10 +1701,12 @@ function find(cfb, path) {
var w = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
if(w !== -1) return cfb.FileIndex[w];
UCPath = UCPath.replace(chr0,'').replace(chr1,'!');
var m = !UCPath.match(chr1);
UCPath = UCPath.replace(chr0,'');
if(m) UCPath = UCPath.replace(chr1,'!');
for(w = 0; w < UCFullPaths.length; ++w) {
if(UCFullPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if(UCPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if((m ? UCFullPaths[w].replace(chr1,'!') : UCFullPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
if((m ? UCPaths[w].replace(chr1,'!') : UCPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
}
return null;
}
@ -2081,8 +2086,8 @@ function zipentries(zip) {
}
var jszip;
/*global JSZip:true */
if(typeof JSZip !== 'undefined') jszip = JSZip;
/*global JSZipSync:true */
if(typeof JSZipSync !== 'undefined') jszip = JSZipSync;
if(typeof exports !== 'undefined') {
if(typeof module !== 'undefined' && module.exports) {
if(typeof jszip === 'undefined') jszip = undefined;
@ -9932,7 +9937,6 @@ function parse_Rgce(blob, length, opts) {
R = PtgTypes[id];
if(id === 0x18 || id === 0x19) R = (id === 0x18 ? Ptg18 : Ptg19)[blob[blob.l + 1]];
if(!R || !R.f) { /*ptgs.push*/(parsenoop(blob, length)); }
// $FlowIgnore
else { ptgs.push([R.n, R.f(blob, length, opts)]); }
}
return ptgs;
@ -12735,7 +12739,6 @@ function parse_BrtBeginWsView(data) {
function write_BrtBeginWsView(ws, Workbook, o) {
if(o == null) o = new_buf(30);
var f = 0x39c;
// $FlowIgnore
if((((Workbook||{}).Views||[])[0]||{}).RTL) f |= 0x20;
o.write_shift(2, f); // bit flag
o.write_shift(4, 0);
@ -15084,7 +15087,6 @@ function write_ws_xlml_wsopts(ws, opts, idx, wb) {
/* LeftColumnVisible */
// $FlowIgnore
if(((((wb||{}).Workbook||{}).Views||[])[0]||{}).RTL) o.push("<DisplayRightToLeft/>");
/* GridlineColorIndex */
@ -18730,7 +18732,6 @@ var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
// $FlowIgnore
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
@ -19214,7 +19215,7 @@ function readSync(data, opts) {
case 0x3C: return parse_xlml(d, o);
case 0x49: if(n[1] === 0x44) return read_wb_ID(d, o); break;
case 0x54: if(n[1] === 0x41 && n[2] === 0x42 && n[3] === 0x4C) return DIF.to_workbook(d, o); break;
case 0x50: if(n[1] === 0x4B && n[2] < 0x20 && n[3] < 0x20) return read_zip(d, o); break;
case 0x50: return (n[1] === 0x4B && n[2] < 0x09 && n[3] < 0x09) ? read_zip(d, o) : read_prn(data, d, o, str);
case 0xEF: return n[3] === 0x3C ? parse_xlml(d, o) : read_prn(data, d, o, str);
case 0xFF: if(n[1] === 0xFE) { return read_utf16(d, o); } break;
case 0x00: if(n[1] === 0x00 && n[2] >= 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o); break;
@ -19245,7 +19246,6 @@ function write_zip_type(wb, opts) {
}
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
var out = z.generate(oopts);
// $FlowIgnore
return o.type == "string" ? utf8read(out) : out;
}
@ -19322,7 +19322,6 @@ function writeSync(wb, opts) {
case 'txt': return write_stxt_type(write_txt_str(wb, o), o);
case 'csv': return write_string_type(write_csv_str(wb, o), o, "\ufeff");
case 'dif': return write_string_type(write_dif_str(wb, o), o);
// $FlowIgnore
case 'dbf': return write_binary_type(write_dbf_buf(wb, o), o);
case 'prn': return write_string_type(write_prn_str(wb, o), o);
case 'rtf': return write_string_type(write_rtf_str(wb, o), o);

24
dist/xlsx.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.min.map generated vendored

File diff suppressed because one or more lines are too long

@ -123,7 +123,7 @@ expected number of rows or columns. Extracting the range is extremely simple:
```js
var range = XLSX.utils.decode_range(worksheet['!ref']);
var ncols = range.e.c - range.r.c + 1, nrows = range.e.r - range.s.r + 1;
var ncols = range.e.c - range.s.c + 1, nrows = range.e.r - range.s.r + 1;
```
</details>

@ -117,7 +117,7 @@ var process_wb = (function() {
var to_html = function to_html(workbook) {
HTMLOUT.innerHTML = "";
workbook.SheetNames.forEach(function(sheetName) {
var htmlstr = X.write(workbook, {sheet:sheetName, type:'binary', bookType:'html'});
var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'});
HTMLOUT.innerHTML += htmlstr;
});
return "";

@ -8,16 +8,19 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js
JSZip uses the library pako released under the MIT license :
https://github.com/nodeca/pako/blob/master/LICENSE
Note: since JSZip 3 removed critical functionality, this version assigns to the
`JSZipSync` variable. Another JSZip version can be loaded in parallel.
*/
(function(e){
if("object"==typeof exports&&"undefined"!=typeof module&&"undefined"==typeof DO_NOT_EXPORT_JSZIP)module.exports=e();
else if("function"==typeof define&&define.amd){JSZip=e();define([],e);}
else if("function"==typeof define&&define.amd){JSZipSync=e();define([],e);}
else{
var f;
"undefined"!=typeof window?f=window:
"undefined"!=typeof global?f=global:
"undefined"!=typeof $ && $.global?f=$.global:
"undefined"!=typeof self&&(f=self),f.JSZip=e()
"undefined"!=typeof self&&(f=self),f.JSZipSync=e()
}
}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
@ -505,9 +508,9 @@ Usage:
* @param {String=|ArrayBuffer=|Uint8Array=} data the data to load, if any (optional).
* @param {Object=} options the options for creating this objects (optional).
*/
function JSZip(data, options) {
function JSZipSync(data, options) {
// if this constructor is used without `new`, it adds `new` before itself:
if(!(this instanceof JSZip)) return new JSZip(data, options);
if(!(this instanceof JSZipSync)) return new JSZipSync(data, options);
// object containing the files :
// {
@ -524,7 +527,7 @@ function JSZip(data, options) {
this.load(data, options);
}
this.clone = function() {
var newObj = new JSZip();
var newObj = new JSZipSync();
for (var i in this) {
if (typeof this[i] !== "function") {
newObj[i] = this[i];
@ -533,18 +536,18 @@ function JSZip(data, options) {
return newObj;
};
}
JSZip.prototype = _dereq_('./object');
JSZip.prototype.load = _dereq_('./load');
JSZip.support = _dereq_('./support');
JSZip.defaults = _dereq_('./defaults');
JSZipSync.prototype = _dereq_('./object');
JSZipSync.prototype.load = _dereq_('./load');
JSZipSync.support = _dereq_('./support');
JSZipSync.defaults = _dereq_('./defaults');
/**
* @deprecated
* This namespace will be removed in a future version without replacement.
*/
JSZip.utils = _dereq_('./deprecatedPublicUtils');
JSZipSync.utils = _dereq_('./deprecatedPublicUtils');
JSZip.base64 = {
JSZipSync.base64 = {
/**
* @deprecated
* This method will be removed in a future version without replacement.
@ -560,8 +563,8 @@ JSZip.base64 = {
return base64.decode(input);
}
};
JSZip.compressions = _dereq_('./compressions');
module.exports = JSZip;
JSZipSync.compressions = _dereq_('./compressions');
module.exports = JSZipSync;
},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(_dereq_,module,exports){
'use strict';

@ -1577,7 +1577,7 @@ expected number of rows or columns. Extracting the range is extremely simple:
```js
var range = XLSX.utils.decode_range(worksheet['!ref']);
var ncols = range.e.c - range.r.c + 1, nrows = range.e.r - range.s.r + 1;
var ncols = range.e.c - range.s.c + 1, nrows = range.e.r - range.s.r + 1;
```

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.12.3",
"version": "0.12.4",
"author": "sheetjs",
"description": "SheetJS Spreadsheet data parser and writer",
"keywords": [
@ -31,7 +31,7 @@
},
"dependencies": {
"adler-32": "~1.2.0",
"cfb": "~1.0.4",
"cfb": "~1.0.5",
"codepage": "~1.12.1",
"commander": "~2.14.1",
"crc-32": "~1.2.0",

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.12.3';
XLSX.version = '0.12.4';
var current_codepage = 1200, current_ansi = 1252;
/*:: declare var cptable:any; */
/*global cptable:true */
@ -87,12 +87,14 @@ var Base64 = (function make_b64(){
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
for(var i = 0; i < input.length; ) {
c1 = input.charCodeAt(i++);
e1 = (c1 >> 2);
c2 = input.charCodeAt(i++);
c3 = input.charCodeAt(i++);
e1 = c1 >> 2;
e2 = ((c1 & 3) << 4) | (c2 >> 4);
c3 = input.charCodeAt(i++);
e3 = ((c2 & 15) << 2) | (c3 >> 6);
e4 = c3 & 63;
e4 = (c3 & 63);
if (isNaN(c2)) { e3 = e4 = 64; }
else if (isNaN(c3)) { e4 = 64; }
o += map.charAt(e1) + map.charAt(e2) + map.charAt(e3) + map.charAt(e4);
@ -101,19 +103,20 @@ var Base64 = (function make_b64(){
},
decode: function b64_decode(input/*:string*/)/*:string*/ {
var o = "";
var c1=0, c2=0, c3=0;
var e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^\w\+\/\=]/g, "");
for(var i = 0; i < input.length;) {
e1 = map.indexOf(input.charAt(i++));
e2 = map.indexOf(input.charAt(i++));
e3 = map.indexOf(input.charAt(i++));
e4 = map.indexOf(input.charAt(i++));
c1 = (e1 << 2) | (e2 >> 4);
c2 = ((e2 & 15) << 4) | (e3 >> 2);
c3 = ((e3 & 3) << 6) | e4;
o += String.fromCharCode(c1);
e3 = map.indexOf(input.charAt(i++));
c2 = ((e2 & 15) << 4) | (e3 >> 2);
if (e3 !== 64) { o += String.fromCharCode(c2); }
e4 = map.indexOf(input.charAt(i++));
c3 = ((e3 & 3) << 6) | e4;
if (e4 !== 64) { o += String.fromCharCode(c3); }
}
return o;
@ -1182,10 +1185,10 @@ type SectorList = {
}
type CFBFiles = {[n:string]:CFBEntry};
*/
/* [MS-CFB] v20130118 */
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
exports.version = '1.0.3';
exports.version = '1.0.5';
/* [MS-CFB] 2.6.4 */
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
var L = l.split("/"), R = r.split("/");
@ -1209,6 +1212,7 @@ function filename(p/*:string*/)/*:string*/ {
var fs/*:: = require('fs'); */;
function get_fs() { return fs || (fs = require('fs')); }
function parse(file/*:RawBytes*/, options/*:CFBReadOpts*/)/*:CFBContainer*/ {
if(file.length < 512) throw new Error("CFB file size " + file.length + " < 512");
var mver = 3;
var ssz = 512;
var nmfs = 0; // number of mini FAT sectors
@ -1365,7 +1369,7 @@ function build_full_paths(FI/*:CFBFileIndex*/, FP/*:Array<string>*/, Paths/*:Arr
if(L !== -1) { dad[L] = dad[i]; q.push(L); }
if(R !== -1) { dad[R] = dad[i]; q.push(R); }
}
for(i=1; i !== pl; ++i) if(dad[i] === i) {
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
else if(L !== -1 && dad[L] !== L) dad[i] = dad[L];
}
@ -1757,7 +1761,6 @@ function _write(cfb/*:CFBContainer*/, options/*:CFBWriteOpts*/)/*:RawBytes*/ {
}
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
function find(cfb/*:CFBContainer*/, path/*:string*/)/*:?CFBEntry*/ {
//return cfb.find(path);
var UCFullPaths/*:Array<string>*/ = cfb.FullPaths.map(function(x) { return x.toUpperCase(); });
var UCPaths/*:Array<string>*/ = UCFullPaths.map(function(x) { var y = x.split("/"); return y[y.length - (x.slice(-1) == "/" ? 2 : 1)]; });
var k/*:boolean*/ = false;
@ -1767,10 +1770,12 @@ function find(cfb/*:CFBContainer*/, path/*:string*/)/*:?CFBEntry*/ {
var w/*:number*/ = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
if(w !== -1) return cfb.FileIndex[w];
UCPath = UCPath.replace(chr0,'').replace(chr1,'!');
var m = !UCPath.match(chr1);
UCPath = UCPath.replace(chr0,'');
if(m) UCPath = UCPath.replace(chr1,'!');
for(w = 0; w < UCFullPaths.length; ++w) {
if(UCFullPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if(UCPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if((m ? UCFullPaths[w].replace(chr1,'!') : UCFullPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
if((m ? UCPaths[w].replace(chr1,'!') : UCPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
}
return null;
}
@ -2157,9 +2162,9 @@ function zipentries(zip) {
}
var jszip;
/*:: declare var JSZip:any; */
/*global JSZip:true */
if(typeof JSZip !== 'undefined') jszip = JSZip;
/*:: declare var JSZipSync:any; */
/*global JSZipSync:true */
if(typeof JSZipSync !== 'undefined') jszip = JSZipSync;
if(typeof exports !== 'undefined') {
if(typeof module !== 'undefined' && module.exports) {
if(typeof jszip === 'undefined') jszip = require('./jszip.js');
@ -10026,7 +10031,6 @@ function parse_Rgce(blob, length, opts) {
R = PtgTypes[id];
if(id === 0x18 || id === 0x19) R = (id === 0x18 ? Ptg18 : Ptg19)[blob[blob.l + 1]];
if(!R || !R.f) { /*ptgs.push*/(parsenoop(blob, length)); }
// $FlowIgnore
else { ptgs.push([R.n, R.f(blob, length, opts)]); }
}
return ptgs;
@ -12830,7 +12834,6 @@ function parse_BrtBeginWsView(data/*::, length, opts*/) {
function write_BrtBeginWsView(ws, Workbook, o) {
if(o == null) o = new_buf(30);
var f = 0x39c;
// $FlowIgnore
if((((Workbook||{}).Views||[])[0]||{}).RTL) f |= 0x20;
o.write_shift(2, f); // bit flag
o.write_shift(4, 0);
@ -15189,7 +15192,6 @@ function write_ws_xlml_wsopts(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workb
/* LeftColumnVisible */
// $FlowIgnore
if(((((wb||{}).Workbook||{}).Views||[])[0]||{}).RTL) o.push("<DisplayRightToLeft/>");
/* GridlineColorIndex */
@ -18841,7 +18843,6 @@ var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
// $FlowIgnore
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
@ -19330,7 +19331,7 @@ function readSync(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
case 0x3C: return parse_xlml(d, o);
case 0x49: if(n[1] === 0x44) return read_wb_ID(d, o); break;
case 0x54: if(n[1] === 0x41 && n[2] === 0x42 && n[3] === 0x4C) return DIF.to_workbook(d, o); break;
case 0x50: if(n[1] === 0x4B && n[2] < 0x20 && n[3] < 0x20) return read_zip(d, o); break;
case 0x50: return (n[1] === 0x4B && n[2] < 0x09 && n[3] < 0x09) ? read_zip(d, o) : read_prn(data, d, o, str);
case 0xEF: return n[3] === 0x3C ? parse_xlml(d, o) : read_prn(data, d, o, str);
case 0xFF: if(n[1] === 0xFE) { return read_utf16(d, o); } break;
case 0x00: if(n[1] === 0x00 && n[2] >= 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o); break;
@ -19361,7 +19362,6 @@ function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
}
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
var out = z.generate(oopts);
// $FlowIgnore
return o.type == "string" ? utf8read(out) : out;
}
@ -19438,7 +19438,6 @@ function writeSync(wb/*:Workbook*/, opts/*:?WriteOpts*/) {
case 'txt': return write_stxt_type(write_txt_str(wb, o), o);
case 'csv': return write_string_type(write_csv_str(wb, o), o, "\ufeff");
case 'dif': return write_string_type(write_dif_str(wb, o), o);
// $FlowIgnore
case 'dbf': return write_binary_type(write_dbf_buf(wb, o), o);
case 'prn': return write_string_type(write_prn_str(wb, o), o);
case 'rtf': return write_string_type(write_rtf_str(wb, o), o);

53
xlsx.js generated

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.12.3';
XLSX.version = '0.12.4';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -86,12 +86,14 @@ var Base64 = (function make_b64(){
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
for(var i = 0; i < input.length; ) {
c1 = input.charCodeAt(i++);
e1 = (c1 >> 2);
c2 = input.charCodeAt(i++);
c3 = input.charCodeAt(i++);
e1 = c1 >> 2;
e2 = ((c1 & 3) << 4) | (c2 >> 4);
c3 = input.charCodeAt(i++);
e3 = ((c2 & 15) << 2) | (c3 >> 6);
e4 = c3 & 63;
e4 = (c3 & 63);
if (isNaN(c2)) { e3 = e4 = 64; }
else if (isNaN(c3)) { e4 = 64; }
o += map.charAt(e1) + map.charAt(e2) + map.charAt(e3) + map.charAt(e4);
@ -100,19 +102,20 @@ var Base64 = (function make_b64(){
},
decode: function b64_decode(input) {
var o = "";
var c1=0, c2=0, c3=0;
var e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0;
input = input.replace(/[^\w\+\/\=]/g, "");
for(var i = 0; i < input.length;) {
e1 = map.indexOf(input.charAt(i++));
e2 = map.indexOf(input.charAt(i++));
e3 = map.indexOf(input.charAt(i++));
e4 = map.indexOf(input.charAt(i++));
c1 = (e1 << 2) | (e2 >> 4);
c2 = ((e2 & 15) << 4) | (e3 >> 2);
c3 = ((e3 & 3) << 6) | e4;
o += String.fromCharCode(c1);
e3 = map.indexOf(input.charAt(i++));
c2 = ((e2 & 15) << 4) | (e3 >> 2);
if (e3 !== 64) { o += String.fromCharCode(c2); }
e4 = map.indexOf(input.charAt(i++));
c3 = ((e3 & 3) << 6) | e4;
if (e4 !== 64) { o += String.fromCharCode(c3); }
}
return o;
@ -1118,10 +1121,10 @@ var DO_NOT_EXPORT_CFB = true;
/*exported CFB */
/*global module, require:false, process:false, Buffer:false, Uint8Array:false */
/* [MS-CFB] v20130118 */
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.0.3';
exports.version = '1.0.5';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -1145,6 +1148,7 @@ function filename(p) {
var fs;
function get_fs() { return fs || (fs = require('fs')); }
function parse(file, options) {
if(file.length < 512) throw new Error("CFB file size " + file.length + " < 512");
var mver = 3;
var ssz = 512;
var nmfs = 0; // number of mini FAT sectors
@ -1301,7 +1305,7 @@ function build_full_paths(FI, FP, Paths) {
if(L !== -1) { dad[L] = dad[i]; q.push(L); }
if(R !== -1) { dad[R] = dad[i]; q.push(R); }
}
for(i=1; i !== pl; ++i) if(dad[i] === i) {
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
else if(L !== -1 && dad[L] !== L) dad[i] = dad[L];
}
@ -1688,7 +1692,6 @@ if(file.size > 0 && file.size < 0x1000) {
}
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
function find(cfb, path) {
//return cfb.find(path);
var UCFullPaths = cfb.FullPaths.map(function(x) { return x.toUpperCase(); });
var UCPaths = UCFullPaths.map(function(x) { var y = x.split("/"); return y[y.length - (x.slice(-1) == "/" ? 2 : 1)]; });
var k = false;
@ -1698,10 +1701,12 @@ function find(cfb, path) {
var w = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
if(w !== -1) return cfb.FileIndex[w];
UCPath = UCPath.replace(chr0,'').replace(chr1,'!');
var m = !UCPath.match(chr1);
UCPath = UCPath.replace(chr0,'');
if(m) UCPath = UCPath.replace(chr1,'!');
for(w = 0; w < UCFullPaths.length; ++w) {
if(UCFullPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if(UCPaths[w].replace(chr0,'').replace(chr1,'!') == UCPath) return cfb.FileIndex[w];
if((m ? UCFullPaths[w].replace(chr1,'!') : UCFullPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
if((m ? UCPaths[w].replace(chr1,'!') : UCPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
}
return null;
}
@ -2081,8 +2086,8 @@ function zipentries(zip) {
}
var jszip;
/*global JSZip:true */
if(typeof JSZip !== 'undefined') jszip = JSZip;
/*global JSZipSync:true */
if(typeof JSZipSync !== 'undefined') jszip = JSZipSync;
if(typeof exports !== 'undefined') {
if(typeof module !== 'undefined' && module.exports) {
if(typeof jszip === 'undefined') jszip = require('./jszip.js');
@ -9932,7 +9937,6 @@ function parse_Rgce(blob, length, opts) {
R = PtgTypes[id];
if(id === 0x18 || id === 0x19) R = (id === 0x18 ? Ptg18 : Ptg19)[blob[blob.l + 1]];
if(!R || !R.f) { /*ptgs.push*/(parsenoop(blob, length)); }
// $FlowIgnore
else { ptgs.push([R.n, R.f(blob, length, opts)]); }
}
return ptgs;
@ -12735,7 +12739,6 @@ function parse_BrtBeginWsView(data) {
function write_BrtBeginWsView(ws, Workbook, o) {
if(o == null) o = new_buf(30);
var f = 0x39c;
// $FlowIgnore
if((((Workbook||{}).Views||[])[0]||{}).RTL) f |= 0x20;
o.write_shift(2, f); // bit flag
o.write_shift(4, 0);
@ -15084,7 +15087,6 @@ function write_ws_xlml_wsopts(ws, opts, idx, wb) {
/* LeftColumnVisible */
// $FlowIgnore
if(((((wb||{}).Workbook||{}).Views||[])[0]||{}).RTL) o.push("<DisplayRightToLeft/>");
/* GridlineColorIndex */
@ -18730,7 +18732,6 @@ var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
// $FlowIgnore
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
@ -19214,7 +19215,7 @@ function readSync(data, opts) {
case 0x3C: return parse_xlml(d, o);
case 0x49: if(n[1] === 0x44) return read_wb_ID(d, o); break;
case 0x54: if(n[1] === 0x41 && n[2] === 0x42 && n[3] === 0x4C) return DIF.to_workbook(d, o); break;
case 0x50: if(n[1] === 0x4B && n[2] < 0x20 && n[3] < 0x20) return read_zip(d, o); break;
case 0x50: return (n[1] === 0x4B && n[2] < 0x09 && n[3] < 0x09) ? read_zip(d, o) : read_prn(data, d, o, str);
case 0xEF: return n[3] === 0x3C ? parse_xlml(d, o) : read_prn(data, d, o, str);
case 0xFF: if(n[1] === 0xFE) { return read_utf16(d, o); } break;
case 0x00: if(n[1] === 0x00 && n[2] >= 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o); break;
@ -19245,7 +19246,6 @@ function write_zip_type(wb, opts) {
}
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
var out = z.generate(oopts);
// $FlowIgnore
return o.type == "string" ? utf8read(out) : out;
}
@ -19322,7 +19322,6 @@ function writeSync(wb, opts) {
case 'txt': return write_stxt_type(write_txt_str(wb, o), o);
case 'csv': return write_string_type(write_csv_str(wb, o), o, "\ufeff");
case 'dif': return write_string_type(write_dif_str(wb, o), o);
// $FlowIgnore
case 'dbf': return write_binary_type(write_dbf_buf(wb, o), o);
case 'prn': return write_string_type(write_prn_str(wb, o), o);
case 'rtf': return write_string_type(write_rtf_str(wb, o), o);