1
forked from sheetjs/sheetjs

version bump 0.16.6: xlfn option

This commit is contained in:
SheetJS 2020-08-12 17:58:02 -04:00
parent 3b589f001b
commit 2e32611dbb
22 changed files with 134 additions and 82 deletions

@ -1685,6 +1685,7 @@ The exported `read` and `readFile` functions accept an options argument:
|`WTF` | false | If true, throw errors on unexpected file features ** | |`WTF` | false | If true, throw errors on unexpected file features ** |
|`sheets` | | If specified, only parse specified sheets ** | |`sheets` | | If specified, only parse specified sheets ** |
|`PRN` | false | If true, allow parsing of PRN files ** | |`PRN` | false | If true, allow parsing of PRN files ** |
|`xlfn` | false | If true, preserve `_xlfn.` prefixes in formulae ** |
- Even if `cellNF` is false, formatted text will be generated and saved to `.w` - 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. - In some cases, sheets may be parsed even if `bookSheets` is false.
@ -1711,6 +1712,8 @@ The exported `read` and `readFile` functions accept an options argument:
- `PRN` affects parsing of text files without a common delimiter character. - `PRN` affects parsing of text files without a common delimiter character.
- Currently only XOR encryption is supported. Unsupported error will be thrown - Currently only XOR encryption is supported. Unsupported error will be thrown
for files employing other encryption methods. for files employing other encryption methods.
- Newer Excel functions are serialized with the `_xlfn.` prefix, hidden from the
user. SheetJS will strip `_xlfn.` normally. The `xlfn` option preserves them.
- WTF is mainly for development. By default, the parser will suppress read - WTF is mainly for development. By default, the parser will suppress read
errors on single worksheets, allowing you to read from the worksheets that do errors on single worksheets, allowing you to read from the worksheets that do
parse properly. Setting `WTF:true` forces those errors to be thrown. parse properly. Setting `WTF:true` forces those errors to be thrown.

@ -1 +1 @@
XLSX.version = '0.16.5'; XLSX.version = '0.16.6';

@ -352,14 +352,17 @@ return function parse_ws_xml_data(sdata/*:string*/, s, opts, guess/*:Range*/, th
if(opts.cellFormula) { if(opts.cellFormula) {
if((cref=d.match(match_f))!= null && /*::cref != null && */cref[1] !== '') { if((cref=d.match(match_f))!= null && /*::cref != null && */cref[1] !== '') {
/* TODO: match against XLSXFutureFunctions */ /* TODO: match against XLSXFutureFunctions */
p.f=_xlfn(unescapexml(utf8read(cref[1]))); p.f=unescapexml(utf8read(cref[1]));
if(!opts.xlfn) p.f = _xlfn(p.f);
if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="array"') > -1) { if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="array"') > -1) {
p.F = (d.match(refregex)||[])[1]; p.F = (d.match(refregex)||[])[1];
if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]); if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]);
} else if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="shared"') > -1) { } else if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="shared"') > -1) {
// TODO: parse formula // TODO: parse formula
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
sharedf[parseInt(ftag.si, 10)] = [ftag, _xlfn(unescapexml(utf8read(cref[1]))), tag.r]; var ___f = unescapexml(utf8read(cref[1]));
if(!opts.xlfn) ___f = _xlfn(___f);
sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];
} }
} else if((cref=d.match(/<f[^>]*\/>/))) { } else if((cref=d.match(/<f[^>]*\/>/))) {
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);

18
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

17
dist/xlsx.extendscript.js generated vendored

