version bump 0.16.1
- Custom Properties use correct encoding - AMD wrapper change (see #1937)
This commit is contained in:
parent
91f8c46704
commit
baea1798cf
|
@ -286,8 +286,8 @@ Excel 2007, nothing outside of SheetJS or Excel supported the format.
|
|||
To promote a format-agnostic view, js-xlsx starts from a pure-JS representation
|
||||
that we call the ["Common Spreadsheet Format"](#common-spreadsheet-format).
|
||||
Emphasizing a uniform object representation enables new features like format
|
||||
conversion (reading an XLSX template and saving as XLS) and circumvents the
|
||||
"class trap". By abstracting the complexities of the various formats, tools
|
||||
conversion (reading an XLSX template and saving as XLS) and circumvents the mess
|
||||
of classes. By abstracting the complexities of the various formats, tools
|
||||
need not worry about the specific file type!
|
||||
|
||||
A simple object representation combined with careful coding practices enables
|
||||
|
|
|
@ -1 +1 @@
|
|||
XLSX.version = '0.16.0';
|
||||
XLSX.version = '0.16.1';
|
||||
|
|
|
@ -225,9 +225,12 @@ function writextag(f/*:string*/,g/*:?string*/,h) { return '<' + f + ((h != null)
|
|||
|
||||
function write_w3cdtf(d/*:Date*/, t/*:?boolean*/)/*:string*/ { try { return d.toISOString().replace(/\.\d*/,""); } catch(e) { if(t) throw e; } return ""; }
|
||||
|
||||
function write_vt(s)/*:string*/ {
|
||||
function write_vt(s, xlsx/*:?boolean*/)/*:string*/ {
|
||||
switch(typeof s) {
|
||||
case 'string': return writextag('vt:lpwstr', escapexml(s));
|
||||
case 'string':
|
||||
var o = writextag('vt:lpwstr', escapexml(s));
|
||||
if(xlsx) o = o.replace(/"/g, "_x0022_");
|
||||
return o;
|
||||
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', escapexml(String(s)));
|
||||
case 'boolean': return writextag('vt:bool',s?'true':'false');
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ var make_offcrypto = function(O, _crypto) {
|
|||
t = S[i]; S[i] = S[j]; S[j] = t;
|
||||
}
|
||||
// $FlowIgnore
|
||||
i = j = 0; var out = Buffer(data.length);
|
||||
i = j = 0; var out = new_raw_buf(data.length);
|
||||
for(c = 0; c != data.length; ++c) {
|
||||
i = (i + 1)&255;
|
||||
j = (j + S[i])%256;
|
||||
|
|
|
@ -9,8 +9,23 @@ function fix_col(cstr/*:string*/)/*:string*/ { return cstr.replace(/^([A-Z])/,"$
|
|||
function unfix_col(cstr/*:string*/)/*:string*/ { return cstr.replace(/^\$([A-Z])/,"$1"); }
|
||||
|
||||
function split_cell(cstr/*:string*/)/*:Array<string>*/ { return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(","); }
|
||||
function decode_cell(cstr/*:string*/)/*:CellAddress*/ { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function encode_cell(cell/*:CellAddress*/)/*:string*/ { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
//function decode_cell(cstr/*:string*/)/*:CellAddress*/ { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function decode_cell(cstr/*:string*/)/*:CellAddress*/ {
|
||||
var R = 0, C = 0;
|
||||
for(var i = 0; i < cstr.length; ++i) {
|
||||
var cc = cstr.charCodeAt(i);
|
||||
if(cc >= 48 && cc <= 57) R = 10 * R + (cc - 48);
|
||||
else if(cc >= 65 && cc <= 90) C = 26 * C + (cc - 64);
|
||||
}
|
||||
return { c: C - 1, r:R - 1 };
|
||||
}
|
||||
//function encode_cell(cell/*:CellAddress*/)/*:string*/ { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
function encode_cell(cell/*:CellAddress*/)/*:string*/ {
|
||||
var col = cell.c + 1;
|
||||
var s="";
|
||||
for(; col; col=((col-1)/26)|0) s = String.fromCharCode(((col-1)%26) + 65) + s;
|
||||
return s + (cell.r + 1);
|
||||
}
|
||||
function decode_range(range/*:string*/)/*:Range*/ { var x =range.split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }
|
||||
/*# if only one arg, it is assumed to be a Range. If 2 args, both are cell addresses */
|
||||
function encode_range(cs/*:CellAddrSpec|Range*/,ce/*:?CellAddrSpec*/)/*:string*/ {
|
||||
|
|
|
@ -57,7 +57,7 @@ function write_cust_props(cp/*::, opts*/)/*:string*/ {
|
|||
if(!cp) return o.join("");
|
||||
var pid = 1;
|
||||
keys(cp).forEach(function custprop(k) { ++pid;
|
||||
o[o.length] = (writextag('property', write_vt(cp[k]), {
|
||||
o[o.length] = (writextag('property', write_vt(cp[k], true), {
|
||||
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
|
||||
'pid': pid,
|
||||
'name': escapexml(k)
|
||||
|
|
|
@ -139,8 +139,8 @@ function parse_dom_table(table/*:HTMLElement*/, _opts/*:?any*/)/*:Worksheet*/ {
|
|||
for(_C = C = 0; _C < elts.length; ++_C) {
|
||||
var elt/*:HTMLTableCellElement*/ = elts[_C];
|
||||
if (opts.display && is_dom_element_hidden(elt)) continue;
|
||||
var v/*:string*/ = elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);
|
||||
var z/*:string*/ = elt.getAttribute('z');
|
||||
var v/*:?string*/ = elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);
|
||||
var z/*:?string*/ = elt.getAttribute('z');
|
||||
for(midx = 0; midx < merges.length; ++midx) {
|
||||
var m/*:Range*/ = merges[midx];
|
||||
if(m.s.c == C && m.s.r <= R && R <= m.e.r) { C = m.e.c+1; midx = -1; }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*:: 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 if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
|
||||
else make_xlsx_lib(XLSX);
|
||||
/*exported XLS, ODS */
|
||||
var XLS = XLSX, ODS = XLSX;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -9160,7 +9160,7 @@ module.exports = ZStream;
|
|||
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
|
||||
var XLSX = {};
|
||||
function make_xlsx_lib(XLSX){
|
||||
XLSX.version = '0.16.0';
|
||||
XLSX.version = '0.16.1';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*global cptable:true, window */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
|
@ -12278,9 +12278,12 @@ function writextag(f,g,h) { return '<' + f + ((h != null) ? wxt_helper(h) : "")
|
|||
|
||||
function write_w3cdtf(d, t) { try { return d.toISOString().replace(/\.\d*/,""); } catch(e) { if(t) throw e; } return ""; }
|
||||
|
||||
function write_vt(s) {
|
||||
function write_vt(s, xlsx) {
|
||||
switch(typeof s) {
|
||||
case 'string': return writextag('vt:lpwstr', escapexml(s));
|
||||
case 'string':
|
||||
var o = writextag('vt:lpwstr', escapexml(s));
|
||||
if(xlsx) o = o.replace(/"/g, "_x0022_");
|
||||
return o;
|
||||
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', escapexml(String(s)));
|
||||
case 'boolean': return writextag('vt:bool',s?'true':'false');
|
||||
}
|
||||
|
@ -12688,7 +12691,7 @@ var make_offcrypto = function(O, _crypto) {
|
|||
t = S[i]; S[i] = S[j]; S[j] = t;
|
||||
}
|
||||
// $FlowIgnore
|
||||
i = j = 0; var out = Buffer(data.length);
|
||||
i = j = 0; var out = new_raw_buf(data.length);
|
||||
for(c = 0; c != data.length; ++c) {
|
||||
i = (i + 1)&255;
|
||||
j = (j + S[i])%256;
|
||||
|
@ -12717,8 +12720,23 @@ function fix_col(cstr) { return cstr.replace(/^([A-Z])/,"$$$1"); }
|
|||
function unfix_col(cstr) { return cstr.replace(/^\$([A-Z])/,"$1"); }
|
||||
|
||||
function split_cell(cstr) { return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(","); }
|
||||
function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
//function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function decode_cell(cstr) {
|
||||
var R = 0, C = 0;
|
||||
for(var i = 0; i < cstr.length; ++i) {
|
||||
var cc = cstr.charCodeAt(i);
|
||||
if(cc >= 48 && cc <= 57) R = 10 * R + (cc - 48);
|
||||
else if(cc >= 65 && cc <= 90) C = 26 * C + (cc - 64);
|
||||
}
|
||||
return { c: C - 1, r:R - 1 };
|
||||
}
|
||||
//function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
function encode_cell(cell) {
|
||||
var col = cell.c + 1;
|
||||
var s="";
|
||||
for(; col; col=((col-1)/26)|0) s = String.fromCharCode(((col-1)%26) + 65) + s;
|
||||
return s + (cell.r + 1);
|
||||
}
|
||||
function decode_range(range) { var x =range.split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }
|
||||
function encode_range(cs,ce) {
|
||||
if(typeof ce === 'undefined' || typeof ce === 'number') {
|
||||
|
@ -14034,7 +14052,7 @@ function parse_ext_props(data, p, opts) {
|
|||
EXT_PROPS.forEach(function(f) {
|
||||
var xml = (data.match(matchtag(f[0]))||[])[1];
|
||||
switch(f[2]) {
|
||||
case "string": p[f[1]] = unescapexml(xml||""); break;
|
||||
case "string": if(xml) p[f[1]] = unescapexml(xml); break;
|
||||
case "bool": p[f[1]] = xml === "true"; break;
|
||||
case "raw":
|
||||
var cur = data.match(new RegExp("<" + f[0] + "[^>]*>([\\s\\S]*?)<\/" + f[0] + ">"));
|
||||
|
@ -14135,7 +14153,7 @@ function write_cust_props(cp) {
|
|||
if(!cp) return o.join("");
|
||||
var pid = 1;
|
||||
keys(cp).forEach(function custprop(k) { ++pid;
|
||||
o[o.length] = (writextag('property', write_vt(cp[k]), {
|
||||
o[o.length] = (writextag('property', write_vt(cp[k], true), {
|
||||
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
|
||||
'pid': pid,
|
||||
'name': escapexml(k)
|
||||
|
@ -28504,6 +28522,7 @@ var HTML_ = (function() {
|
|||
sp.t = cell && cell.t || 'z';
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>';
|
||||
sp.id = (o.id || "sjs") + "-" + coord;
|
||||
if(sp.t != "z") { sp.v = cell.v; if(cell.z != null) sp.z = cell.z; }
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
var preamble = "<tr>";
|
||||
|
@ -28526,8 +28545,8 @@ var HTML_ = (function() {
|
|||
for(var R = r.s.r; R <= r.e.r; ++R) out.push(make_html_row(ws, r, R, o));
|
||||
out.push("</table>" + footer);
|
||||
return out.join("");
|
||||
}
|
||||
|
||||
}
|
||||
return {
|
||||
to_workbook: html_to_book,
|
||||
to_sheet: html_to_sheet,
|
||||
|
@ -28559,7 +28578,8 @@ function parse_dom_table(table, _opts) {
|
|||
for(_C = C = 0; _C < elts.length; ++_C) {
|
||||
var elt = elts[_C];
|
||||
if (opts.display && is_dom_element_hidden(elt)) continue;
|
||||
var v = htmldecode(elt.innerHTML);
|
||||
var v = elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);
|
||||
var z = elt.getAttribute('z');
|
||||
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; }
|
||||
|
@ -28581,7 +28601,8 @@ function parse_dom_table(table, _opts) {
|
|||
o.z = opts.dateNF || SSF._table[14];
|
||||
}
|
||||
}
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o; }
|
||||
if(o.z === undefined && z != null) o.z = z;
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o;}
|
||||
else ws[encode_cell({c:C, r:R})] = o;
|
||||
if(range.e.c < C) range.e.c = C;
|
||||
C += CS;
|
||||
|
@ -30625,7 +30646,7 @@ if(typeof CFB !== "undefined") XLSX.CFB = CFB;
|
|||
/*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 if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
|
||||
else make_xlsx_lib(XLSX);
|
||||
/*exported XLS, ODS */
|
||||
var XLS = XLSX, ODS = XLSX;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
|
||||
var XLSX = {};
|
||||
function make_xlsx_lib(XLSX){
|
||||
XLSX.version = '0.16.0';
|
||||
XLSX.version = '0.16.1';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*global cptable:true, window */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
|
@ -3122,9 +3122,12 @@ function writextag(f,g,h) { return '<' + f + ((h != null) ? wxt_helper(h) : "")
|
|||
|
||||
function write_w3cdtf(d, t) { try { return d.toISOString().replace(/\.\d*/,""); } catch(e) { if(t) throw e; } return ""; }
|
||||
|
||||
function write_vt(s) {
|
||||
function write_vt(s, xlsx) {
|
||||
switch(typeof s) {
|
||||
case 'string': return writextag('vt:lpwstr', escapexml(s));
|
||||
case 'string':
|
||||
var o = writextag('vt:lpwstr', escapexml(s));
|
||||
if(xlsx) o = o.replace(/"/g, "_x0022_");
|
||||
return o;
|
||||
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', escapexml(String(s)));
|
||||
case 'boolean': return writextag('vt:bool',s?'true':'false');
|
||||
}
|
||||
|
@ -3532,7 +3535,7 @@ var make_offcrypto = function(O, _crypto) {
|
|||
t = S[i]; S[i] = S[j]; S[j] = t;
|
||||
}
|
||||
// $FlowIgnore
|
||||
i = j = 0; var out = Buffer(data.length);
|
||||
i = j = 0; var out = new_raw_buf(data.length);
|
||||
for(c = 0; c != data.length; ++c) {
|
||||
i = (i + 1)&255;
|
||||
j = (j + S[i])%256;
|
||||
|
@ -3561,8 +3564,23 @@ function fix_col(cstr) { return cstr.replace(/^([A-Z])/,"$$$1"); }
|
|||
function unfix_col(cstr) { return cstr.replace(/^\$([A-Z])/,"$1"); }
|
||||
|
||||
function split_cell(cstr) { return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(","); }
|
||||
function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
//function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function decode_cell(cstr) {
|
||||
var R = 0, C = 0;
|
||||
for(var i = 0; i < cstr.length; ++i) {
|
||||
var cc = cstr.charCodeAt(i);
|
||||
if(cc >= 48 && cc <= 57) R = 10 * R + (cc - 48);
|
||||
else if(cc >= 65 && cc <= 90) C = 26 * C + (cc - 64);
|
||||
}
|
||||
return { c: C - 1, r:R - 1 };
|
||||
}
|
||||
//function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
function encode_cell(cell) {
|
||||
var col = cell.c + 1;
|
||||
var s="";
|
||||
for(; col; col=((col-1)/26)|0) s = String.fromCharCode(((col-1)%26) + 65) + s;
|
||||
return s + (cell.r + 1);
|
||||
}
|
||||
function decode_range(range) { var x =range.split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }
|
||||
function encode_range(cs,ce) {
|
||||
if(typeof ce === 'undefined' || typeof ce === 'number') {
|
||||
|
@ -4878,7 +4896,7 @@ function parse_ext_props(data, p, opts) {
|
|||
EXT_PROPS.forEach(function(f) {
|
||||
var xml = (data.match(matchtag(f[0]))||[])[1];
|
||||
switch(f[2]) {
|
||||
case "string": p[f[1]] = unescapexml(xml||""); break;
|
||||
case "string": if(xml) p[f[1]] = unescapexml(xml); break;
|
||||
case "bool": p[f[1]] = xml === "true"; break;
|
||||
case "raw":
|
||||
var cur = data.match(new RegExp("<" + f[0] + "[^>]*>([\\s\\S]*?)<\/" + f[0] + ">"));
|
||||
|
@ -4979,7 +4997,7 @@ function write_cust_props(cp) {
|
|||
if(!cp) return o.join("");
|
||||
var pid = 1;
|
||||
keys(cp).forEach(function custprop(k) { ++pid;
|
||||
o[o.length] = (writextag('property', write_vt(cp[k]), {
|
||||
o[o.length] = (writextag('property', write_vt(cp[k], true), {
|
||||
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
|
||||
'pid': pid,
|
||||
'name': escapexml(k)
|
||||
|
@ -19348,6 +19366,7 @@ var HTML_ = (function() {
|
|||
sp.t = cell && cell.t || 'z';
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>';
|
||||
sp.id = (o.id || "sjs") + "-" + coord;
|
||||
if(sp.t != "z") { sp.v = cell.v; if(cell.z != null) sp.z = cell.z; }
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
var preamble = "<tr>";
|
||||
|
@ -19370,8 +19389,8 @@ var HTML_ = (function() {
|
|||
for(var R = r.s.r; R <= r.e.r; ++R) out.push(make_html_row(ws, r, R, o));
|
||||
out.push("</table>" + footer);
|
||||
return out.join("");
|
||||
}
|
||||
|
||||
}
|
||||
return {
|
||||
to_workbook: html_to_book,
|
||||
to_sheet: html_to_sheet,
|
||||
|
@ -19403,7 +19422,8 @@ function parse_dom_table(table, _opts) {
|
|||
for(_C = C = 0; _C < elts.length; ++_C) {
|
||||
var elt = elts[_C];
|
||||
if (opts.display && is_dom_element_hidden(elt)) continue;
|
||||
var v = htmldecode(elt.innerHTML);
|
||||
var v = elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);
|
||||
var z = elt.getAttribute('z');
|
||||
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; }
|
||||
|
@ -19425,7 +19445,8 @@ function parse_dom_table(table, _opts) {
|
|||
o.z = opts.dateNF || SSF._table[14];
|
||||
}
|
||||
}
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o; }
|
||||
if(o.z === undefined && z != null) o.z = z;
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o;}
|
||||
else ws[encode_cell({c:C, r:R})] = o;
|
||||
if(range.e.c < C) range.e.c = C;
|
||||
C += CS;
|
||||
|
@ -21469,7 +21490,7 @@ if(typeof CFB !== "undefined") XLSX.CFB = CFB;
|
|||
/*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 if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
|
||||
else make_xlsx_lib(XLSX);
|
||||
/*exported XLS, ODS */
|
||||
var XLS = XLSX, ODS = XLSX;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -11,8 +11,8 @@ Excel 2007, nothing outside of SheetJS or Excel supported the format.
|
|||
To promote a format-agnostic view, js-xlsx starts from a pure-JS representation
|
||||
that we call the ["Common Spreadsheet Format"](#common-spreadsheet-format).
|
||||
Emphasizing a uniform object representation enables new features like format
|
||||
conversion (reading an XLSX template and saving as XLS) and circumvents the
|
||||
"class trap". By abstracting the complexities of the various formats, tools
|
||||
conversion (reading an XLSX template and saving as XLS) and circumvents the mess
|
||||
of classes. By abstracting the complexities of the various formats, tools
|
||||
need not worry about the specific file type!
|
||||
|
||||
A simple object representation combined with careful coding practices enables
|
||||
|
|
|
@ -272,8 +272,8 @@ Excel 2007, nothing outside of SheetJS or Excel supported the format.
|
|||
To promote a format-agnostic view, js-xlsx starts from a pure-JS representation
|
||||
that we call the ["Common Spreadsheet Format"](#common-spreadsheet-format).
|
||||
Emphasizing a uniform object representation enables new features like format
|
||||
conversion (reading an XLSX template and saving as XLS) and circumvents the
|
||||
"class trap". By abstracting the complexities of the various formats, tools
|
||||
conversion (reading an XLSX template and saving as XLS) and circumvents the mess
|
||||
of classes. By abstracting the complexities of the various formats, tools
|
||||
need not worry about the specific file type!
|
||||
|
||||
A simple object representation combined with careful coding practices enables
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "xlsx",
|
||||
"version": "0.16.0",
|
||||
"version": "0.16.1",
|
||||
"author": "sheetjs",
|
||||
"description": "SheetJS Spreadsheet data parser and writer",
|
||||
"keywords": [
|
||||
|
@ -38,8 +38,8 @@
|
|||
"commander": "~2.17.1",
|
||||
"crc-32": "~1.2.0",
|
||||
"exit-on-epipe": "~1.0.1",
|
||||
"wmf": "~1.0.1",
|
||||
"ssf": "~0.10.3"
|
||||
"ssf": "~0.10.3",
|
||||
"wmf": "~1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sheetjs/uglify-js": "~2.7.3",
|
||||
|
|
45
xlsx.flow.js
45
xlsx.flow.js
|
@ -4,7 +4,7 @@
|
|||
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
|
||||
var XLSX = {};
|
||||
function make_xlsx_lib(XLSX){
|
||||
XLSX.version = '0.16.0';
|
||||
XLSX.version = '0.16.1';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*:: declare var cptable:any; */
|
||||
/*global cptable:true, window */
|
||||
|
@ -3203,9 +3203,12 @@ function writextag(f/*:string*/,g/*:?string*/,h) { return '<' + f + ((h != null)
|
|||
|
||||
function write_w3cdtf(d/*:Date*/, t/*:?boolean*/)/*:string*/ { try { return d.toISOString().replace(/\.\d*/,""); } catch(e) { if(t) throw e; } return ""; }
|
||||
|
||||
function write_vt(s)/*:string*/ {
|
||||
function write_vt(s, xlsx/*:?boolean*/)/*:string*/ {
|
||||
switch(typeof s) {
|
||||
case 'string': return writextag('vt:lpwstr', escapexml(s));
|
||||
case 'string':
|
||||
var o = writextag('vt:lpwstr', escapexml(s));
|
||||
if(xlsx) o = o.replace(/"/g, "_x0022_");
|
||||
return o;
|
||||
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', escapexml(String(s)));
|
||||
case 'boolean': return writextag('vt:bool',s?'true':'false');
|
||||
}
|
||||
|
@ -3619,7 +3622,7 @@ var make_offcrypto = function(O, _crypto) {
|
|||
t = S[i]; S[i] = S[j]; S[j] = t;
|
||||
}
|
||||
// $FlowIgnore
|
||||
i = j = 0; var out = Buffer(data.length);
|
||||
i = j = 0; var out = new_raw_buf(data.length);
|
||||
for(c = 0; c != data.length; ++c) {
|
||||
i = (i + 1)&255;
|
||||
j = (j + S[i])%256;
|
||||
|
@ -3649,8 +3652,23 @@ function fix_col(cstr/*:string*/)/*:string*/ { return cstr.replace(/^([A-Z])/,"$
|
|||
function unfix_col(cstr/*:string*/)/*:string*/ { return cstr.replace(/^\$([A-Z])/,"$1"); }
|
||||
|
||||
function split_cell(cstr/*:string*/)/*:Array<string>*/ { return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(","); }
|
||||
function decode_cell(cstr/*:string*/)/*:CellAddress*/ { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function encode_cell(cell/*:CellAddress*/)/*:string*/ { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
//function decode_cell(cstr/*:string*/)/*:CellAddress*/ { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function decode_cell(cstr/*:string*/)/*:CellAddress*/ {
|
||||
var R = 0, C = 0;
|
||||
for(var i = 0; i < cstr.length; ++i) {
|
||||
var cc = cstr.charCodeAt(i);
|
||||
if(cc >= 48 && cc <= 57) R = 10 * R + (cc - 48);
|
||||
else if(cc >= 65 && cc <= 90) C = 26 * C + (cc - 64);
|
||||
}
|
||||
return { c: C - 1, r:R - 1 };
|
||||
}
|
||||
//function encode_cell(cell/*:CellAddress*/)/*:string*/ { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
function encode_cell(cell/*:CellAddress*/)/*:string*/ {
|
||||
var col = cell.c + 1;
|
||||
var s="";
|
||||
for(; col; col=((col-1)/26)|0) s = String.fromCharCode(((col-1)%26) + 65) + s;
|
||||
return s + (cell.r + 1);
|
||||
}
|
||||
function decode_range(range/*:string*/)/*:Range*/ { var x =range.split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }
|
||||
/*# if only one arg, it is assumed to be a Range. If 2 args, both are cell addresses */
|
||||
function encode_range(cs/*:CellAddrSpec|Range*/,ce/*:?CellAddrSpec*/)/*:string*/ {
|
||||
|
@ -4971,7 +4989,7 @@ function parse_ext_props(data, p, opts) {
|
|||
EXT_PROPS.forEach(function(f) {
|
||||
var xml = (data.match(matchtag(f[0]))||[])[1];
|
||||
switch(f[2]) {
|
||||
case "string": p[f[1]] = unescapexml(xml||""); break;
|
||||
case "string": if(xml) p[f[1]] = unescapexml(xml); break;
|
||||
case "bool": p[f[1]] = xml === "true"; break;
|
||||
case "raw":
|
||||
var cur = data.match(new RegExp("<" + f[0] + "[^>]*>([\\s\\S]*?)<\/" + f[0] + ">"));
|
||||
|
@ -5072,7 +5090,7 @@ function write_cust_props(cp/*::, opts*/)/*:string*/ {
|
|||
if(!cp) return o.join("");
|
||||
var pid = 1;
|
||||
keys(cp).forEach(function custprop(k) { ++pid;
|
||||
o[o.length] = (writextag('property', write_vt(cp[k]), {
|
||||
o[o.length] = (writextag('property', write_vt(cp[k], true), {
|
||||
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
|
||||
'pid': pid,
|
||||
'name': escapexml(k)
|
||||
|
@ -19466,6 +19484,7 @@ var HTML_ = (function() {
|
|||
sp.t = cell && cell.t || 'z';
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>';
|
||||
sp.id = (o.id || "sjs") + "-" + coord;
|
||||
if(sp.t != "z") { sp.v = cell.v; if(cell.z != null) sp.z = cell.z; }
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
var preamble = "<tr>";
|
||||
|
@ -19488,8 +19507,8 @@ var HTML_ = (function() {
|
|||
for(var R = r.s.r; R <= r.e.r; ++R) out.push(make_html_row(ws, r, R, o));
|
||||
out.push("</table>" + footer);
|
||||
return out.join("");
|
||||
}
|
||||
|
||||
}
|
||||
return {
|
||||
to_workbook: html_to_book,
|
||||
to_sheet: html_to_sheet,
|
||||
|
@ -19521,7 +19540,8 @@ function parse_dom_table(table/*:HTMLElement*/, _opts/*:?any*/)/*:Worksheet*/ {
|
|||
for(_C = C = 0; _C < elts.length; ++_C) {
|
||||
var elt/*:HTMLTableCellElement*/ = elts[_C];
|
||||
if (opts.display && is_dom_element_hidden(elt)) continue;
|
||||
var v/*:string*/ = htmldecode(elt.innerHTML);
|
||||
var v/*:?string*/ = elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);
|
||||
var z/*:?string*/ = elt.getAttribute('z');
|
||||
for(midx = 0; midx < merges.length; ++midx) {
|
||||
var m/*:Range*/ = merges[midx];
|
||||
if(m.s.c == C && m.s.r <= R && R <= m.e.r) { C = m.e.c+1; midx = -1; }
|
||||
|
@ -19543,7 +19563,8 @@ function parse_dom_table(table/*:HTMLElement*/, _opts/*:?any*/)/*:Worksheet*/ {
|
|||
o.z = opts.dateNF || SSF._table[14];
|
||||
}
|
||||
}
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o; }
|
||||
if(o.z === undefined && z != null) o.z = z;
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o;}
|
||||
else ws[encode_cell({c:C, r:R})] = o;
|
||||
if(range.e.c < C) range.e.c = C;
|
||||
C += CS;
|
||||
|
@ -21601,7 +21622,7 @@ if(typeof CFB !== "undefined") XLSX.CFB = CFB;
|
|||
/*:: 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 if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
|
||||
else make_xlsx_lib(XLSX);
|
||||
/*exported XLS, ODS */
|
||||
var XLS = XLSX, ODS = XLSX;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
|
||||
var XLSX = {};
|
||||
function make_xlsx_lib(XLSX){
|
||||
XLSX.version = '0.16.0';
|
||||
XLSX.version = '0.16.1';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*global cptable:true, window */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
|
@ -3122,9 +3122,12 @@ function writextag(f,g,h) { return '<' + f + ((h != null) ? wxt_helper(h) : "")
|
|||
|
||||
function write_w3cdtf(d, t) { try { return d.toISOString().replace(/\.\d*/,""); } catch(e) { if(t) throw e; } return ""; }
|
||||
|
||||
function write_vt(s) {
|
||||
function write_vt(s, xlsx) {
|
||||
switch(typeof s) {
|
||||
case 'string': return writextag('vt:lpwstr', escapexml(s));
|
||||
case 'string':
|
||||
var o = writextag('vt:lpwstr', escapexml(s));
|
||||
if(xlsx) o = o.replace(/"/g, "_x0022_");
|
||||
return o;
|
||||
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', escapexml(String(s)));
|
||||
case 'boolean': return writextag('vt:bool',s?'true':'false');
|
||||
}
|
||||
|
@ -3532,7 +3535,7 @@ var make_offcrypto = function(O, _crypto) {
|
|||
t = S[i]; S[i] = S[j]; S[j] = t;
|
||||
}
|
||||
// $FlowIgnore
|
||||
i = j = 0; var out = Buffer(data.length);
|
||||
i = j = 0; var out = new_raw_buf(data.length);
|
||||
for(c = 0; c != data.length; ++c) {
|
||||
i = (i + 1)&255;
|
||||
j = (j + S[i])%256;
|
||||
|
@ -3561,8 +3564,23 @@ function fix_col(cstr) { return cstr.replace(/^([A-Z])/,"$$$1"); }
|
|||
function unfix_col(cstr) { return cstr.replace(/^\$([A-Z])/,"$1"); }
|
||||
|
||||
function split_cell(cstr) { return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(","); }
|
||||
function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
//function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function decode_cell(cstr) {
|
||||
var R = 0, C = 0;
|
||||
for(var i = 0; i < cstr.length; ++i) {
|
||||
var cc = cstr.charCodeAt(i);
|
||||
if(cc >= 48 && cc <= 57) R = 10 * R + (cc - 48);
|
||||
else if(cc >= 65 && cc <= 90) C = 26 * C + (cc - 64);
|
||||
}
|
||||
return { c: C - 1, r:R - 1 };
|
||||
}
|
||||
//function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
function encode_cell(cell) {
|
||||
var col = cell.c + 1;
|
||||
var s="";
|
||||
for(; col; col=((col-1)/26)|0) s = String.fromCharCode(((col-1)%26) + 65) + s;
|
||||
return s + (cell.r + 1);
|
||||
}
|
||||
function decode_range(range) { var x =range.split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }
|
||||
function encode_range(cs,ce) {
|
||||
if(typeof ce === 'undefined' || typeof ce === 'number') {
|
||||
|
@ -4878,7 +4896,7 @@ function parse_ext_props(data, p, opts) {
|
|||
EXT_PROPS.forEach(function(f) {
|
||||
var xml = (data.match(matchtag(f[0]))||[])[1];
|
||||
switch(f[2]) {
|
||||
case "string": p[f[1]] = unescapexml(xml||""); break;
|
||||
case "string": if(xml) p[f[1]] = unescapexml(xml); break;
|
||||
case "bool": p[f[1]] = xml === "true"; break;
|
||||
case "raw":
|
||||
var cur = data.match(new RegExp("<" + f[0] + "[^>]*>([\\s\\S]*?)<\/" + f[0] + ">"));
|
||||
|
@ -4979,7 +4997,7 @@ function write_cust_props(cp) {
|
|||
if(!cp) return o.join("");
|
||||
var pid = 1;
|
||||
keys(cp).forEach(function custprop(k) { ++pid;
|
||||
o[o.length] = (writextag('property', write_vt(cp[k]), {
|
||||
o[o.length] = (writextag('property', write_vt(cp[k], true), {
|
||||
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
|
||||
'pid': pid,
|
||||
'name': escapexml(k)
|
||||
|
@ -19348,6 +19366,7 @@ var HTML_ = (function() {
|
|||
sp.t = cell && cell.t || 'z';
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>';
|
||||
sp.id = (o.id || "sjs") + "-" + coord;
|
||||
if(sp.t != "z") { sp.v = cell.v; if(cell.z != null) sp.z = cell.z; }
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
var preamble = "<tr>";
|
||||
|
@ -19370,8 +19389,8 @@ var HTML_ = (function() {
|
|||
for(var R = r.s.r; R <= r.e.r; ++R) out.push(make_html_row(ws, r, R, o));
|
||||
out.push("</table>" + footer);
|
||||
return out.join("");
|
||||
}
|
||||
|
||||
}
|
||||
return {
|
||||
to_workbook: html_to_book,
|
||||
to_sheet: html_to_sheet,
|
||||
|
@ -19403,7 +19422,8 @@ function parse_dom_table(table, _opts) {
|
|||
for(_C = C = 0; _C < elts.length; ++_C) {
|
||||
var elt = elts[_C];
|
||||
if (opts.display && is_dom_element_hidden(elt)) continue;
|
||||
var v = htmldecode(elt.innerHTML);
|
||||
var v = elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);
|
||||
var z = elt.getAttribute('z');
|
||||
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; }
|
||||
|
@ -19425,7 +19445,8 @@ function parse_dom_table(table, _opts) {
|
|||
o.z = opts.dateNF || SSF._table[14];
|
||||
}
|
||||
}
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o; }
|
||||
if(o.z === undefined && z != null) o.z = z;
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o;}
|
||||
else ws[encode_cell({c:C, r:R})] = o;
|
||||
if(range.e.c < C) range.e.c = C;
|
||||
C += CS;
|
||||
|
@ -21469,7 +21490,7 @@ if(typeof CFB !== "undefined") XLSX.CFB = CFB;
|
|||
/*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 if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
|
||||
else make_xlsx_lib(XLSX);
|
||||
/*exported XLS, ODS */
|
||||
var XLS = XLSX, ODS = XLSX;
|
||||
|
|
|
@ -3165,9 +3165,12 @@ function writextag(f/*:string*/,g/*:?string*/,h) { return '<' + f + ((h != null)
|
|||
|
||||
function write_w3cdtf(d/*:Date*/, t/*:?boolean*/)/*:string*/ { try { return d.toISOString().replace(/\.\d*/,""); } catch(e) { if(t) throw e; } return ""; }
|
||||
|
||||
function write_vt(s)/*:string*/ {
|
||||
function write_vt(s, xlsx/*:?boolean*/)/*:string*/ {
|
||||
switch(typeof s) {
|
||||
case 'string': return writextag('vt:lpwstr', escapexml(s));
|
||||
case 'string':
|
||||
var o = writextag('vt:lpwstr', escapexml(s));
|
||||
if(xlsx) o = o.replace(/"/g, "_x0022_");
|
||||
return o;
|
||||
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', escapexml(String(s)));
|
||||
case 'boolean': return writextag('vt:bool',s?'true':'false');
|
||||
}
|
||||
|
@ -3573,8 +3576,23 @@ function fix_col(cstr/*:string*/)/*:string*/ { return cstr.replace(/^([A-Z])/,"$
|
|||
function unfix_col(cstr/*:string*/)/*:string*/ { return cstr.replace(/^\$([A-Z])/,"$1"); }
|
||||
|
||||
function split_cell(cstr/*:string*/)/*:Array<string>*/ { return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(","); }
|
||||
function decode_cell(cstr/*:string*/)/*:CellAddress*/ { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function encode_cell(cell/*:CellAddress*/)/*:string*/ { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
//function decode_cell(cstr/*:string*/)/*:CellAddress*/ { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function decode_cell(cstr/*:string*/)/*:CellAddress*/ {
|
||||
var R = 0, C = 0;
|
||||
for(var i = 0; i < cstr.length; ++i) {
|
||||
var cc = cstr.charCodeAt(i);
|
||||
if(cc >= 48 && cc <= 57) R = 10 * R + (cc - 48);
|
||||
else if(cc >= 65 && cc <= 90) C = 26 * C + (cc - 64);
|
||||
}
|
||||
return { c: C - 1, r:R - 1 };
|
||||
}
|
||||
//function encode_cell(cell/*:CellAddress*/)/*:string*/ { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
function encode_cell(cell/*:CellAddress*/)/*:string*/ {
|
||||
var col = cell.c + 1;
|
||||
var s="";
|
||||
for(; col; col=((col-1)/26)|0) s = String.fromCharCode(((col-1)%26) + 65) + s;
|
||||
return s + (cell.r + 1);
|
||||
}
|
||||
function decode_range(range/*:string*/)/*:Range*/ { var x =range.split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }
|
||||
/*# if only one arg, it is assumed to be a Range. If 2 args, both are cell addresses */
|
||||
function encode_range(cs/*:CellAddrSpec|Range*/,ce/*:?CellAddrSpec*/)/*:string*/ {
|
||||
|
@ -4523,7 +4541,7 @@ function parse_ext_props(data, p, opts) {
|
|||
EXT_PROPS.forEach(function(f) {
|
||||
var xml = (data.match(matchtag(f[0]))||[])[1];
|
||||
switch(f[2]) {
|
||||
case "string": p[f[1]] = unescapexml(xml||""); break;
|
||||
case "string": if(xml) p[f[1]] = unescapexml(xml); break;
|
||||
case "bool": p[f[1]] = xml === "true"; break;
|
||||
case "raw":
|
||||
var cur = data.match(new RegExp("<" + f[0] + "[^>]*>([\\s\\S]*?)<\/" + f[0] + ">"));
|
||||
|
@ -4624,7 +4642,7 @@ function write_cust_props(cp/*::, opts*/)/*:string*/ {
|
|||
if(!cp) return o.join("");
|
||||
var pid = 1;
|
||||
keys(cp).forEach(function custprop(k) { ++pid;
|
||||
o[o.length] = (writextag('property', write_vt(cp[k]), {
|
||||
o[o.length] = (writextag('property', write_vt(cp[k], true), {
|
||||
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
|
||||
'pid': pid,
|
||||
'name': escapexml(k)
|
||||
|
@ -7457,6 +7475,7 @@ var HTML_ = (function() {
|
|||
sp.t = cell && cell.t || 'z';
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>';
|
||||
sp.id = (o.id || "sjs") + "-" + coord;
|
||||
if(sp.t != "z") { sp.v = cell.v; if(cell.z != null) sp.z = cell.z; }
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
var preamble = "<tr>";
|
||||
|
@ -7479,8 +7498,8 @@ var HTML_ = (function() {
|
|||
for(var R = r.s.r; R <= r.e.r; ++R) out.push(make_html_row(ws, r, R, o));
|
||||
out.push("</table>" + footer);
|
||||
return out.join("");
|
||||
}
|
||||
|
||||
}
|
||||
return {
|
||||
to_workbook: html_to_book,
|
||||
to_sheet: html_to_sheet,
|
||||
|
@ -7512,7 +7531,8 @@ function parse_dom_table(table/*:HTMLElement*/, _opts/*:?any*/)/*:Worksheet*/ {
|
|||
for(_C = C = 0; _C < elts.length; ++_C) {
|
||||
var elt/*:HTMLTableCellElement*/ = elts[_C];
|
||||
if (opts.display && is_dom_element_hidden(elt)) continue;
|
||||
var v/*:string*/ = htmldecode(elt.innerHTML);
|
||||
var v/*:string*/ = elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);
|
||||
var z/*:string*/ = elt.getAttribute('z');
|
||||
for(midx = 0; midx < merges.length; ++midx) {
|
||||
var m/*:Range*/ = merges[midx];
|
||||
if(m.s.c == C && m.s.r <= R && R <= m.e.r) { C = m.e.c+1; midx = -1; }
|
||||
|
@ -7534,7 +7554,8 @@ function parse_dom_table(table/*:HTMLElement*/, _opts/*:?any*/)/*:Worksheet*/ {
|
|||
o.z = opts.dateNF || SSF._table[14];
|
||||
}
|
||||
}
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o; }
|
||||
if(o.z === undefined && z != null) o.z = z;
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o;}
|
||||
else ws[encode_cell({c:C, r:R})] = o;
|
||||
if(range.e.c < C) range.e.c = C;
|
||||
C += CS;
|
||||
|
@ -8675,7 +8696,7 @@ if(typeof CFB !== "undefined") XLSX.CFB = CFB;
|
|||
/*:: 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 if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
|
||||
else make_xlsx_lib(XLSX);
|
||||
/*exported XLS, ODS */
|
||||
var XLS = XLSX, ODS = XLSX;
|
||||
|
|
41
xlsx.mini.js
41
xlsx.mini.js
|
@ -3086,9 +3086,12 @@ function writextag(f,g,h) { return '<' + f + ((h != null) ? wxt_helper(h) : "")
|
|||
|
||||
function write_w3cdtf(d, t) { try { return d.toISOString().replace(/\.\d*/,""); } catch(e) { if(t) throw e; } return ""; }
|
||||
|
||||
function write_vt(s) {
|
||||
function write_vt(s, xlsx) {
|
||||
switch(typeof s) {
|
||||
case 'string': return writextag('vt:lpwstr', escapexml(s));
|
||||
case 'string':
|
||||
var o = writextag('vt:lpwstr', escapexml(s));
|
||||
if(xlsx) o = o.replace(/"/g, "_x0022_");
|
||||
return o;
|
||||
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', escapexml(String(s)));
|
||||
case 'boolean': return writextag('vt:bool',s?'true':'false');
|
||||
}
|
||||
|
@ -3488,8 +3491,23 @@ function fix_col(cstr) { return cstr.replace(/^([A-Z])/,"$$$1"); }
|
|||
function unfix_col(cstr) { return cstr.replace(/^\$([A-Z])/,"$1"); }
|
||||
|
||||
function split_cell(cstr) { return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(","); }
|
||||
function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
//function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
||||
function decode_cell(cstr) {
|
||||
var R = 0, C = 0;
|
||||
for(var i = 0; i < cstr.length; ++i) {
|
||||
var cc = cstr.charCodeAt(i);
|
||||
if(cc >= 48 && cc <= 57) R = 10 * R + (cc - 48);
|
||||
else if(cc >= 65 && cc <= 90) C = 26 * C + (cc - 64);
|
||||
}
|
||||
return { c: C - 1, r:R - 1 };
|
||||
}
|
||||
//function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
||||
function encode_cell(cell) {
|
||||
var col = cell.c + 1;
|
||||
var s="";
|
||||
for(; col; col=((col-1)/26)|0) s = String.fromCharCode(((col-1)%26) + 65) + s;
|
||||
return s + (cell.r + 1);
|
||||
}
|
||||
function decode_range(range) { var x =range.split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }
|
||||
function encode_range(cs,ce) {
|
||||
if(typeof ce === 'undefined' || typeof ce === 'number') {
|
||||
|
@ -4433,7 +4451,7 @@ function parse_ext_props(data, p, opts) {
|
|||
EXT_PROPS.forEach(function(f) {
|
||||
var xml = (data.match(matchtag(f[0]))||[])[1];
|
||||
switch(f[2]) {
|
||||
case "string": p[f[1]] = unescapexml(xml||""); break;
|
||||
case "string": if(xml) p[f[1]] = unescapexml(xml); break;
|
||||
case "bool": p[f[1]] = xml === "true"; break;
|
||||
case "raw":
|
||||
var cur = data.match(new RegExp("<" + f[0] + "[^>]*>([\\s\\S]*?)<\/" + f[0] + ">"));
|
||||
|
@ -4534,7 +4552,7 @@ function write_cust_props(cp) {
|
|||
if(!cp) return o.join("");
|
||||
var pid = 1;
|
||||
keys(cp).forEach(function custprop(k) { ++pid;
|
||||
o[o.length] = (writextag('property', write_vt(cp[k]), {
|
||||
o[o.length] = (writextag('property', write_vt(cp[k], true), {
|
||||
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
|
||||
'pid': pid,
|
||||
'name': escapexml(k)
|
||||
|
@ -7365,6 +7383,7 @@ var HTML_ = (function() {
|
|||
sp.t = cell && cell.t || 'z';
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>';
|
||||
sp.id = (o.id || "sjs") + "-" + coord;
|
||||
if(sp.t != "z") { sp.v = cell.v; if(cell.z != null) sp.z = cell.z; }
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
var preamble = "<tr>";
|
||||
|
@ -7387,8 +7406,8 @@ var HTML_ = (function() {
|
|||
for(var R = r.s.r; R <= r.e.r; ++R) out.push(make_html_row(ws, r, R, o));
|
||||
out.push("</table>" + footer);
|
||||
return out.join("");
|
||||
}
|
||||
|
||||
}
|
||||
return {
|
||||
to_workbook: html_to_book,
|
||||
to_sheet: html_to_sheet,
|
||||
|
@ -7420,7 +7439,8 @@ function parse_dom_table(table, _opts) {
|
|||
for(_C = C = 0; _C < elts.length; ++_C) {
|
||||
var elt = elts[_C];
|
||||
if (opts.display && is_dom_element_hidden(elt)) continue;
|
||||
var v = htmldecode(elt.innerHTML);
|
||||
var v = elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);
|
||||
var z = elt.getAttribute('z');
|
||||
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; }
|
||||
|
@ -7442,7 +7462,8 @@ function parse_dom_table(table, _opts) {
|
|||
o.z = opts.dateNF || SSF._table[14];
|
||||
}
|
||||
}
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o; }
|
||||
if(o.z === undefined && z != null) o.z = z;
|
||||
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o;}
|
||||
else ws[encode_cell({c:C, r:R})] = o;
|
||||
if(range.e.c < C) range.e.c = C;
|
||||
C += CS;
|
||||
|
@ -8570,7 +8591,7 @@ if(typeof CFB !== "undefined") XLSX.CFB = CFB;
|
|||
/*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 if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; });
|
||||
else make_xlsx_lib(XLSX);
|
||||
/*exported XLS, ODS */
|
||||
var XLS = XLSX, ODS = XLSX;
|
||||
|
|
Loading…
Reference in New Issue