version bump 0.13.0: AMD support

- library reshaped to support requirejs / amd without shim
- control comment visibility (fixes #998, h/t @cmuruganmsc)
- fixed README code sample error (fixes #1118 h/t @iahmedani)
This commit is contained in:
SheetJS 2018-06-01 12:32:08 -04:00
parent 2918185249
commit 64798fd1f9
29 changed files with 269 additions and 156 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.13.0 (2018-06-01)
* Library reshaped to support AMD out of the box
## 0.12.11 (2018-04-27)
* XLS/XLSX/XLSB range truncation (errors in `WTF` mode)

@ -364,11 +364,11 @@ Multiple tables on a web page can be converted to individual worksheets:
var workbook = XLSX.utils.book_new();
/* convert table 'table1' to worksheet named "Sheet1" */
var ws1 = XLSX.utils.table_to_book(document.getElementById('table1'));
var ws1 = XLSX.utils.table_to_sheet(document.getElementById('table1'));
XLSX.utils.book_append_sheet(workbook, ws1, "Sheet1");
/* convert table 'table2' to worksheet named "Sheet2" */
var ws2 = XLSX.utils.table_to_book(document.getElementById('table2'));
var ws2 = XLSX.utils.table_to_sheet(document.getElementById('table2'));
XLSX.utils.book_append_sheet(workbook, ws2, "Sheet2");
/* workbook now has 2 worksheets */
@ -1555,6 +1555,17 @@ ws.A1.c.push({a:"SheetJS", t:"I'm a little comment, short and stout!"});
Note: XLSB enforces a 54 character limit on the Author name. Names longer than
54 characters may cause issues with other formats.
To mark a comment as normally hidden, set the `hidden` property:
```js
if(!ws.A1.c) ws.A1.c = [];
ws.A1.c.push({a:"SheetJS", t:"This comment is visible"});
if(!ws.A2.c) ws.A2.c = [];
ws.A2.c.hidden = true;
ws.A2.c.push({a:"SheetJS", t:"This comment will be hidden"});
```
#### Sheet Visibility
Excel enables hiding sheets in the lower tab bar. The sheet data is stored in

@ -1,6 +1,6 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported XLSX */
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
function make_xlsx_lib(XLSX){

@ -1 +1 @@
XLSX.version = '0.12.13';
XLSX.version = '0.13.0';

@ -1,6 +1,6 @@
/* L.5.5.2 SpreadsheetML Comments + VML Schema */
var _shapeid = 1024;
function write_comments_vml(rId, comments) {
function write_comments_vml(rId/*:number*/, comments) {
var csize = [21600, 21600];
/* L.5.2.1.2 Path Attribute */
var bbox = ["m0,0l0",csize[1],csize[0],csize[1],csize[0],"0xe"].join(",");
@ -19,7 +19,7 @@ function write_comments_vml(rId, comments) {
'<v:shape' + wxt_helper({
id:'_x0000_s' + (++_shapeid),
type:"#_x0000_t202",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10;visibility:hidden",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10" + (x[1].hidden ? ";visibility:hidden" : "") ,
fillcolor:"#ECFAD4",
strokecolor:"#edeaa1"
}) + '>',
@ -35,7 +35,7 @@ function write_comments_vml(rId, comments) {
writetag('x:AutoFill', "False"),
writetag('x:Row', String(c.r)),
writetag('x:Column', String(c.c)),
'<x:Visible/>',
x[1].hidden ? '' : '<x:Visible/>',
'</x:ClientData>',
'</v:shape>'
]); });

@ -1,3 +1,9 @@
})(typeof exports !== 'undefined' ? exports : XLSX);
}
/*global define */
/*:: declare var define:any; */
if(typeof exports !== 'undefined') make_xlsx_lib(exports);
else if(typeof module !== 'undefined' && module.exports) make_xlsx_lib(module.exports);
else if(typeof define === 'function' && define.amd) define('xlsx', function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
else make_xlsx_lib(XLSX);
/*exported XLS, ODS */
var XLS = XLSX, ODS = XLSX;

@ -1,16 +1,7 @@
# RequireJS
The minified dist files trip up the RequireJS mechanism. To bypass, the scripts
automatically expose an `XLSX` variable that can be used if the require callback
argument is `_XLSX` rather than `XLSX`. This trick is employed in the included
`xlsx-shim.js` script:
```js
/* xlsx-shim.js */
define(['xlsx'], function (_XLSX) {
return XLSX;
});
```
The module complies with the AMD `define` semantics, enabling use in RequireJS
out of the box.
The require config should set `xlsx` path to the appropriate dist file:
@ -20,10 +11,10 @@ The require config should set `xlsx` path to the appropriate dist file:
},
```
Once that is set, app code can freely require `"xlsx-shim"`:
Once that is set, app code can freely require `"xlsx"`:
```js
require(["xlsx-shim"], function(XLSX) {
require(["xlsx"], function(XLSX) {
/* use XLSX here */
});
```
@ -69,7 +60,7 @@ node r.js -o build.js paths.requireLib=./require include=requireLib
That step creates a file `app-built.js` that can be included in a page:
```html
<!-- final bundle includes require.js, xlsx-shim, library and app code -->
<!-- final bundle includes require.js, library and app code -->
<script src="app-built.js"></script>
```

@ -1,5 +1,5 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
require(["xlsx-shim"], function(XLSX) {
require(["xlsx"], function(XLSX) {
console.log(XLSX);
var X = XLSX;

@ -1,5 +0,0 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
define(['xlsx'], function (_XLSX) {
/* work around require.js */
return XLSX;
});

4
dist/jszip.js generated vendored

@ -1,4 +1,4 @@
/*!
/*
JSZip - A Javascript class for generating and reading zip files
<http://stuartk.com/jszip>
@ -14,7 +14,7 @@ Note: since JSZip 3 removed critical functionality, this version assigns to the
*/
(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){JSZipSync=e();define([],e);}
else if("function"==typeof define&&define.amd&&"undefined"==typeof DO_NOT_EXPORT_JSZIP){JSZipSync=e();define([],e);}
else{
var f;
"undefined"!=typeof window?f=window:

4
dist/shim.min.js generated vendored

File diff suppressed because one or more lines are too long

32
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

91
dist/xlsx.extendscript.js generated vendored

@ -1,5 +1,5 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* shim.js (C) 2013-present SheetJS -- http://sheetjs.com */
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/*! shim.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* ES3/5 Compatibility shims and other utilities for older browsers. */
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
@ -148,9 +148,14 @@ var IE_LoadFile = (function() { try {
}
return function(filename) { return fix_data(IE_LoadFile_Impl(filename)); };
} catch(e) { return void 0; }})();
// getComputedStyle polyfill from https://gist.github.com/8HNHoFtE/5891086
if(typeof window !== 'undefined' && typeof window.getComputedStyle !== 'function') {
window.getComputedStyle = function(e,t){return this.el=e,this.getPropertyValue=function(t){var n=/(\-([a-z]){1})/g;return t=="float"&&(t="styleFloat"),n.test(t)&&(t=t.replace(n,function(){return arguments[2].toUpperCase()})),e.currentStyle[t]?e.currentStyle[t]:null},this}
}
var DO_NOT_EXPORT_CODEPAGE = true;
var DO_NOT_EXPORT_JSZIP = true;
/*!
/*
JSZip - A Javascript class for generating and reading zip files
<http://stuartk.com/jszip>
@ -166,7 +171,7 @@ Note: since JSZip 3 removed critical functionality, this version assigns to the
*/
(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){JSZipSync=e();define([],e);}
else if("function"==typeof define&&define.amd&&"undefined"==typeof DO_NOT_EXPORT_JSZIP){JSZipSync=e();define([],e);}
else{
var f;
"undefined"!=typeof window?f=window:
@ -9147,13 +9152,13 @@ module.exports = ZStream;
},{}]},{},[9])
(9)
}));
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported XLSX */
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.12.13';
function make_xlsx_lib(XLSX){
XLSX.version = '0.13.0';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -17007,7 +17012,7 @@ function parse_borders(t, styles, themes, opts) {
var pass = false;
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x);
switch (y[0]) {
switch(strip_ns(y[0])) {
case '<borders': case '<borders>': case '</borders>': break;
/* 18.8.4 border CT_Border */
@ -17081,7 +17086,7 @@ function parse_fills(t, styles, themes, opts) {
var pass = false;
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x);
switch(y[0]) {
switch(strip_ns(y[0])) {
case '<fills': case '<fills>': case '</fills>': break;
/* 18.8.20 fill CT_Fill */
@ -17147,7 +17152,7 @@ function parse_fonts(t, styles, themes, opts) {
var pass = false;
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x);
switch (y[0]) {
switch(strip_ns(y[0])) {
case '<fonts': case '<fonts>': case '</fonts>': break;
/* 18.8.22 font CT_Font */
@ -17265,7 +17270,7 @@ function parse_numFmts(t, styles, opts) {
if(!m) return;
for(i=0; i < m.length; ++i) {
var y = parsexmltag(m[i]);
switch(y[0]) {
switch(strip_ns(y[0])) {
case '<numFmts': case '</numFmts>': case '<numFmts/>': case '<numFmts>': break;
case '<numFmt': {
var f=unescapexml(utf8read(y.formatCode)), j=parseInt(y.numFmtId,10);
@ -17304,7 +17309,7 @@ function parse_cellXfs(t, styles, opts) {
var pass = false;
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x), i = 0;
switch(y[0]) {
switch(strip_ns(y[0])) {
case '<cellXfs': case '<cellXfs>': case '<cellXfs/>': case '</cellXfs>': break;
/* 18.8.45 xf CT_Xf */
@ -17359,11 +17364,11 @@ function write_cellXfs(cellXfs) {
/* 18.8 Styles CT_Stylesheet*/
var parse_sty_xml= (function make_pstyx() {
var numFmtRegex = /<numFmts([^>]*)>[\S\s]*?<\/numFmts>/;
var cellXfRegex = /<cellXfs([^>]*)>[\S\s]*?<\/cellXfs>/;
var fillsRegex = /<fills([^>]*)>[\S\s]*?<\/fills>/;
var fontsRegex = /<fonts([^>]*)>[\S\s]*?<\/fonts>/;
var bordersRegex = /<borders([^>]*)>[\S\s]*?<\/borders>/;
var numFmtRegex = /<(?:\w+:)?numFmts([^>]*)>[\S\s]*?<\/(?:\w+:)?numFmts>/;
var cellXfRegex = /<(?:\w+:)?cellXfs([^>]*)>[\S\s]*?<\/(?:\w+:)?cellXfs>/;
var fillsRegex = /<(?:\w+:)?fills([^>]*)>[\S\s]*?<\/(?:\w+:)?fills>/;
var fontsRegex = /<(?:\w+:)?fonts([^>]*)>[\S\s]*?<\/(?:\w+:)?fonts>/;
var bordersRegex = /<(?:\w+:)?borders([^>]*)>[\S\s]*?<\/(?:\w+:)?borders>/;
return function parse_sty_xml(data, themes, opts) {
var styles = {};
@ -18317,7 +18322,7 @@ function write_comments_vml(rId, comments) {
'<v:shape' + wxt_helper({
id:'_x0000_s' + (++_shapeid),
type:"#_x0000_t202",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10;visibility:hidden",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10" + (x[1].hidden ? ";visibility:hidden" : "") ,
fillcolor:"#ECFAD4",
strokecolor:"#edeaa1"
}) + '>',
@ -18333,7 +18338,7 @@ function write_comments_vml(rId, comments) {
writetag('x:AutoFill', "False"),
writetag('x:Row', String(c.r)),
writetag('x:Column', String(c.c)),
'<x:Visible/>',
x[1].hidden ? '' : '<x:Visible/>',
'</x:ClientData>',
'</v:shape>'
]); });
@ -27317,15 +27322,22 @@ function parse_dom_table(table, _opts) {
if(DENSE != null) opts.dense = DENSE;
var ws = opts.dense ? ([]) : ({});
var rows = table.getElementsByTagName('tr');
var sheetRows = Math.min(opts.sheetRows||10000000, rows.length);
var range = {s:{r:0,c:0},e:{r:sheetRows - 1,c:0}};
var sheetRows = opts.sheetRows || 10000000;
var range = {s:{r:0,c:0},e:{r:0,c:0}};
var merges = [], midx = 0;
var R = 0, _C = 0, C = 0, RS = 0, CS = 0;
for(; R < sheetRows; ++R) {
var row = rows[R];
var rowinfo = [];
var _R = 0, R = 0, _C, C, RS, CS;
for(; _R < rows.length && R < sheetRows; ++_R) {
var row = rows[_R];
if (is_dom_element_hidden(row)) {
if (opts.display) continue;
rowinfo[R] = {hidden: true};
}
var elts = (row.children);
for(_C = C = 0; _C < elts.length; ++_C) {
var elt = elts[_C], v = htmldecode(elts[_C].innerHTML);
var elt = elts[_C];
if (opts.display && is_dom_element_hidden(elt)) continue;
var v = htmldecode(elt.innerHTML);
for(midx = 0; midx < merges.length; ++midx) {
var m = merges[midx];
if(m.s.c == C && m.s.r <= R && R <= m.e.r) { C = m.e.c+1; midx = -1; }
@ -27352,16 +27364,36 @@ function parse_dom_table(table, _opts) {
if(range.e.c < C) range.e.c = C;
C += CS;
}
++R;
}
if(merges.length) ws['!merges'] = merges;
if(rowinfo.length) ws['!rows'] = rowinfo;
range.e.r = R - 1;
ws['!ref'] = encode_range(range);
if(sheetRows < rows.length) ws['!fullref'] = encode_range((range.e.r = rows.length-1,range));
if(R >= sheetRows) ws['!fullref'] = encode_range((range.e.r = rows.length-_R+R-1,range)); // We can count the real number of rows to parse but we don't to improve the performance
return ws;
}
function table_to_book(table, opts) {
return sheet_to_workbook(parse_dom_table(table, opts), opts);
}
function is_dom_element_hidden(element) {
var display = '';
var get_computed_style = get_get_computed_style_function(element);
if(get_computed_style) display = get_computed_style(element).getPropertyValue('display');
if(!display) display = element.style.display; // Fallback for cases when getComputedStyle is not available (e.g. an old browser or some Node.js environments) or doesn't work (e.g. if the element is not inserted to a document)
return display === 'none';
}
/* global getComputedStyle */
function get_get_computed_style_function(element) {
// The proper getComputedStyle implementation is the one defined in the element window
if(element.ownerDocument.defaultView && typeof element.ownerDocument.defaultView.getComputedStyle === 'function') return element.ownerDocument.defaultView.getComputedStyle;
// If it is not available, try to get one from the global namespace
if(typeof getComputedStyle === 'function') return getComputedStyle;
return null;
}
/* OpenDocument */
var parse_content_xml = (function() {
@ -29247,6 +29279,11 @@ XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
})(typeof exports !== 'undefined' ? exports : XLSX);
}
/*global define */
if(typeof exports !== 'undefined') make_xlsx_lib(exports);
else if(typeof module !== 'undefined' && module.exports) make_xlsx_lib(module.exports);
else if(typeof define === 'function' && define.amd) define('xlsx', function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
else make_xlsx_lib(XLSX);
/*exported XLS, ODS */
var XLS = XLSX, ODS = XLSX;

35
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

78
dist/xlsx.js generated vendored

@ -1,10 +1,10 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported XLSX */
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.12.13';
function make_xlsx_lib(XLSX){
XLSX.version = '0.13.0';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -7858,7 +7858,7 @@ function parse_borders(t, styles, themes, opts) {
var pass = false;
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x);
switch (y[0]) {
switch(strip_ns(y[0])) {
case '<borders': case '<borders>': case '</borders>': break;
/* 18.8.4 border CT_Border */
@ -7932,7 +7932,7 @@ function parse_fills(t, styles, themes, opts) {
var pass = false;
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x);
switch(y[0]) {
switch(strip_ns(y[0])) {
case '<fills': case '<fills>': case '</fills>': break;
/* 18.8.20 fill CT_Fill */
@ -7998,7 +7998,7 @@ function parse_fonts(t, styles, themes, opts) {
var pass = false;
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x);
switch (y[0]) {
switch(strip_ns(y[0])) {
case '<fonts': case '<fonts>': case '</fonts>': break;
/* 18.8.22 font CT_Font */
@ -8116,7 +8116,7 @@ function parse_numFmts(t, styles, opts) {
if(!m) return;
for(i=0; i < m.length; ++i) {
var y = parsexmltag(m[i]);
switch(y[0]) {
switch(strip_ns(y[0])) {
case '<numFmts': case '</numFmts>': case '<numFmts/>': case '<numFmts>': break;
case '<numFmt': {
var f=unescapexml(utf8read(y.formatCode)), j=parseInt(y.numFmtId,10);
@ -8155,7 +8155,7 @@ function parse_cellXfs(t, styles, opts) {
var pass = false;
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x), i = 0;
switch(y[0]) {
switch(strip_ns(y[0])) {
case '<cellXfs': case '<cellXfs>': case '<cellXfs/>': case '</cellXfs>': break;
/* 18.8.45 xf CT_Xf */
@ -8210,11 +8210,11 @@ function write_cellXfs(cellXfs) {
/* 18.8 Styles CT_Stylesheet*/
var parse_sty_xml= (function make_pstyx() {
var numFmtRegex = /<numFmts([^>]*)>[\S\s]*?<\/numFmts>/;
var cellXfRegex = /<cellXfs([^>]*)>[\S\s]*?<\/cellXfs>/;
var fillsRegex = /<fills([^>]*)>[\S\s]*?<\/fills>/;
var fontsRegex = /<fonts([^>]*)>[\S\s]*?<\/fonts>/;
var bordersRegex = /<borders([^>]*)>[\S\s]*?<\/borders>/;
var numFmtRegex = /<(?:\w+:)?numFmts([^>]*)>[\S\s]*?<\/(?:\w+:)?numFmts>/;
var cellXfRegex = /<(?:\w+:)?cellXfs([^>]*)>[\S\s]*?<\/(?:\w+:)?cellXfs>/;
var fillsRegex = /<(?:\w+:)?fills([^>]*)>[\S\s]*?<\/(?:\w+:)?fills>/;
var fontsRegex = /<(?:\w+:)?fonts([^>]*)>[\S\s]*?<\/(?:\w+:)?fonts>/;
var bordersRegex = /<(?:\w+:)?borders([^>]*)>[\S\s]*?<\/(?:\w+:)?borders>/;
return function parse_sty_xml(data, themes, opts) {
var styles = {};
@ -9168,7 +9168,7 @@ function write_comments_vml(rId, comments) {
'<v:shape' + wxt_helper({
id:'_x0000_s' + (++_shapeid),
type:"#_x0000_t202",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10;visibility:hidden",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10" + (x[1].hidden ? ";visibility:hidden" : "") ,
fillcolor:"#ECFAD4",
strokecolor:"#edeaa1"
}) + '>',
@ -9184,7 +9184,7 @@ function write_comments_vml(rId, comments) {
writetag('x:AutoFill', "False"),
writetag('x:Row', String(c.r)),
writetag('x:Column', String(c.c)),
'<x:Visible/>',
x[1].hidden ? '' : '<x:Visible/>',
'</x:ClientData>',
'</v:shape>'
]); });
@ -18168,15 +18168,22 @@ function parse_dom_table(table, _opts) {
if(DENSE != null) opts.dense = DENSE;
var ws = opts.dense ? ([]) : ({});
var rows = table.getElementsByTagName('tr');
var sheetRows = Math.min(opts.sheetRows||10000000, rows.length);
var range = {s:{r:0,c:0},e:{r:sheetRows - 1,c:0}};
var sheetRows = opts.sheetRows || 10000000;
var range = {s:{r:0,c:0},e:{r:0,c:0}};
var merges = [], midx = 0;
var R = 0, _C = 0, C = 0, RS = 0, CS = 0;
for(; R < sheetRows; ++R) {
var row = rows[R];
var rowinfo = [];
var _R = 0, R = 0, _C, C, RS, CS;
for(; _R < rows.length && R < sheetRows; ++_R) {
var row = rows[_R];
if (is_dom_element_hidden(row)) {
if (opts.display) continue;
rowinfo[R] = {hidden: true};
}
var elts = (row.children);
for(_C = C = 0; _C < elts.length; ++_C) {
var elt = elts[_C], v = htmldecode(elts[_C].innerHTML);
var elt = elts[_C];
if (opts.display && is_dom_element_hidden(elt)) continue;
var v = htmldecode(elt.innerHTML);
for(midx = 0; midx < merges.length; ++midx) {
var m = merges[midx];
if(m.s.c == C && m.s.r <= R && R <= m.e.r) { C = m.e.c+1; midx = -1; }
@ -18203,16 +18210,36 @@ function parse_dom_table(table, _opts) {
if(range.e.c < C) range.e.c = C;
C += CS;
}
++R;
}
if(merges.length) ws['!merges'] = merges;
if(rowinfo.length) ws['!rows'] = rowinfo;
range.e.r = R - 1;
ws['!ref'] = encode_range(range);
if(sheetRows < rows.length) ws['!fullref'] = encode_range((range.e.r = rows.length-1,range));
if(R >= sheetRows) ws['!fullref'] = encode_range((range.e.r = rows.length-_R+R-1,range)); // We can count the real number of rows to parse but we don't to improve the performance
return ws;
}
function table_to_book(table, opts) {
return sheet_to_workbook(parse_dom_table(table, opts), opts);
}
function is_dom_element_hidden(element) {
var display = '';
var get_computed_style = get_get_computed_style_function(element);
if(get_computed_style) display = get_computed_style(element).getPropertyValue('display');
if(!display) display = element.style.display; // Fallback for cases when getComputedStyle is not available (e.g. an old browser or some Node.js environments) or doesn't work (e.g. if the element is not inserted to a document)
return display === 'none';
}
/* global getComputedStyle */
function get_get_computed_style_function(element) {
// The proper getComputedStyle implementation is the one defined in the element window
if(element.ownerDocument.defaultView && typeof element.ownerDocument.defaultView.getComputedStyle === 'function') return element.ownerDocument.defaultView.getComputedStyle;
// If it is not available, try to get one from the global namespace
if(typeof getComputedStyle === 'function') return getComputedStyle;
return null;
}
/* OpenDocument */
var parse_content_xml = (function() {
@ -20098,6 +20125,11 @@ XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
})(typeof exports !== 'undefined' ? exports : XLSX);
}
/*global define */
if(typeof exports !== 'undefined') make_xlsx_lib(exports);
else if(typeof module !== 'undefined' && module.exports) make_xlsx_lib(module.exports);
else if(typeof define === 'function' && define.amd) define('xlsx', function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
else make_xlsx_lib(XLSX);
/*exported XLS, ODS */
var XLS = XLSX, ODS = XLSX;

28
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

@ -52,11 +52,11 @@ Multiple tables on a web page can be converted to individual worksheets:
var workbook = XLSX.utils.book_new();
/* convert table 'table1' to worksheet named "Sheet1" */
var ws1 = XLSX.utils.table_to_book(document.getElementById('table1'));
var ws1 = XLSX.utils.table_to_sheet(document.getElementById('table1'));
XLSX.utils.book_append_sheet(workbook, ws1, "Sheet1");
/* convert table 'table2' to worksheet named "Sheet2" */
var ws2 = XLSX.utils.table_to_book(document.getElementById('table2'));
var ws2 = XLSX.utils.table_to_sheet(document.getElementById('table2'));
XLSX.utils.book_append_sheet(workbook, ws2, "Sheet2");
/* workbook now has 2 worksheets */

@ -15,3 +15,14 @@ ws.A1.c.push({a:"SheetJS", t:"I'm a little comment, short and stout!"});
Note: XLSB enforces a 54 character limit on the Author name. Names longer than
54 characters may cause issues with other formats.
To mark a comment as normally hidden, set the `hidden` property:
```js
if(!ws.A1.c) ws.A1.c = [];
ws.A1.c.push({a:"SheetJS", t:"This comment is visible"});
if(!ws.A2.c) ws.A2.c = [];
ws.A2.c.hidden = true;
ws.A2.c.push({a:"SheetJS", t:"This comment will be hidden"});
```

@ -1,4 +1,4 @@
/*!
/*
JSZip - A Javascript class for generating and reading zip files
<http://stuartk.com/jszip>
@ -14,7 +14,7 @@ Note: since JSZip 3 removed critical functionality, this version assigns to the
*/
(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){JSZipSync=e();define([],e);}
else if("function"==typeof define&&define.amd&&"undefined"==typeof DO_NOT_EXPORT_JSZIP){JSZipSync=e();define([],e);}
else{
var f;
"undefined"!=typeof window?f=window:

@ -341,11 +341,11 @@ Multiple tables on a web page can be converted to individual worksheets:
var workbook = XLSX.utils.book_new();
/* convert table 'table1' to worksheet named "Sheet1" */
var ws1 = XLSX.utils.table_to_book(document.getElementById('table1'));
var ws1 = XLSX.utils.table_to_sheet(document.getElementById('table1'));
XLSX.utils.book_append_sheet(workbook, ws1, "Sheet1");
/* convert table 'table2' to worksheet named "Sheet2" */
var ws2 = XLSX.utils.table_to_book(document.getElementById('table2'));
var ws2 = XLSX.utils.table_to_sheet(document.getElementById('table2'));
XLSX.utils.book_append_sheet(workbook, ws2, "Sheet2");
/* workbook now has 2 worksheets */
@ -1426,6 +1426,17 @@ ws.A1.c.push({a:"SheetJS", t:"I'm a little comment, short and stout!"});
Note: XLSB enforces a 54 character limit on the Author name. Names longer than
54 characters may cause issues with other formats.
To mark a comment as normally hidden, set the `hidden` property:
```js
if(!ws.A1.c) ws.A1.c = [];
ws.A1.c.push({a:"SheetJS", t:"This comment is visible"});
if(!ws.A2.c) ws.A2.c = [];
ws.A2.c.hidden = true;
ws.A2.c.push({a:"SheetJS", t:"This comment will be hidden"});
```
#### Sheet Visibility
Excel enables hiding sheets in the lower tab bar. The sheet data is stored in
@ -1896,6 +1907,7 @@ Both functions accept options arguments:
|`dateNF` | FMT 14 | Use specified date format in string output |
|`cellDates` | false | Store dates as type `d` (default is `n`) |
|`sheetRows` | 0 | If >0, read the first `sheetRows` rows of the table |
|`display` | false | If true, hidden rows and cells will not be parsed |

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.12.13",
"version": "0.13.0",
"author": "sheetjs",
"description": "SheetJS Spreadsheet data parser and writer",
"keywords": [

@ -1,4 +1,4 @@
/* shim.js (C) 2013-present SheetJS -- http://sheetjs.com */
/*! shim.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* ES3/5 Compatibility shims and other utilities for older browsers. */
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

@ -10,6 +10,7 @@ declare type DescribeIt = { (desc:string, test:EmptyFunc):void; skip(desc:string
declare var describe : DescribeIt;
declare var it: DescribeIt;
declare var before:(test:EmptyFunc)=>void;
declare var afterEach:(test:EmptyFunc)=>void;
declare var cptable: any;
*/
var X;
@ -2031,7 +2032,7 @@ function get_dom_element(html) {
if(browser) {
var domelt = document.createElement('div');
domelt.innerHTML = html;
document.body.appendChild(domelt);
if(document.body) document.body.appendChild(domelt);
inserted_dom_elements.push(domelt);
return domelt.children[0];
}

3
tests/core.js generated

@ -10,6 +10,7 @@ declare type DescribeIt = { (desc:string, test:EmptyFunc):void; skip(desc:string
declare var describe : DescribeIt;
declare var it: DescribeIt;
declare var before:(test:EmptyFunc)=>void;
declare var afterEach:(test:EmptyFunc)=>void;
declare var cptable: any;
*/
var X;
@ -2031,7 +2032,7 @@ function get_dom_element(html) {
if(browser) {
var domelt = document.createElement('div');
domelt.innerHTML = html;
document.body.appendChild(domelt);
if(document.body) document.body.appendChild(domelt);
inserted_dom_elements.push(domelt);
return domelt.children[0];
}

@ -1,10 +1,10 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported XLSX */
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.12.13';
function make_xlsx_lib(XLSX){
XLSX.version = '0.13.0';
var current_codepage = 1200, current_ansi = 1252;
/*:: declare var cptable:any; */
/*global cptable:true, window */
@ -9246,7 +9246,7 @@ function parse_drawing(data, rels/*:any*/) {
/* L.5.5.2 SpreadsheetML Comments + VML Schema */
var _shapeid = 1024;
function write_comments_vml(rId, comments) {
function write_comments_vml(rId/*:number*/, comments) {
var csize = [21600, 21600];
/* L.5.2.1.2 Path Attribute */
var bbox = ["m0,0l0",csize[1],csize[0],csize[1],csize[0],"0xe"].join(",");
@ -9265,7 +9265,7 @@ function write_comments_vml(rId, comments) {
'<v:shape' + wxt_helper({
id:'_x0000_s' + (++_shapeid),
type:"#_x0000_t202",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10;visibility:hidden",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10" + (x[1].hidden ? ";visibility:hidden" : "") ,
fillcolor:"#ECFAD4",
strokecolor:"#edeaa1"
}) + '>',
@ -9281,7 +9281,7 @@ function write_comments_vml(rId, comments) {
writetag('x:AutoFill', "False"),
writetag('x:Row', String(c.r)),
writetag('x:Column', String(c.c)),
'<x:Visible/>',
x[1].hidden ? '' : '<x:Visible/>',
'</x:ClientData>',
'</v:shape>'
]); });
@ -20244,6 +20244,12 @@ XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
})(typeof exports !== 'undefined' ? exports : XLSX);
}
/*global define */
/*:: declare var define:any; */
if(typeof exports !== 'undefined') make_xlsx_lib(exports);
else if(typeof module !== 'undefined' && module.exports) make_xlsx_lib(module.exports);
else if(typeof define === 'function' && define.amd) define('xlsx', function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
else make_xlsx_lib(XLSX);
/*exported XLS, ODS */
var XLS = XLSX, ODS = XLSX;

17
xlsx.js generated

@ -1,10 +1,10 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported XLSX */
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.12.13';
function make_xlsx_lib(XLSX){
XLSX.version = '0.13.0';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -9168,7 +9168,7 @@ function write_comments_vml(rId, comments) {
'<v:shape' + wxt_helper({
id:'_x0000_s' + (++_shapeid),
type:"#_x0000_t202",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10;visibility:hidden",
style:"position:absolute; margin-left:80pt;margin-top:5pt;width:104pt;height:64pt;z-index:10" + (x[1].hidden ? ";visibility:hidden" : "") ,
fillcolor:"#ECFAD4",
strokecolor:"#edeaa1"
}) + '>',
@ -9184,7 +9184,7 @@ function write_comments_vml(rId, comments) {
writetag('x:AutoFill', "False"),
writetag('x:Row', String(c.r)),
writetag('x:Column', String(c.c)),
'<x:Visible/>',
x[1].hidden ? '' : '<x:Visible/>',
'</x:ClientData>',
'</v:shape>'
]); });
@ -20125,6 +20125,11 @@ XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
})(typeof exports !== 'undefined' ? exports : XLSX);
}
/*global define */
if(typeof exports !== 'undefined') make_xlsx_lib(exports);
else if(typeof module !== 'undefined' && module.exports) make_xlsx_lib(module.exports);
else if(typeof define === 'function' && define.amd) define('xlsx', function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
else make_xlsx_lib(XLSX);
/*exported XLS, ODS */
var XLS = XLSX, ODS = XLSX;