@ -9161,7 +9161,7 @@ module.exports = ZStream;
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {}; var XLSX = {};
function make_xlsx_lib(XLSX){ function make_xlsx_lib(XLSX){
XLSX.version = '0.16.5'; XLSX.version = '0.16.6';
var current_codepage = 1200, current_ansi = 1252; var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */ /*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') { if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -12153,7 +12153,7 @@ function resolve_path(path, base) {
} }
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'; var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g; var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g; var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g; if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/; var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;
@ -17500,7 +17500,7 @@ var sirphregex = /<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;
function parse_si(x, opts) { function parse_si(x, opts) {
var html = opts ? opts.cellHTML : true; var html = opts ? opts.cellHTML : true;
var z = {}; var z = {};
if(!x) return null; if(!x) return { t: "" };
//var y; //var y;
/* 18.4.12 t ST_Xstring (Plaintext String) */ /* 18.4.12 t ST_Xstring (Plaintext String) */
// TODO: is whitespace actually valid here? // TODO: is whitespace actually valid here?
@ -22708,14 +22708,17 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
if(opts.cellFormula) { if(opts.cellFormula) {
if((cref=d.match(match_f))!= null && cref[1] !== '') { if((cref=d.match(match_f))!= null && cref[1] !== '') {
/* TODO: match against XLSXFutureFunctions */ /* TODO: match against XLSXFutureFunctions */
p.f=_xlfn(unescapexml(utf8read(cref[1]))); p.f=unescapexml(utf8read(cref[1]));
if(!opts.xlfn) p.f = _xlfn(p.f);
if(cref[0].indexOf('t="array"') > -1) { if(cref[0].indexOf('t="array"') > -1) {
p.F = (d.match(refregex)||[])[1]; p.F = (d.match(refregex)||[])[1];
if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]); if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]);
} else if(cref[0].indexOf('t="shared"') > -1) { } else if(cref[0].indexOf('t="shared"') > -1) {
// TODO: parse formula // TODO: parse formula
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
sharedf[parseInt(ftag.si, 10)] = [ftag, _xlfn(unescapexml(utf8read(cref[1]))), tag.r]; var ___f = unescapexml(utf8read(cref[1]));
if(!opts.xlfn) ___f = _xlfn(___f);
sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];
} }
} else if((cref=d.match(/<f[^>]*\/>/))) { } else if((cref=d.match(/<f[^>]*\/>/))) {
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
@ -30619,8 +30622,8 @@ utils.book_new = function() {
/* add a worksheet to the end of a given workbook */ /* add a worksheet to the end of a given workbook */
utils.book_append_sheet = function(wb, ws, name) { utils.book_append_sheet = function(wb, ws, name) {
if(!name) for(var i = 1; i <= 0xFFFF; ++i) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break; if(!name) for(var i = 1; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break;
if(!name) throw new Error("Too many worksheets"); if(!name || wb.SheetNames.length >= 0xFFFF) throw new Error("Too many worksheets");
check_ws_name(name); check_ws_name(name);
if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!"); if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!");

18
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

17
dist/xlsx.js generated vendored

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {}; var XLSX = {};
function make_xlsx_lib(XLSX){ function make_xlsx_lib(XLSX){
XLSX.version = '0.16.5'; XLSX.version = '0.16.6';
var current_codepage = 1200, current_ansi = 1252; var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */ /*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') { if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -2996,7 +2996,7 @@ function resolve_path(path, base) {
} }
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'; var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g; var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g; var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g; if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/; var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;
@ -8343,7 +8343,7 @@ var sirphregex = /<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;
function parse_si(x, opts) { function parse_si(x, opts) {
var html = opts ? opts.cellHTML : true; var html = opts ? opts.cellHTML : true;
var z = {}; var z = {};
if(!x) return null; if(!x) return { t: "" };
//var y; //var y;
/* 18.4.12 t ST_Xstring (Plaintext String) */ /* 18.4.12 t ST_Xstring (Plaintext String) */
// TODO: is whitespace actually valid here? // TODO: is whitespace actually valid here?
@ -13551,14 +13551,17 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
if(opts.cellFormula) { if(opts.cellFormula) {
if((cref=d.match(match_f))!= null && cref[1] !== '') { if((cref=d.match(match_f))!= null && cref[1] !== '') {
/* TODO: match against XLSXFutureFunctions */ /* TODO: match against XLSXFutureFunctions */
p.f=_xlfn(unescapexml(utf8read(cref[1]))); p.f=unescapexml(utf8read(cref[1]));
if(!opts.xlfn) p.f = _xlfn(p.f);
if(cref[0].indexOf('t="array"') > -1) { if(cref[0].indexOf('t="array"') > -1) {
p.F = (d.match(refregex)||[])[1]; p.F = (d.match(refregex)||[])[1];
if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]); if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]);
} else if(cref[0].indexOf('t="shared"') > -1) { } else if(cref[0].indexOf('t="shared"') > -1) {
// TODO: parse formula // TODO: parse formula
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
sharedf[parseInt(ftag.si, 10)] = [ftag, _xlfn(unescapexml(utf8read(cref[1]))), tag.r]; var ___f = unescapexml(utf8read(cref[1]));
if(!opts.xlfn) ___f = _xlfn(___f);
sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];
} }
} else if((cref=d.match(/<f[^>]*\/>/))) { } else if((cref=d.match(/<f[^>]*\/>/))) {
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
@ -21462,8 +21465,8 @@ utils.book_new = function() {
/* add a worksheet to the end of a given workbook */ /* add a worksheet to the end of a given workbook */
utils.book_append_sheet = function(wb, ws, name) { utils.book_append_sheet = function(wb, ws, name) {
if(!name) for(var i = 1; i <= 0xFFFF; ++i) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break; if(!name) for(var i = 1; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break;
if(!name) throw new Error("Too many worksheets"); if(!name || wb.SheetNames.length >= 0xFFFF) throw new Error("Too many worksheets");
check_ws_name(name); check_ws_name(name);
if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!"); if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!");

20
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

10
dist/xlsx.mini.min.js generated vendored

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

@ -25,6 +25,7 @@ The exported `read` and `readFile` functions accept an options argument:
|`WTF` | false | If true, throw errors on unexpected file features ** | |`WTF` | false | If true, throw errors on unexpected file features ** |
|`sheets` | | If specified, only parse specified sheets ** | |`sheets` | | If specified, only parse specified sheets ** |
|`PRN` | false | If true, allow parsing of PRN files ** | |`PRN` | false | If true, allow parsing of PRN files ** |
|`xlfn` | false | If true, preserve `_xlfn.` prefixes in formulae ** |
- Even if `cellNF` is false, formatted text will be generated and saved to `.w` - 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. - In some cases, sheets may be parsed even if `bookSheets` is false.
@ -51,6 +52,8 @@ The exported `read` and `readFile` functions accept an options argument:
- `PRN` affects parsing of text files without a common delimiter character. - `PRN` affects parsing of text files without a common delimiter character.
- Currently only XOR encryption is supported. Unsupported error will be thrown - Currently only XOR encryption is supported. Unsupported error will be thrown
for files employing other encryption methods. for files employing other encryption methods.
- Newer Excel functions are serialized with the `_xlfn.` prefix, hidden from the
user. SheetJS will strip `_xlfn.` normally. The `xlfn` option preserves them.
- WTF is mainly for development. By default, the parser will suppress read - WTF is mainly for development. By default, the parser will suppress read
errors on single worksheets, allowing you to read from the worksheets that do errors on single worksheets, allowing you to read from the worksheets that do
parse properly. Setting `WTF:true` forces those errors to be thrown. parse properly. Setting `WTF:true` forces those errors to be thrown.

@ -1541,6 +1541,7 @@ The exported `read` and `readFile` functions accept an options argument:
|`WTF` | false | If true, throw errors on unexpected file features ** | |`WTF` | false | If true, throw errors on unexpected file features ** |
|`sheets` | | If specified, only parse specified sheets ** | |`sheets` | | If specified, only parse specified sheets ** |
|`PRN` | false | If true, allow parsing of PRN files ** | |`PRN` | false | If true, allow parsing of PRN files ** |
|`xlfn` | false | If true, preserve `_xlfn.` prefixes in formulae ** |
- Even if `cellNF` is false, formatted text will be generated and saved to `.w` - 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. - In some cases, sheets may be parsed even if `bookSheets` is false.
@ -1567,6 +1568,8 @@ The exported `read` and `readFile` functions accept an options argument:
- `PRN` affects parsing of text files without a common delimiter character. - `PRN` affects parsing of text files without a common delimiter character.
- Currently only XOR encryption is supported. Unsupported error will be thrown - Currently only XOR encryption is supported. Unsupported error will be thrown
for files employing other encryption methods. for files employing other encryption methods.
- Newer Excel functions are serialized with the `_xlfn.` prefix, hidden from the
user. SheetJS will strip `_xlfn.` normally. The `xlfn` option preserves them.
- WTF is mainly for development. By default, the parser will suppress read - WTF is mainly for development. By default, the parser will suppress read
errors on single worksheets, allowing you to read from the worksheets that do errors on single worksheets, allowing you to read from the worksheets that do
parse properly. Setting `WTF:true` forces those errors to be thrown. parse properly. Setting `WTF:true` forces those errors to be thrown.

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

11
test.js

@ -517,6 +517,17 @@ describe('parse options', function() {
assert(found); assert(found);
}); });
}); });
it('should preserve `_xlfn.` only when requested', function() {
var wb = { SheetNames: ["Sheet1"], Sheets: { Sheet1: {
"!ref": "A1:A1",
"A1": { t:"n", v:2, f:"_xlfn.IFS(2>3,1,3>2,2)"}
} } };
var str = X.write(wb, {bookType: "xlsx", type: "binary"});
var wb2 = X.read(str, {type: "binary"});
assert.equal(wb2.Sheets.Sheet1["A1"].f, "IFS(2>3,1,3>2,2)");
var wb3 = X.read(str, {type: "binary", xlfn: true});
assert.equal(wb3.Sheets.Sheet1["A1"].f, "_xlfn.IFS(2>3,1,3>2,2)");
});
}); });
describe('sheet', function() { describe('sheet', function() {
it('should not generate sheet stubs by default', function() { it('should not generate sheet stubs by default', function() {

11
tests/core.js generated

@ -517,6 +517,17 @@ describe('parse options', function() {
assert(found); assert(found);
}); });
}); });
it('should preserve `_xlfn.` only when requested', function() {
var wb = { SheetNames: ["Sheet1"], Sheets: { Sheet1: {
"!ref": "A1:A1",
"A1": { t:"n", v:2, f:"_xlfn.IFS(2>3,1,3>2,2)"}
} } };
var str = X.write(wb, {bookType: "xlsx", type: "binary"});
var wb2 = X.read(str, {type: "binary"});
assert.equal(wb2.Sheets.Sheet1["A1"].f, "IFS(2>3,1,3>2,2)");
var wb3 = X.read(str, {type: "binary", xlfn: true});
assert.equal(wb3.Sheets.Sheet1["A1"].f, "_xlfn.IFS(2>3,1,3>2,2)");
});
}); });
describe('sheet', function() { describe('sheet', function() {
it('should not generate sheet stubs by default', function() { it('should not generate sheet stubs by default', function() {

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {}; var XLSX = {};
function make_xlsx_lib(XLSX){ function make_xlsx_lib(XLSX){
XLSX.version = '0.16.5'; XLSX.version = '0.16.6';
var current_codepage = 1200, current_ansi = 1252; var current_codepage = 1200, current_ansi = 1252;
/*:: declare var cptable:any; */ /*:: declare var cptable:any; */
/*global cptable:true, window */ /*global cptable:true, window */
@ -3077,7 +3077,7 @@ function resolve_path(path/*:string*/, base/*:string*/)/*:string*/ {
} }
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'; var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g; var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g; var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g; if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/; var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;
@ -8441,7 +8441,7 @@ var sirphregex = /<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;
function parse_si(x, opts) { function parse_si(x, opts) {
var html = opts ? opts.cellHTML : true; var html = opts ? opts.cellHTML : true;
var z = {}; var z = {};
if(!x) return null; if(!x) return { t: "" };
//var y; //var y;
/* 18.4.12 t ST_Xstring (Plaintext String) */ /* 18.4.12 t ST_Xstring (Plaintext String) */
// TODO: is whitespace actually valid here? // TODO: is whitespace actually valid here?
@ -13653,14 +13653,17 @@ return function parse_ws_xml_data(sdata/*:string*/, s, opts, guess/*:Range*/, th
if(opts.cellFormula) { if(opts.cellFormula) {
if((cref=d.match(match_f))!= null && /*::cref != null && */cref[1] !== '') { if((cref=d.match(match_f))!= null && /*::cref != null && */cref[1] !== '') {
/* TODO: match against XLSXFutureFunctions */ /* TODO: match against XLSXFutureFunctions */
p.f=_xlfn(unescapexml(utf8read(cref[1]))); p.f=unescapexml(utf8read(cref[1]));
if(!opts.xlfn) p.f = _xlfn(p.f);
if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="array"') > -1) { if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="array"') > -1) {
p.F = (d.match(refregex)||[])[1]; p.F = (d.match(refregex)||[])[1];
if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]); if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]);
} else if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="shared"') > -1) { } else if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="shared"') > -1) {
// TODO: parse formula // TODO: parse formula
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
sharedf[parseInt(ftag.si, 10)] = [ftag, _xlfn(unescapexml(utf8read(cref[1]))), tag.r]; var ___f = unescapexml(utf8read(cref[1]));
if(!opts.xlfn) ___f = _xlfn(___f);
sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];
} }
} else if((cref=d.match(/<f[^>]*\/>/))) { } else if((cref=d.match(/<f[^>]*\/>/))) {
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
@ -21593,8 +21596,8 @@ utils.book_new = function()/*:Workbook*/ {
/* add a worksheet to the end of a given workbook */ /* add a worksheet to the end of a given workbook */
utils.book_append_sheet = function(wb/*:Workbook*/, ws/*:Worksheet*/, name/*:?string*/) { utils.book_append_sheet = function(wb/*:Workbook*/, ws/*:Worksheet*/, name/*:?string*/) {
if(!name) for(var i = 1; i <= 0xFFFF; ++i) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break; if(!name) for(var i = 1; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break;
if(!name) throw new Error("Too many worksheets"); if(!name || wb.SheetNames.length >= 0xFFFF) throw new Error("Too many worksheets");
check_ws_name(name); check_ws_name(name);
if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!"); if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!");

15
xlsx.js generated

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {}; var XLSX = {};
function make_xlsx_lib(XLSX){ function make_xlsx_lib(XLSX){
XLSX.version = '0.16.5'; XLSX.version = '0.16.6';
var current_codepage = 1200, current_ansi = 1252; var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */ /*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') { if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -2996,7 +2996,7 @@ function resolve_path(path, base) {
} }
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'; var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g; var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g; var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g; if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/; var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;
@ -8343,7 +8343,7 @@ var sirphregex = /<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;
function parse_si(x, opts) { function parse_si(x, opts) {
var html = opts ? opts.cellHTML : true; var html = opts ? opts.cellHTML : true;
var z = {}; var z = {};
if(!x) return null; if(!x) return { t: "" };
//var y; //var y;
/* 18.4.12 t ST_Xstring (Plaintext String) */ /* 18.4.12 t ST_Xstring (Plaintext String) */
// TODO: is whitespace actually valid here? // TODO: is whitespace actually valid here?
@ -13551,14 +13551,17 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
if(opts.cellFormula) { if(opts.cellFormula) {
if((cref=d.match(match_f))!= null && cref[1] !== '') { if((cref=d.match(match_f))!= null && cref[1] !== '') {
/* TODO: match against XLSXFutureFunctions */ /* TODO: match against XLSXFutureFunctions */
p.f=_xlfn(unescapexml(utf8read(cref[1]))); p.f=unescapexml(utf8read(cref[1]));
if(!opts.xlfn) p.f = _xlfn(p.f);
if(cref[0].indexOf('t="array"') > -1) { if(cref[0].indexOf('t="array"') > -1) {
p.F = (d.match(refregex)||[])[1]; p.F = (d.match(refregex)||[])[1];
if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]); if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]);
} else if(cref[0].indexOf('t="shared"') > -1) { } else if(cref[0].indexOf('t="shared"') > -1) {
// TODO: parse formula // TODO: parse formula
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
sharedf[parseInt(ftag.si, 10)] = [ftag, _xlfn(unescapexml(utf8read(cref[1]))), tag.r]; var ___f = unescapexml(utf8read(cref[1]));
if(!opts.xlfn) ___f = _xlfn(___f);
sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];
} }
} else if((cref=d.match(/<f[^>]*\/>/))) { } else if((cref=d.match(/<f[^>]*\/>/))) {
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
@ -21463,7 +21466,7 @@ utils.book_new = function() {
/* add a worksheet to the end of a given workbook */ /* add a worksheet to the end of a given workbook */
utils.book_append_sheet = function(wb, ws, name) { utils.book_append_sheet = function(wb, ws, name) {
if(!name) for(var i = 1; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break; if(!name) for(var i = 1; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break;
if(!name) throw new Error("Too many worksheets"); if(!name || wb.SheetNames.length >= 0xFFFF) throw new Error("Too many worksheets");
check_ws_name(name); check_ws_name(name);
if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!"); if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!");

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {}; var XLSX = {};
function make_xlsx_lib(XLSX){ function make_xlsx_lib(XLSX){
XLSX.version = '0.16.5'; XLSX.version = '0.16.6';
var current_codepage = 1200, current_ansi = 1252; var current_codepage = 1200, current_ansi = 1252;
var VALID_ANSI = [ 874, 932, 936, 949, 950 ]; var VALID_ANSI = [ 874, 932, 936, 949, 950 ];
@ -3039,7 +3039,7 @@ function resolve_path(path/*:string*/, base/*:string*/)/*:string*/ {
} }
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'; var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g; var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g; var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g; if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/; var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;
@ -5886,7 +5886,7 @@ var sirphregex = /<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;
function parse_si(x, opts) { function parse_si(x, opts) {
var html = opts ? opts.cellHTML : true; var html = opts ? opts.cellHTML : true;
var z = {}; var z = {};
if(!x) return null; if(!x) return { t: "" };
//var y; //var y;
/* 18.4.12 t ST_Xstring (Plaintext String) */ /* 18.4.12 t ST_Xstring (Plaintext String) */
// TODO: is whitespace actually valid here? // TODO: is whitespace actually valid here?
@ -7574,14 +7574,17 @@ return function parse_ws_xml_data(sdata/*:string*/, s, opts, guess/*:Range*/, th
if(opts.cellFormula) { if(opts.cellFormula) {
if((cref=d.match(match_f))!= null && /*::cref != null && */cref[1] !== '') { if((cref=d.match(match_f))!= null && /*::cref != null && */cref[1] !== '') {
/* TODO: match against XLSXFutureFunctions */ /* TODO: match against XLSXFutureFunctions */
p.f=_xlfn(unescapexml(utf8read(cref[1]))); p.f=unescapexml(utf8read(cref[1]));
if(!opts.xlfn) p.f = _xlfn(p.f);
if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="array"') > -1) { if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="array"') > -1) {
p.F = (d.match(refregex)||[])[1]; p.F = (d.match(refregex)||[])[1];
if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]); if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]);
} else if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="shared"') > -1) { } else if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="shared"') > -1) {
// TODO: parse formula // TODO: parse formula
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
sharedf[parseInt(ftag.si, 10)] = [ftag, _xlfn(unescapexml(utf8read(cref[1]))), tag.r]; var ___f = unescapexml(utf8read(cref[1]));
if(!opts.xlfn) ___f = _xlfn(___f);
sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];
} }
} else if((cref=d.match(/<f[^>]*\/>/))) { } else if((cref=d.match(/<f[^>]*\/>/))) {
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
@ -9696,8 +9699,8 @@ utils.book_new = function()/*:Workbook*/ {
/* add a worksheet to the end of a given workbook */ /* add a worksheet to the end of a given workbook */
utils.book_append_sheet = function(wb/*:Workbook*/, ws/*:Worksheet*/, name/*:?string*/) { utils.book_append_sheet = function(wb/*:Workbook*/, ws/*:Worksheet*/, name/*:?string*/) {
if(!name) for(var i = 1; i <= 0xFFFF; ++i) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break; if(!name) for(var i = 1; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break;
if(!name) throw new Error("Too many worksheets"); if(!name || wb.SheetNames.length >= 0xFFFF) throw new Error("Too many worksheets");
check_ws_name(name); check_ws_name(name);
if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!"); if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!");

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {}; var XLSX = {};
function make_xlsx_lib(XLSX){ function make_xlsx_lib(XLSX){
XLSX.version = '0.16.5'; XLSX.version = '0.16.6';
var current_codepage = 1200, current_ansi = 1252; var current_codepage = 1200, current_ansi = 1252;
var VALID_ANSI = [ 874, 932, 936, 949, 950 ]; var VALID_ANSI = [ 874, 932, 936, 949, 950 ];
@ -2960,7 +2960,7 @@ function resolve_path(path, base) {
} }
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'; var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g; var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g; var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g; if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/; var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;
@ -5795,7 +5795,7 @@ var sirphregex = /<(?:\w+:)?rPh.*?>([\s\S]*?)<\/(?:\w+:)?rPh>/g;
function parse_si(x, opts) { function parse_si(x, opts) {
var html = opts ? opts.cellHTML : true; var html = opts ? opts.cellHTML : true;
var z = {}; var z = {};
if(!x) return null; if(!x) return { t: "" };
//var y; //var y;
/* 18.4.12 t ST_Xstring (Plaintext String) */ /* 18.4.12 t ST_Xstring (Plaintext String) */
// TODO: is whitespace actually valid here? // TODO: is whitespace actually valid here?
@ -7483,14 +7483,17 @@ return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
if(opts.cellFormula) { if(opts.cellFormula) {
if((cref=d.match(match_f))!= null && cref[1] !== '') { if((cref=d.match(match_f))!= null && cref[1] !== '') {
/* TODO: match against XLSXFutureFunctions */ /* TODO: match against XLSXFutureFunctions */
p.f=_xlfn(unescapexml(utf8read(cref[1]))); p.f=unescapexml(utf8read(cref[1]));
if(!opts.xlfn) p.f = _xlfn(p.f);
if(cref[0].indexOf('t="array"') > -1) { if(cref[0].indexOf('t="array"') > -1) {
p.F = (d.match(refregex)||[])[1]; p.F = (d.match(refregex)||[])[1];
if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]); if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]);
} else if(cref[0].indexOf('t="shared"') > -1) { } else if(cref[0].indexOf('t="shared"') > -1) {
// TODO: parse formula // TODO: parse formula
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
sharedf[parseInt(ftag.si, 10)] = [ftag, _xlfn(unescapexml(utf8read(cref[1]))), tag.r]; var ___f = unescapexml(utf8read(cref[1]));
if(!opts.xlfn) ___f = _xlfn(___f);
sharedf[parseInt(ftag.si, 10)] = [ftag, ___f, tag.r];
} }
} else if((cref=d.match(/<f[^>]*\/>/))) { } else if((cref=d.match(/<f[^>]*\/>/))) {
ftag = parsexmltag(cref[0]); ftag = parsexmltag(cref[0]);
@ -9591,8 +9594,8 @@ utils.book_new = function() {
/* add a worksheet to the end of a given workbook */ /* add a worksheet to the end of a given workbook */
utils.book_append_sheet = function(wb, ws, name) { utils.book_append_sheet = function(wb, ws, name) {
if(!name) for(var i = 1; i <= 0xFFFF; ++i) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break; if(!name) for(var i = 1; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break;
if(!name) throw new Error("Too many worksheets"); if(!name || wb.SheetNames.length >= 0xFFFF) throw new Error("Too many worksheets");
check_ws_name(name); check_ws_name(name);
if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!"); if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!");