version bump 0.14.2: comment xml (fixes #1468)

This commit is contained in:
SheetJS 2019-04-01 10:25:15 -04:00
parent ca22658b8c
commit 0c36667c0c
26 changed files with 340 additions and 244 deletions

@ -21,8 +21,6 @@ enhancements, additional features like styling, and dedicated support.
[**Issues and Bug Reports**](https://github.com/sheetjs/js-xlsx/issues)
[**Other General Support Issues**](https://discourse.sheetjs.com)
[**File format support for known spreadsheet data formats:**](#file-formats)
<details>
@ -43,7 +41,6 @@ enhancements, additional features like styling, and dedicated support.
[![Coverage Status](http://img.shields.io/coveralls/SheetJS/js-xlsx/master.svg)](https://coveralls.io/r/SheetJS/js-xlsx?branch=master)
[![Dependencies Status](https://david-dm.org/sheetjs/js-xlsx/status.svg)](https://david-dm.org/sheetjs/js-xlsx)
[![npm Downloads](https://img.shields.io/npm/dt/xlsx.svg)](https://npmjs.org/package/xlsx)
[![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/js-xlsx)](https://ghit.me/repo/sheetjs/js-xlsx)
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx)
## Table of Contents

@ -1 +1 @@
XLSX.version = '0.14.1';
XLSX.version = '0.14.2';

@ -114,7 +114,7 @@ function sheet_add_aoa(_ws/*:?Worksheet*/, data/*:AOA*/, opts/*:?any*/)/*:Worksh
if(data[R][C] && typeof data[R][C] === 'object' && !Array.isArray(data[R][C]) && !(data[R][C] instanceof Date)) cell = data[R][C];
else {
if(Array.isArray(cell.v)) { cell.f = data[R][C][1]; cell.v = cell.v[0]; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.cellStubs) continue; else cell.t = 'z'; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.sheetStubs) continue; else cell.t = 'z'; }
else if(typeof cell.v === 'number') cell.t = 'n';
else if(typeof cell.v === 'boolean') cell.t = 'b';
else if(cell.v instanceof Date) {

@ -20,10 +20,10 @@ function parse_comments(zip, dirComments, sheets, sheetRels, opts) {
function insertCommentsIntoSheet(sheetName, sheet, comments/*:Array<RawComment>*/) {
var dense = Array.isArray(sheet);
var cell/*:Cell*/, r;
var cell/*:Cell*/;
comments.forEach(function(comment) {
var r = decode_cell(comment.ref);
if(dense) {
r = decode_cell(comment.ref);
if(!sheet[r.r]) sheet[r.r] = [];
cell = sheet[r.r][r.c];
} else cell = sheet[comment.ref];
@ -32,11 +32,10 @@ function insertCommentsIntoSheet(sheetName, sheet, comments/*:Array<RawComment>*
if(dense) sheet[r.r][r.c] = cell;
else sheet[comment.ref] = cell;
var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");
var thisCell = decode_cell(comment.ref);
if(range.s.r > thisCell.r) range.s.r = thisCell.r;
if(range.e.r < thisCell.r) range.e.r = thisCell.r;
if(range.s.c > thisCell.c) range.s.c = thisCell.c;
if(range.e.c < thisCell.c) range.e.c = thisCell.c;
if(range.s.r > r.r) range.s.r = r.r;
if(range.e.r < r.r) range.e.r = r.r;
if(range.s.c > r.c) range.s.c = r.c;
if(range.e.c < r.c) range.e.c = r.c;
var encoded = encode_range(range);
if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded;
}

@ -47,7 +47,7 @@ function write_comments_xml(data/*::, opts*/) {
d[1].forEach(function(c) {
/* 18.7.3 CT_Comment */
o.push('<comment ref="' + d[0] + '" authorId="' + iauthor.indexOf(escapexml(c.a)) + '"><text>');
o.push(writetag("t", c.t == null ? "" : c.t));
o.push(writetag("t", c.t == null ? "" : escapexml(c.t)));
o.push('</text></comment>');
});
});

@ -6,7 +6,7 @@ var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
var sheetdataregex = /<(?:\w+:)?sheetData>([\s\S]*)<\/(?:\w+:)?sheetData>/;
var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
var dimregex = /"(\w*:\w*)"/;
var colregex = /<(?:\w:)?col[^>]*[\/]?>/g;
var colregex = /<(?:\w:)?col\b[^>]*[\/]?>/g;
var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g;
var sheetprregex = /<(?:\w:)?sheetPr(?:[^>a-z][^>]*)?\/>/;
@ -448,10 +448,10 @@ function write_ws_xml_data(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workbook
row = rows[R];
if(row.hidden) params.hidden = 1;
height = -1;
if (row.hpx) height = px2pt(row.hpx);
else if (row.hpt) height = row.hpt;
if (height > -1) { params.ht = height; params.customHeight = 1; }
if (row.level) { params.outlineLevel = row.level; }
if(row.hpx) height = px2pt(row.hpx);
else if(row.hpt) height = row.hpt;
if(height > -1) { params.ht = height; params.customHeight = 1; }
if(row.level) { params.outlineLevel = row.level; }
}
o[o.length] = (writextag('row', r.join(""), params));
}

@ -83,6 +83,7 @@ function parse_wb_xml(data, opts)/*:WorkbookFile*/ {
dname.Name = utf8read(y.name);
if(y.comment) dname.Comment = y.comment;
if(y.localSheetId) dname.Sheet = +y.localSheetId;
if(parsexmlbool(y.hidden||"0")) dname.Hidden = true;
dnstart = idx + x.length;
} break;
case '</definedName>': {
@ -184,11 +185,14 @@ function write_wb_xml(wb/*:Workbook*//*::, opts:?WriteOpts*/)/*:string*/ {
o[o.length] = (writextag('workbookPr', null, workbookPr));
/* workbookProtection */
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
var i = 0;
/* bookViews */
o[o.length] = "<sheets>";
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
for(var i = 0; i != wb.SheetNames.length; ++i) {
for(i = 0; i != wb.SheetNames.length; ++i) {
var sht = ({name:escapexml(wb.SheetNames[i].slice(0,31))}/*:any*/);
sht.sheetId = ""+(i+1);
sht["r:id"] = "rId"+(i+1);
@ -209,8 +213,9 @@ function write_wb_xml(wb/*:Workbook*//*::, opts:?WriteOpts*/)/*:string*/ {
var d/*:any*/ = {name:n.Name};
if(n.Comment) d.comment = n.Comment;
if(n.Sheet != null) d.localSheetId = ""+n.Sheet;
if(n.Hidden) d.hidden = "1";
if(!n.Ref) return;
o[o.length] = writextag('definedName', String(n.Ref), d);
o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "&lt;").replace(/>/g, "&gt;"), d);
});
o[o.length] = "</definedNames>";
}

@ -86,6 +86,7 @@ function parse_BrtName(data, length, opts) {
/* [MS-XLSB] 2.1.7.61 Workbook */
function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
var state/*:Array<string>*/ = [];
var pass = false;
if(!opts) opts = {};
@ -161,18 +162,20 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
state.push(R_n); pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */ break;
case 0x0026: /* 'BrtACEnd' */ break;
state.pop(); pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); pass = true; break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); pass = false; break;
case 0x0010: /* 'BrtFRTArchID$' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
else if(!pass || (opts.WTF && state[state.length-1] != "BrtACBegin" && state[state.length-1] != "BrtFRTBegin")) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);

@ -265,7 +265,8 @@ function parse_workbook(blob, options/*:ParseOpts*/)/*:Workbook*/ {
case 'WsBool':
if(val.fDialog) out["!type"] = "dialog";
break; // TODO
case 'XF': XFs.push(val); break;
case 'XF':
XFs.push(val); break;
case 'ExtSST': break; // TODO
case 'BookExt': break; // TODO
case 'RichTextStream': break;

@ -828,6 +828,9 @@ var XLSBRecordEnum = {
/*::[*/0x085D/*::]*/: { n:"BrtModelTimeGroupingCalcCol" },
/*::[*/0x0C00/*::]*/: { n:"BrtUid" },
/*::[*/0x0C01/*::]*/: { n:"BrtRevisionPtr" },
/*::[*/0x13e7/*::]*/: { n:"BrtBeginCalcFeatures" },
/*::[*/0x13e8/*::]*/: { n:"BrtEndCalcFeatures" },
/*::[*/0x13e9/*::]*/: { n:"BrtCalcFeature" },
/*::[*/0xFFFF/*::]*/: { n:"" }
};

@ -1,16 +1,17 @@
/* OpenDocument */
var parse_content_xml = (function() {
/* 6.1.2 White Space Characters */
var parse_text_p = function(text/*:string*//*::, tag*/)/*:string*/ {
return unescapexml(text
var parse_text_p = function(text/*:string*//*::, tag*/)/*:Array<any>*/ {
/* 6.1.2 White Space Characters */
var fixed = text
.replace(/[\t\r\n]/g, " ").trim().replace(/ +/g, " ")
.replace(/<text:s\/>/g," ")
.replace(/<text:s text:c="(\d+)"\/>/g, function($$,$1) { return Array(parseInt($1,10)+1).join(" "); })
.replace(/<text:tab[^>]*\/>/g,"\t")
.replace(/<text:line-break\/>/g,"\n")
.replace(/<[^>]*>/g,"")
);
.replace(/<text:line-break\/>/g,"\n");
var v = unescapexml(fixed.replace(/<[^>]*>/g,""));
return [v];
};
var number_formats = {
@ -42,6 +43,7 @@ var parse_content_xml = (function() {
var Rn, q/*:: :any = ({t:"", v:null, z:null, w:"",c:[],}:any)*/;
var ctag = ({value:""}/*:any*/);
var textp = "", textpidx = 0, textptag/*:: = {}*/;
var textR = [];
var R = -1, C = -1, range = {s: {r:1000000,c:10000000}, e: {r:0, c:0}};
var row_ol = 0;
var number_format_map = {};
@ -97,11 +99,12 @@ var parse_content_xml = (function() {
if(rowpeat < 10) for(i = 0; i < rowpeat; ++i) if(row_ol > 0) rowinfo[R + i] = {level: row_ol};
C = -1; break;
case 'covered-table-cell': // 9.1.5 <table:covered-table-cell>
++C;
if(Rn[1] !== '/') ++C;
if(opts.sheetStubs) {
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = {t:'z'}; }
else ws[encode_cell({r:R,c:C})] = {t:'z'};
}
textp = ""; textR = [];
break; /* stub */
case 'table-cell': case '数据':
if(Rn[0].charAt(Rn[0].length-2) === '/') {
@ -170,13 +173,14 @@ var parse_content_xml = (function() {
default:
if(q.t === 'string' || q.t === 'text' || !q.t) {
q.t = 's';
if(ctag['string-value'] != null) textp = unescapexml(ctag['string-value']);
if(ctag['string-value'] != null) { textp = unescapexml(ctag['string-value']); textR = []; }
} else throw new Error('Unsupported value type ' + q.t);
}
} else {
isstub = false;
if(q.t === 's') {
q.v = textp || '';
if(textR.length) q.R = textR;
isstub = textpidx == 0;
}
if(atag.Target) q.l = atag;
@ -201,7 +205,7 @@ var parse_content_xml = (function() {
colpeat = parseInt(ctag['number-columns-repeated']||"1", 10);
C += colpeat-1; colpeat = 0;
q = {/*:: t:"", v:null, z:null, w:"",c:[]*/};
textp = "";
textp = ""; textR = [];
}
atag = ({}/*:any*/);
break; // 9.1.4 <table:table-cell>
@ -221,12 +225,13 @@ var parse_content_xml = (function() {
if(Rn[1]==='/'){
if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;
comment.t = textp;
if(textR.length) comment.R = textR;
comment.a = creator;
comments.push(comment);
}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') {state.push([Rn[3], false]);}
creator = ""; creatoridx = 0;
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'creator': // 4.3.2.7 <dc:creator>
@ -253,7 +258,7 @@ var parse_content_xml = (function() {
case 'chart': // TODO
if(Rn[1]==='/'){if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') state.push([Rn[3], false]);
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'scientific-number': // TODO: <number:scientific-number>
@ -282,7 +287,8 @@ var parse_content_xml = (function() {
case 'default-style': // TODO: <style:default-style>
case 'page-layout': break; // TODO: <style:page-layout>
case 'style': break; // 16.2 <style:style>
case 'style': // 16.2 <style:style>
break;
case 'map': break; // 16.3 <style:map>
case 'font-face': break; // 16.21 <style:font-face>
@ -374,8 +380,10 @@ var parse_content_xml = (function() {
case 'line-break': break; // 6.1.5 <text:line-break>
case 'span': break; // 6.1.7 <text:span>
case 'p': case '文本串': // 5.1.3 <text:p>
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) textp = (textp.length > 0 ? textp + "\n" : "") + parse_text_p(str.slice(textpidx,Rn.index), textptag);
else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) {
var ptp = parse_text_p(str.slice(textpidx,Rn.index), textptag);
textp = (textp.length > 0 ? textp + "\n" : "") + ptp[0];
} else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
break; // <text:p>
case 's': break; // <text:s>

@ -75,14 +75,16 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
if(ws) {
var comments = ws['!comments'];
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];

@ -3,7 +3,7 @@ DUKTAPE_VER=2.2.0
if [ ! -e duktape-$DUKTAPE_VER ]; then
if [ ! -e duktape-$DUKTAPE_VER.tar ]; then
if [ ! -e duktape-$DUKTAPE_VER.tar.xz ]; then
curl -O http://duktape.org/duktape-$DUKTAPE_VER.tar.xz
curl -O https://duktape.org/duktape-$DUKTAPE_VER.tar.xz
fi
xz -d duktape-$DUKTAPE_VER.tar.xz
fi

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

97
dist/xlsx.extendscript.js generated vendored

@ -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.14.1';
XLSX.version = '0.14.2';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -12756,7 +12756,7 @@ function sheet_add_aoa(_ws, data, opts) {
if(data[R][C] && typeof data[R][C] === 'object' && !Array.isArray(data[R][C]) && !(data[R][C] instanceof Date)) cell = data[R][C];
else {
if(Array.isArray(cell.v)) { cell.f = data[R][C][1]; cell.v = cell.v[0]; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.cellStubs) continue; else cell.t = 'z'; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.sheetStubs) continue; else cell.t = 'z'; }
else if(typeof cell.v === 'number') cell.t = 'n';
else if(typeof cell.v === 'boolean') cell.t = 'b';
else if(cell.v instanceof Date) {
@ -19115,10 +19115,10 @@ function parse_comments(zip, dirComments, sheets, sheetRels, opts) {
function insertCommentsIntoSheet(sheetName, sheet, comments) {
var dense = Array.isArray(sheet);
var cell, r;
var cell;
comments.forEach(function(comment) {
var r = decode_cell(comment.ref);
if(dense) {
r = decode_cell(comment.ref);
if(!sheet[r.r]) sheet[r.r] = [];
cell = sheet[r.r][r.c];
} else cell = sheet[comment.ref];
@ -19127,11 +19127,10 @@ function insertCommentsIntoSheet(sheetName, sheet, comments) {
if(dense) sheet[r.r][r.c] = cell;
else sheet[comment.ref] = cell;
var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");
var thisCell = decode_cell(comment.ref);
if(range.s.r > thisCell.r) range.s.r = thisCell.r;
if(range.e.r < thisCell.r) range.e.r = thisCell.r;
if(range.s.c > thisCell.c) range.s.c = thisCell.c;
if(range.e.c < thisCell.c) range.e.c = thisCell.c;
if(range.s.r > r.r) range.s.r = r.r;
if(range.e.r < r.r) range.e.r = r.r;
if(range.s.c > r.c) range.s.c = r.c;
if(range.e.c < r.c) range.e.c = r.c;
var encoded = encode_range(range);
if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded;
}
@ -19192,7 +19191,7 @@ function write_comments_xml(data) {
d[1].forEach(function(c) {
/* 18.7.3 CT_Comment */
o.push('<comment ref="' + d[0] + '" authorId="' + iauthor.indexOf(escapexml(c.a)) + '"><text>');
o.push(writetag("t", c.t == null ? "" : c.t));
o.push(writetag("t", c.t == null ? "" : escapexml(c.t)));
o.push('</text></comment>');
});
});
@ -21946,7 +21945,7 @@ var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
var sheetdataregex = /<(?:\w+:)?sheetData>([\s\S]*)<\/(?:\w+:)?sheetData>/;
var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
var dimregex = /"(\w*:\w*)"/;
var colregex = /<(?:\w:)?col[^>]*[\/]?>/g;
var colregex = /<(?:\w:)?col\b[^>]*[\/]?>/g;
var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g;
var sheetprregex = /<(?:\w:)?sheetPr(?:[^>a-z][^>]*)?\/>/;
@ -22388,10 +22387,10 @@ function write_ws_xml_data(ws, opts, idx, wb) {
row = rows[R];
if(row.hidden) params.hidden = 1;
height = -1;
if (row.hpx) height = px2pt(row.hpx);
else if (row.hpt) height = row.hpt;
if (height > -1) { params.ht = height; params.customHeight = 1; }
if (row.level) { params.outlineLevel = row.level; }
if(row.hpx) height = px2pt(row.hpx);
else if(row.hpt) height = row.hpt;
if(height > -1) { params.ht = height; params.customHeight = 1; }
if(row.level) { params.outlineLevel = row.level; }
}
o[o.length] = (writextag('row', r.join(""), params));
}
@ -23773,6 +23772,7 @@ function parse_wb_xml(data, opts) {
dname.Name = utf8read(y.name);
if(y.comment) dname.Comment = y.comment;
if(y.localSheetId) dname.Sheet = +y.localSheetId;
if(parsexmlbool(y.hidden||"0")) dname.Hidden = true;
dnstart = idx + x.length;
} break;
case '</definedName>': {
@ -23872,11 +23872,14 @@ if(wb.Workbook.WBProps.CodeName) { workbookPr.codeName = wb.Workbook.WBProps.Cod
o[o.length] = (writextag('workbookPr', null, workbookPr));
/* workbookProtection */
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
var i = 0;
/* bookViews */
o[o.length] = "<sheets>";
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
for(var i = 0; i != wb.SheetNames.length; ++i) {
for(i = 0; i != wb.SheetNames.length; ++i) {
var sht = ({name:escapexml(wb.SheetNames[i].slice(0,31))});
sht.sheetId = ""+(i+1);
sht["r:id"] = "rId"+(i+1);
@ -23897,8 +23900,9 @@ if(wb.Workbook.WBProps.CodeName) { workbookPr.codeName = wb.Workbook.WBProps.Cod
var d = {name:n.Name};
if(n.Comment) d.comment = n.Comment;
if(n.Sheet != null) d.localSheetId = ""+n.Sheet;
if(n.Hidden) d.hidden = "1";
if(!n.Ref) return;
o[o.length] = writextag('definedName', String(n.Ref), d);
o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "&lt;").replace(/>/g, "&gt;"), d);
});
o[o.length] = "</definedNames>";
}
@ -24005,6 +24009,7 @@ function parse_BrtName(data, length, opts) {
/* [MS-XLSB] 2.1.7.61 Workbook */
function parse_wb_bin(data, opts) {
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
var state = [];
var pass = false;
if(!opts) opts = {};
@ -24080,18 +24085,20 @@ function parse_wb_bin(data, opts) {
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
state.push(R_n); pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */ break;
case 0x0026: /* 'BrtACEnd' */ break;
state.pop(); pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); pass = true; break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); pass = false; break;
case 0x0010: /* 'BrtFRTArchID$' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
else if(!pass || (opts.WTF && state[state.length-1] != "BrtACBegin" && state[state.length-1] != "BrtFRTBegin")) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
@ -25705,7 +25712,8 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
case 'WsBool':
if(val.fDialog) out["!type"] = "dialog";
break; // TODO
case 'XF': XFs.push(val); break;
case 'XF':
XFs.push(val); break;
case 'ExtSST': break; // TODO
case 'BookExt': break; // TODO
case 'RichTextStream': break;
@ -27223,6 +27231,9 @@ var XLSBRecordEnum = {
0x085D: { n:"BrtModelTimeGroupingCalcCol" },
0x0C00: { n:"BrtUid" },
0x0C01: { n:"BrtRevisionPtr" },
0x13e7: { n:"BrtBeginCalcFeatures" },
0x13e8: { n:"BrtEndCalcFeatures" },
0x13e9: { n:"BrtCalcFeature" },
0xFFFF: { n:"" }
};
@ -28176,16 +28187,17 @@ function get_get_computed_style_function(element) {
/* OpenDocument */
var parse_content_xml = (function() {
/* 6.1.2 White Space Characters */
var parse_text_p = function(text) {
return unescapexml(text
/* 6.1.2 White Space Characters */
var fixed = text
.replace(/[\t\r\n]/g, " ").trim().replace(/ +/g, " ")
.replace(/<text:s\/>/g," ")
.replace(/<text:s text:c="(\d+)"\/>/g, function($$,$1) { return Array(parseInt($1,10)+1).join(" "); })
.replace(/<text:tab[^>]*\/>/g,"\t")
.replace(/<text:line-break\/>/g,"\n")
.replace(/<[^>]*>/g,"")
);
.replace(/<text:line-break\/>/g,"\n");
var v = unescapexml(fixed.replace(/<[^>]*>/g,""));
return [v];
};
var number_formats = {
@ -28217,6 +28229,7 @@ var parse_content_xml = (function() {
var Rn, q;
var ctag = ({value:""});
var textp = "", textpidx = 0, textptag;
var textR = [];
var R = -1, C = -1, range = {s: {r:1000000,c:10000000}, e: {r:0, c:0}};
var row_ol = 0;
var number_format_map = {};
@ -28272,11 +28285,12 @@ var parse_content_xml = (function() {
if(rowpeat < 10) for(i = 0; i < rowpeat; ++i) if(row_ol > 0) rowinfo[R + i] = {level: row_ol};
C = -1; break;
case 'covered-table-cell': // 9.1.5 <table:covered-table-cell>
++C;
if(Rn[1] !== '/') ++C;
if(opts.sheetStubs) {
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = {t:'z'}; }
else ws[encode_cell({r:R,c:C})] = {t:'z'};
}
textp = ""; textR = [];
break; /* stub */
case 'table-cell': case '数据':
if(Rn[0].charAt(Rn[0].length-2) === '/') {
@ -28345,13 +28359,14 @@ var parse_content_xml = (function() {
default:
if(q.t === 'string' || q.t === 'text' || !q.t) {
q.t = 's';
if(ctag['string-value'] != null) textp = unescapexml(ctag['string-value']);
if(ctag['string-value'] != null) { textp = unescapexml(ctag['string-value']); textR = []; }
} else throw new Error('Unsupported value type ' + q.t);
}
} else {
isstub = false;
if(q.t === 's') {
q.v = textp || '';
if(textR.length) q.R = textR;
isstub = textpidx == 0;
}
if(atag.Target) q.l = atag;
@ -28376,7 +28391,7 @@ var parse_content_xml = (function() {
colpeat = parseInt(ctag['number-columns-repeated']||"1", 10);
C += colpeat-1; colpeat = 0;
q = {};
textp = "";
textp = ""; textR = [];
}
atag = ({});
break; // 9.1.4 <table:table-cell>
@ -28396,12 +28411,13 @@ var parse_content_xml = (function() {
if(Rn[1]==='/'){
if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;
comment.t = textp;
if(textR.length) comment.R = textR;
comment.a = creator;
comments.push(comment);
}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') {state.push([Rn[3], false]);}
creator = ""; creatoridx = 0;
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'creator': // 4.3.2.7 <dc:creator>
@ -28428,7 +28444,7 @@ var parse_content_xml = (function() {
case 'chart': // TODO
if(Rn[1]==='/'){if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') state.push([Rn[3], false]);
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'scientific-number': // TODO: <number:scientific-number>
@ -28457,7 +28473,8 @@ var parse_content_xml = (function() {
case 'default-style': // TODO: <style:default-style>
case 'page-layout': break; // TODO: <style:page-layout>
case 'style': break; // 16.2 <style:style>
case 'style': // 16.2 <style:style>
break;
case 'map': break; // 16.3 <style:map>
case 'font-face': break; // 16.21 <style:font-face>
@ -28549,8 +28566,10 @@ var parse_content_xml = (function() {
case 'line-break': break; // 6.1.5 <text:line-break>
case 'span': break; // 6.1.7 <text:span>
case 'p': case '文本串': // 5.1.3 <text:p>
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) textp = (textp.length > 0 ? textp + "\n" : "") + parse_text_p(str.slice(textpidx,Rn.index), textptag);
else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) {
var ptp = parse_text_p(str.slice(textpidx,Rn.index), textptag);
textp = (textp.length > 0 ? textp + "\n" : "") + ptp[0];
} else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
break; // <text:p>
case 's': break; // <text:s>
@ -29319,14 +29338,16 @@ f = "docProps/app.xml";
if(ws) {
var comments = ws['!comments'];
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];

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

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

97
dist/xlsx.js generated vendored

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.1';
XLSX.version = '0.14.2';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -3600,7 +3600,7 @@ function sheet_add_aoa(_ws, data, opts) {
if(data[R][C] && typeof data[R][C] === 'object' && !Array.isArray(data[R][C]) && !(data[R][C] instanceof Date)) cell = data[R][C];
else {
if(Array.isArray(cell.v)) { cell.f = data[R][C][1]; cell.v = cell.v[0]; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.cellStubs) continue; else cell.t = 'z'; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.sheetStubs) continue; else cell.t = 'z'; }
else if(typeof cell.v === 'number') cell.t = 'n';
else if(typeof cell.v === 'boolean') cell.t = 'b';
else if(cell.v instanceof Date) {
@ -9959,10 +9959,10 @@ function parse_comments(zip, dirComments, sheets, sheetRels, opts) {
function insertCommentsIntoSheet(sheetName, sheet, comments) {
var dense = Array.isArray(sheet);
var cell, r;
var cell;
comments.forEach(function(comment) {
var r = decode_cell(comment.ref);
if(dense) {
r = decode_cell(comment.ref);
if(!sheet[r.r]) sheet[r.r] = [];
cell = sheet[r.r][r.c];
} else cell = sheet[comment.ref];
@ -9971,11 +9971,10 @@ function insertCommentsIntoSheet(sheetName, sheet, comments) {
if(dense) sheet[r.r][r.c] = cell;
else sheet[comment.ref] = cell;
var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");
var thisCell = decode_cell(comment.ref);
if(range.s.r > thisCell.r) range.s.r = thisCell.r;
if(range.e.r < thisCell.r) range.e.r = thisCell.r;
if(range.s.c > thisCell.c) range.s.c = thisCell.c;
if(range.e.c < thisCell.c) range.e.c = thisCell.c;
if(range.s.r > r.r) range.s.r = r.r;
if(range.e.r < r.r) range.e.r = r.r;
if(range.s.c > r.c) range.s.c = r.c;
if(range.e.c < r.c) range.e.c = r.c;
var encoded = encode_range(range);
if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded;
}
@ -10036,7 +10035,7 @@ function write_comments_xml(data) {
d[1].forEach(function(c) {
/* 18.7.3 CT_Comment */
o.push('<comment ref="' + d[0] + '" authorId="' + iauthor.indexOf(escapexml(c.a)) + '"><text>');
o.push(writetag("t", c.t == null ? "" : c.t));
o.push(writetag("t", c.t == null ? "" : escapexml(c.t)));
o.push('</text></comment>');
});
});
@ -12790,7 +12789,7 @@ var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
var sheetdataregex = /<(?:\w+:)?sheetData>([\s\S]*)<\/(?:\w+:)?sheetData>/;
var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
var dimregex = /"(\w*:\w*)"/;
var colregex = /<(?:\w:)?col[^>]*[\/]?>/g;
var colregex = /<(?:\w:)?col\b[^>]*[\/]?>/g;
var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g;
var sheetprregex = /<(?:\w:)?sheetPr(?:[^>a-z][^>]*)?\/>/;
@ -13232,10 +13231,10 @@ function write_ws_xml_data(ws, opts, idx, wb) {
row = rows[R];
if(row.hidden) params.hidden = 1;
height = -1;
if (row.hpx) height = px2pt(row.hpx);
else if (row.hpt) height = row.hpt;
if (height > -1) { params.ht = height; params.customHeight = 1; }
if (row.level) { params.outlineLevel = row.level; }
if(row.hpx) height = px2pt(row.hpx);
else if(row.hpt) height = row.hpt;
if(height > -1) { params.ht = height; params.customHeight = 1; }
if(row.level) { params.outlineLevel = row.level; }
}
o[o.length] = (writextag('row', r.join(""), params));
}
@ -14617,6 +14616,7 @@ function parse_wb_xml(data, opts) {
dname.Name = utf8read(y.name);
if(y.comment) dname.Comment = y.comment;
if(y.localSheetId) dname.Sheet = +y.localSheetId;
if(parsexmlbool(y.hidden||"0")) dname.Hidden = true;
dnstart = idx + x.length;
} break;
case '</definedName>': {
@ -14716,11 +14716,14 @@ if(wb.Workbook.WBProps.CodeName) { workbookPr.codeName = wb.Workbook.WBProps.Cod
o[o.length] = (writextag('workbookPr', null, workbookPr));
/* workbookProtection */
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
var i = 0;
/* bookViews */
o[o.length] = "<sheets>";
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
for(var i = 0; i != wb.SheetNames.length; ++i) {
for(i = 0; i != wb.SheetNames.length; ++i) {
var sht = ({name:escapexml(wb.SheetNames[i].slice(0,31))});
sht.sheetId = ""+(i+1);
sht["r:id"] = "rId"+(i+1);
@ -14741,8 +14744,9 @@ if(wb.Workbook.WBProps.CodeName) { workbookPr.codeName = wb.Workbook.WBProps.Cod
var d = {name:n.Name};
if(n.Comment) d.comment = n.Comment;
if(n.Sheet != null) d.localSheetId = ""+n.Sheet;
if(n.Hidden) d.hidden = "1";
if(!n.Ref) return;
o[o.length] = writextag('definedName', String(n.Ref), d);
o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "&lt;").replace(/>/g, "&gt;"), d);
});
o[o.length] = "</definedNames>";
}
@ -14849,6 +14853,7 @@ function parse_BrtName(data, length, opts) {
/* [MS-XLSB] 2.1.7.61 Workbook */
function parse_wb_bin(data, opts) {
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
var state = [];
var pass = false;
if(!opts) opts = {};
@ -14924,18 +14929,20 @@ function parse_wb_bin(data, opts) {
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
state.push(R_n); pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */ break;
case 0x0026: /* 'BrtACEnd' */ break;
state.pop(); pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); pass = true; break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); pass = false; break;
case 0x0010: /* 'BrtFRTArchID$' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
else if(!pass || (opts.WTF && state[state.length-1] != "BrtACBegin" && state[state.length-1] != "BrtFRTBegin")) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
@ -16549,7 +16556,8 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
case 'WsBool':
if(val.fDialog) out["!type"] = "dialog";
break; // TODO
case 'XF': XFs.push(val); break;
case 'XF':
XFs.push(val); break;
case 'ExtSST': break; // TODO
case 'BookExt': break; // TODO
case 'RichTextStream': break;
@ -18067,6 +18075,9 @@ var XLSBRecordEnum = {
0x085D: { n:"BrtModelTimeGroupingCalcCol" },
0x0C00: { n:"BrtUid" },
0x0C01: { n:"BrtRevisionPtr" },
0x13e7: { n:"BrtBeginCalcFeatures" },
0x13e8: { n:"BrtEndCalcFeatures" },
0x13e9: { n:"BrtCalcFeature" },
0xFFFF: { n:"" }
};
@ -19020,16 +19031,17 @@ function get_get_computed_style_function(element) {
/* OpenDocument */
var parse_content_xml = (function() {
/* 6.1.2 White Space Characters */
var parse_text_p = function(text) {
return unescapexml(text
/* 6.1.2 White Space Characters */
var fixed = text
.replace(/[\t\r\n]/g, " ").trim().replace(/ +/g, " ")
.replace(/<text:s\/>/g," ")
.replace(/<text:s text:c="(\d+)"\/>/g, function($$,$1) { return Array(parseInt($1,10)+1).join(" "); })
.replace(/<text:tab[^>]*\/>/g,"\t")
.replace(/<text:line-break\/>/g,"\n")
.replace(/<[^>]*>/g,"")
);
.replace(/<text:line-break\/>/g,"\n");
var v = unescapexml(fixed.replace(/<[^>]*>/g,""));
return [v];
};
var number_formats = {
@ -19061,6 +19073,7 @@ var parse_content_xml = (function() {
var Rn, q;
var ctag = ({value:""});
var textp = "", textpidx = 0, textptag;
var textR = [];
var R = -1, C = -1, range = {s: {r:1000000,c:10000000}, e: {r:0, c:0}};
var row_ol = 0;
var number_format_map = {};
@ -19116,11 +19129,12 @@ var parse_content_xml = (function() {
if(rowpeat < 10) for(i = 0; i < rowpeat; ++i) if(row_ol > 0) rowinfo[R + i] = {level: row_ol};
C = -1; break;
case 'covered-table-cell': // 9.1.5 <table:covered-table-cell>
++C;
if(Rn[1] !== '/') ++C;
if(opts.sheetStubs) {
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = {t:'z'}; }
else ws[encode_cell({r:R,c:C})] = {t:'z'};
}
textp = ""; textR = [];
break; /* stub */
case 'table-cell': case '数据':
if(Rn[0].charAt(Rn[0].length-2) === '/') {
@ -19189,13 +19203,14 @@ var parse_content_xml = (function() {
default:
if(q.t === 'string' || q.t === 'text' || !q.t) {
q.t = 's';
if(ctag['string-value'] != null) textp = unescapexml(ctag['string-value']);
if(ctag['string-value'] != null) { textp = unescapexml(ctag['string-value']); textR = []; }
} else throw new Error('Unsupported value type ' + q.t);
}
} else {
isstub = false;
if(q.t === 's') {
q.v = textp || '';
if(textR.length) q.R = textR;
isstub = textpidx == 0;
}
if(atag.Target) q.l = atag;
@ -19220,7 +19235,7 @@ var parse_content_xml = (function() {
colpeat = parseInt(ctag['number-columns-repeated']||"1", 10);
C += colpeat-1; colpeat = 0;
q = {};
textp = "";
textp = ""; textR = [];
}
atag = ({});
break; // 9.1.4 <table:table-cell>
@ -19240,12 +19255,13 @@ var parse_content_xml = (function() {
if(Rn[1]==='/'){
if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;
comment.t = textp;
if(textR.length) comment.R = textR;
comment.a = creator;
comments.push(comment);
}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') {state.push([Rn[3], false]);}
creator = ""; creatoridx = 0;
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'creator': // 4.3.2.7 <dc:creator>
@ -19272,7 +19288,7 @@ var parse_content_xml = (function() {
case 'chart': // TODO
if(Rn[1]==='/'){if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') state.push([Rn[3], false]);
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'scientific-number': // TODO: <number:scientific-number>
@ -19301,7 +19317,8 @@ var parse_content_xml = (function() {
case 'default-style': // TODO: <style:default-style>
case 'page-layout': break; // TODO: <style:page-layout>
case 'style': break; // 16.2 <style:style>
case 'style': // 16.2 <style:style>
break;
case 'map': break; // 16.3 <style:map>
case 'font-face': break; // 16.21 <style:font-face>
@ -19393,8 +19410,10 @@ var parse_content_xml = (function() {
case 'line-break': break; // 6.1.5 <text:line-break>
case 'span': break; // 6.1.7 <text:span>
case 'p': case '文本串': // 5.1.3 <text:p>
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) textp = (textp.length > 0 ? textp + "\n" : "") + parse_text_p(str.slice(textpidx,Rn.index), textptag);
else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) {
var ptp = parse_text_p(str.slice(textpidx,Rn.index), textptag);
textp = (textp.length > 0 ? textp + "\n" : "") + ptp[0];
} else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
break; // <text:p>
case 's': break; // <text:s>
@ -20163,14 +20182,16 @@ f = "docProps/app.xml";
if(ws) {
var comments = ws['!comments'];
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];

26
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

@ -21,8 +21,6 @@ enhancements, additional features like styling, and dedicated support.
[**Issues and Bug Reports**](https://github.com/sheetjs/js-xlsx/issues)
[**Other General Support Issues**](https://discourse.sheetjs.com)
[**File format support for known spreadsheet data formats:**](#file-formats)
<details>
@ -43,6 +41,5 @@ enhancements, additional features like styling, and dedicated support.
[![Coverage Status](http://img.shields.io/coveralls/SheetJS/js-xlsx/master.svg)](https://coveralls.io/r/SheetJS/js-xlsx?branch=master)
[![Dependencies Status](https://david-dm.org/sheetjs/js-xlsx/status.svg)](https://david-dm.org/sheetjs/js-xlsx)
[![npm Downloads](https://img.shields.io/npm/dt/xlsx.svg)](https://npmjs.org/package/xlsx)
[![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/js-xlsx)](https://ghit.me/repo/sheetjs/js-xlsx)
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx)

@ -21,8 +21,6 @@ enhancements, additional features like styling, and dedicated support.
[**Issues and Bug Reports**](https://github.com/sheetjs/js-xlsx/issues)
[**Other General Support Issues**](https://discourse.sheetjs.com)
[**File format support for known spreadsheet data formats:**](#file-formats)
@ -40,7 +38,6 @@ enhancements, additional features like styling, and dedicated support.
[![Coverage Status](http://img.shields.io/coveralls/SheetJS/js-xlsx/master.svg)](https://coveralls.io/r/SheetJS/js-xlsx?branch=master)
[![Dependencies Status](https://david-dm.org/sheetjs/js-xlsx/status.svg)](https://david-dm.org/sheetjs/js-xlsx)
[![npm Downloads](https://img.shields.io/npm/dt/xlsx.svg)](https://npmjs.org/package/xlsx)
[![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/js-xlsx)](https://ghit.me/repo/sheetjs/js-xlsx)
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx)
## Table of Contents

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

@ -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.14.1';
XLSX.version = '0.14.2';
var current_codepage = 1200, current_ansi = 1252;
/*:: declare var cptable:any; */
/*global cptable:true, window */
@ -3692,7 +3692,7 @@ function sheet_add_aoa(_ws/*:?Worksheet*/, data/*:AOA*/, opts/*:?any*/)/*:Worksh
if(data[R][C] && typeof data[R][C] === 'object' && !Array.isArray(data[R][C]) && !(data[R][C] instanceof Date)) cell = data[R][C];
else {
if(Array.isArray(cell.v)) { cell.f = data[R][C][1]; cell.v = cell.v[0]; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.cellStubs) continue; else cell.t = 'z'; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.sheetStubs) continue; else cell.t = 'z'; }
else if(typeof cell.v === 'number') cell.t = 'n';
else if(typeof cell.v === 'boolean') cell.t = 'b';
else if(cell.v instanceof Date) {
@ -10059,10 +10059,10 @@ function parse_comments(zip, dirComments, sheets, sheetRels, opts) {
function insertCommentsIntoSheet(sheetName, sheet, comments/*:Array<RawComment>*/) {
var dense = Array.isArray(sheet);
var cell/*:Cell*/, r;
var cell/*:Cell*/;
comments.forEach(function(comment) {
var r = decode_cell(comment.ref);
if(dense) {
r = decode_cell(comment.ref);
if(!sheet[r.r]) sheet[r.r] = [];
cell = sheet[r.r][r.c];
} else cell = sheet[comment.ref];
@ -10071,11 +10071,10 @@ function insertCommentsIntoSheet(sheetName, sheet, comments/*:Array<RawComment>*
if(dense) sheet[r.r][r.c] = cell;
else sheet[comment.ref] = cell;
var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");
var thisCell = decode_cell(comment.ref);
if(range.s.r > thisCell.r) range.s.r = thisCell.r;
if(range.e.r < thisCell.r) range.e.r = thisCell.r;
if(range.s.c > thisCell.c) range.s.c = thisCell.c;
if(range.e.c < thisCell.c) range.e.c = thisCell.c;
if(range.s.r > r.r) range.s.r = r.r;
if(range.e.r < r.r) range.e.r = r.r;
if(range.s.c > r.c) range.s.c = r.c;
if(range.e.c < r.c) range.e.c = r.c;
var encoded = encode_range(range);
if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded;
}
@ -10136,7 +10135,7 @@ function write_comments_xml(data/*::, opts*/) {
d[1].forEach(function(c) {
/* 18.7.3 CT_Comment */
o.push('<comment ref="' + d[0] + '" authorId="' + iauthor.indexOf(escapexml(c.a)) + '"><text>');
o.push(writetag("t", c.t == null ? "" : c.t));
o.push(writetag("t", c.t == null ? "" : escapexml(c.t)));
o.push('</text></comment>');
});
});
@ -12891,7 +12890,7 @@ var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
var sheetdataregex = /<(?:\w+:)?sheetData>([\s\S]*)<\/(?:\w+:)?sheetData>/;
var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
var dimregex = /"(\w*:\w*)"/;
var colregex = /<(?:\w:)?col[^>]*[\/]?>/g;
var colregex = /<(?:\w:)?col\b[^>]*[\/]?>/g;
var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g;
var sheetprregex = /<(?:\w:)?sheetPr(?:[^>a-z][^>]*)?\/>/;
@ -13333,10 +13332,10 @@ function write_ws_xml_data(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workbook
row = rows[R];
if(row.hidden) params.hidden = 1;
height = -1;
if (row.hpx) height = px2pt(row.hpx);
else if (row.hpt) height = row.hpt;
if (height > -1) { params.ht = height; params.customHeight = 1; }
if (row.level) { params.outlineLevel = row.level; }
if(row.hpx) height = px2pt(row.hpx);
else if(row.hpt) height = row.hpt;
if(height > -1) { params.ht = height; params.customHeight = 1; }
if(row.level) { params.outlineLevel = row.level; }
}
o[o.length] = (writextag('row', r.join(""), params));
}
@ -14719,6 +14718,7 @@ function parse_wb_xml(data, opts)/*:WorkbookFile*/ {
dname.Name = utf8read(y.name);
if(y.comment) dname.Comment = y.comment;
if(y.localSheetId) dname.Sheet = +y.localSheetId;
if(parsexmlbool(y.hidden||"0")) dname.Hidden = true;
dnstart = idx + x.length;
} break;
case '</definedName>': {
@ -14820,11 +14820,14 @@ function write_wb_xml(wb/*:Workbook*//*::, opts:?WriteOpts*/)/*:string*/ {
o[o.length] = (writextag('workbookPr', null, workbookPr));
/* workbookProtection */
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
var i = 0;
/* bookViews */
o[o.length] = "<sheets>";
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
for(var i = 0; i != wb.SheetNames.length; ++i) {
for(i = 0; i != wb.SheetNames.length; ++i) {
var sht = ({name:escapexml(wb.SheetNames[i].slice(0,31))}/*:any*/);
sht.sheetId = ""+(i+1);
sht["r:id"] = "rId"+(i+1);
@ -14845,8 +14848,9 @@ function write_wb_xml(wb/*:Workbook*//*::, opts:?WriteOpts*/)/*:string*/ {
var d/*:any*/ = {name:n.Name};
if(n.Comment) d.comment = n.Comment;
if(n.Sheet != null) d.localSheetId = ""+n.Sheet;
if(n.Hidden) d.hidden = "1";
if(!n.Ref) return;
o[o.length] = writextag('definedName', String(n.Ref), d);
o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "&lt;").replace(/>/g, "&gt;"), d);
});
o[o.length] = "</definedNames>";
}
@ -14953,6 +14957,7 @@ function parse_BrtName(data, length, opts) {
/* [MS-XLSB] 2.1.7.61 Workbook */
function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
var state/*:Array<string>*/ = [];
var pass = false;
if(!opts) opts = {};
@ -15028,18 +15033,20 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
state.push(R_n); pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */ break;
case 0x0026: /* 'BrtACEnd' */ break;
state.pop(); pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); pass = true; break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); pass = false; break;
case 0x0010: /* 'BrtFRTArchID$' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
else if(!pass || (opts.WTF && state[state.length-1] != "BrtACBegin" && state[state.length-1] != "BrtFRTBegin")) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
@ -16663,7 +16670,8 @@ function parse_workbook(blob, options/*:ParseOpts*/)/*:Workbook*/ {
case 'WsBool':
if(val.fDialog) out["!type"] = "dialog";
break; // TODO
case 'XF': XFs.push(val); break;
case 'XF':
XFs.push(val); break;
case 'ExtSST': break; // TODO
case 'BookExt': break; // TODO
case 'RichTextStream': break;
@ -18182,6 +18190,9 @@ var XLSBRecordEnum = {
/*::[*/0x085D/*::]*/: { n:"BrtModelTimeGroupingCalcCol" },
/*::[*/0x0C00/*::]*/: { n:"BrtUid" },
/*::[*/0x0C01/*::]*/: { n:"BrtRevisionPtr" },
/*::[*/0x13e7/*::]*/: { n:"BrtBeginCalcFeatures" },
/*::[*/0x13e8/*::]*/: { n:"BrtEndCalcFeatures" },
/*::[*/0x13e9/*::]*/: { n:"BrtCalcFeature" },
/*::[*/0xFFFF/*::]*/: { n:"" }
};
@ -19136,16 +19147,17 @@ function get_get_computed_style_function(element/*:HTMLElement*/)/*:?function*/
/* OpenDocument */
var parse_content_xml = (function() {
/* 6.1.2 White Space Characters */
var parse_text_p = function(text/*:string*//*::, tag*/)/*:string*/ {
return unescapexml(text
var parse_text_p = function(text/*:string*//*::, tag*/)/*:Array<any>*/ {
/* 6.1.2 White Space Characters */
var fixed = text
.replace(/[\t\r\n]/g, " ").trim().replace(/ +/g, " ")
.replace(/<text:s\/>/g," ")
.replace(/<text:s text:c="(\d+)"\/>/g, function($$,$1) { return Array(parseInt($1,10)+1).join(" "); })
.replace(/<text:tab[^>]*\/>/g,"\t")
.replace(/<text:line-break\/>/g,"\n")
.replace(/<[^>]*>/g,"")
);
.replace(/<text:line-break\/>/g,"\n");
var v = unescapexml(fixed.replace(/<[^>]*>/g,""));
return [v];
};
var number_formats = {
@ -19177,6 +19189,7 @@ var parse_content_xml = (function() {
var Rn, q/*:: :any = ({t:"", v:null, z:null, w:"",c:[],}:any)*/;
var ctag = ({value:""}/*:any*/);
var textp = "", textpidx = 0, textptag/*:: = {}*/;
var textR = [];
var R = -1, C = -1, range = {s: {r:1000000,c:10000000}, e: {r:0, c:0}};
var row_ol = 0;
var number_format_map = {};
@ -19232,11 +19245,12 @@ var parse_content_xml = (function() {
if(rowpeat < 10) for(i = 0; i < rowpeat; ++i) if(row_ol > 0) rowinfo[R + i] = {level: row_ol};
C = -1; break;
case 'covered-table-cell': // 9.1.5 <table:covered-table-cell>
++C;
if(Rn[1] !== '/') ++C;
if(opts.sheetStubs) {
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = {t:'z'}; }
else ws[encode_cell({r:R,c:C})] = {t:'z'};
}
textp = ""; textR = [];
break; /* stub */
case 'table-cell': case '数据':
if(Rn[0].charAt(Rn[0].length-2) === '/') {
@ -19305,13 +19319,14 @@ var parse_content_xml = (function() {
default:
if(q.t === 'string' || q.t === 'text' || !q.t) {
q.t = 's';
if(ctag['string-value'] != null) textp = unescapexml(ctag['string-value']);
if(ctag['string-value'] != null) { textp = unescapexml(ctag['string-value']); textR = []; }
} else throw new Error('Unsupported value type ' + q.t);
}
} else {
isstub = false;
if(q.t === 's') {
q.v = textp || '';
if(textR.length) q.R = textR;
isstub = textpidx == 0;
}
if(atag.Target) q.l = atag;
@ -19336,7 +19351,7 @@ var parse_content_xml = (function() {
colpeat = parseInt(ctag['number-columns-repeated']||"1", 10);
C += colpeat-1; colpeat = 0;
q = {/*:: t:"", v:null, z:null, w:"",c:[]*/};
textp = "";
textp = ""; textR = [];
}
atag = ({}/*:any*/);
break; // 9.1.4 <table:table-cell>
@ -19356,12 +19371,13 @@ var parse_content_xml = (function() {
if(Rn[1]==='/'){
if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;
comment.t = textp;
if(textR.length) comment.R = textR;
comment.a = creator;
comments.push(comment);
}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') {state.push([Rn[3], false]);}
creator = ""; creatoridx = 0;
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'creator': // 4.3.2.7 <dc:creator>
@ -19388,7 +19404,7 @@ var parse_content_xml = (function() {
case 'chart': // TODO
if(Rn[1]==='/'){if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') state.push([Rn[3], false]);
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'scientific-number': // TODO: <number:scientific-number>
@ -19417,7 +19433,8 @@ var parse_content_xml = (function() {
case 'default-style': // TODO: <style:default-style>
case 'page-layout': break; // TODO: <style:page-layout>
case 'style': break; // 16.2 <style:style>
case 'style': // 16.2 <style:style>
break;
case 'map': break; // 16.3 <style:map>
case 'font-face': break; // 16.21 <style:font-face>
@ -19509,8 +19526,10 @@ var parse_content_xml = (function() {
case 'line-break': break; // 6.1.5 <text:line-break>
case 'span': break; // 6.1.7 <text:span>
case 'p': case '文本串': // 5.1.3 <text:p>
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) textp = (textp.length > 0 ? textp + "\n" : "") + parse_text_p(str.slice(textpidx,Rn.index), textptag);
else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) {
var ptp = parse_text_p(str.slice(textpidx,Rn.index), textptag);
textp = (textp.length > 0 ? textp + "\n" : "") + ptp[0];
} else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
break; // <text:p>
case 's': break; // <text:s>
@ -20284,14 +20303,16 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
if(ws) {
var comments = ws['!comments'];
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];

97
xlsx.js generated

@ -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.14.1';
XLSX.version = '0.14.2';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -3600,7 +3600,7 @@ function sheet_add_aoa(_ws, data, opts) {
if(data[R][C] && typeof data[R][C] === 'object' && !Array.isArray(data[R][C]) && !(data[R][C] instanceof Date)) cell = data[R][C];
else {
if(Array.isArray(cell.v)) { cell.f = data[R][C][1]; cell.v = cell.v[0]; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.cellStubs) continue; else cell.t = 'z'; }
if(cell.v === null) { if(cell.f) cell.t = 'n'; else if(!o.sheetStubs) continue; else cell.t = 'z'; }
else if(typeof cell.v === 'number') cell.t = 'n';
else if(typeof cell.v === 'boolean') cell.t = 'b';
else if(cell.v instanceof Date) {
@ -9959,10 +9959,10 @@ function parse_comments(zip, dirComments, sheets, sheetRels, opts) {
function insertCommentsIntoSheet(sheetName, sheet, comments) {
var dense = Array.isArray(sheet);
var cell, r;
var cell;
comments.forEach(function(comment) {
var r = decode_cell(comment.ref);
if(dense) {
r = decode_cell(comment.ref);
if(!sheet[r.r]) sheet[r.r] = [];
cell = sheet[r.r][r.c];
} else cell = sheet[comment.ref];
@ -9971,11 +9971,10 @@ function insertCommentsIntoSheet(sheetName, sheet, comments) {
if(dense) sheet[r.r][r.c] = cell;
else sheet[comment.ref] = cell;
var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");
var thisCell = decode_cell(comment.ref);
if(range.s.r > thisCell.r) range.s.r = thisCell.r;
if(range.e.r < thisCell.r) range.e.r = thisCell.r;
if(range.s.c > thisCell.c) range.s.c = thisCell.c;
if(range.e.c < thisCell.c) range.e.c = thisCell.c;
if(range.s.r > r.r) range.s.r = r.r;
if(range.e.r < r.r) range.e.r = r.r;
if(range.s.c > r.c) range.s.c = r.c;
if(range.e.c < r.c) range.e.c = r.c;
var encoded = encode_range(range);
if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded;
}
@ -10036,7 +10035,7 @@ function write_comments_xml(data) {
d[1].forEach(function(c) {
/* 18.7.3 CT_Comment */
o.push('<comment ref="' + d[0] + '" authorId="' + iauthor.indexOf(escapexml(c.a)) + '"><text>');
o.push(writetag("t", c.t == null ? "" : c.t));
o.push(writetag("t", c.t == null ? "" : escapexml(c.t)));
o.push('</text></comment>');
});
});
@ -12790,7 +12789,7 @@ var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
var sheetdataregex = /<(?:\w+:)?sheetData>([\s\S]*)<\/(?:\w+:)?sheetData>/;
var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
var dimregex = /"(\w*:\w*)"/;
var colregex = /<(?:\w:)?col[^>]*[\/]?>/g;
var colregex = /<(?:\w:)?col\b[^>]*[\/]?>/g;
var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g;
var sheetprregex = /<(?:\w:)?sheetPr(?:[^>a-z][^>]*)?\/>/;
@ -13232,10 +13231,10 @@ function write_ws_xml_data(ws, opts, idx, wb) {
row = rows[R];
if(row.hidden) params.hidden = 1;
height = -1;
if (row.hpx) height = px2pt(row.hpx);
else if (row.hpt) height = row.hpt;
if (height > -1) { params.ht = height; params.customHeight = 1; }
if (row.level) { params.outlineLevel = row.level; }
if(row.hpx) height = px2pt(row.hpx);
else if(row.hpt) height = row.hpt;
if(height > -1) { params.ht = height; params.customHeight = 1; }
if(row.level) { params.outlineLevel = row.level; }
}
o[o.length] = (writextag('row', r.join(""), params));
}
@ -14617,6 +14616,7 @@ function parse_wb_xml(data, opts) {
dname.Name = utf8read(y.name);
if(y.comment) dname.Comment = y.comment;
if(y.localSheetId) dname.Sheet = +y.localSheetId;
if(parsexmlbool(y.hidden||"0")) dname.Hidden = true;
dnstart = idx + x.length;
} break;
case '</definedName>': {
@ -14716,11 +14716,14 @@ if(wb.Workbook.WBProps.CodeName) { workbookPr.codeName = wb.Workbook.WBProps.Cod
o[o.length] = (writextag('workbookPr', null, workbookPr));
/* workbookProtection */
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
var i = 0;
/* bookViews */
o[o.length] = "<sheets>";
var sheets = wb.Workbook && wb.Workbook.Sheets || [];
for(var i = 0; i != wb.SheetNames.length; ++i) {
for(i = 0; i != wb.SheetNames.length; ++i) {
var sht = ({name:escapexml(wb.SheetNames[i].slice(0,31))});
sht.sheetId = ""+(i+1);
sht["r:id"] = "rId"+(i+1);
@ -14741,8 +14744,9 @@ if(wb.Workbook.WBProps.CodeName) { workbookPr.codeName = wb.Workbook.WBProps.Cod
var d = {name:n.Name};
if(n.Comment) d.comment = n.Comment;
if(n.Sheet != null) d.localSheetId = ""+n.Sheet;
if(n.Hidden) d.hidden = "1";
if(!n.Ref) return;
o[o.length] = writextag('definedName', String(n.Ref), d);
o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "&lt;").replace(/>/g, "&gt;"), d);
});
o[o.length] = "</definedNames>";
}
@ -14849,6 +14853,7 @@ function parse_BrtName(data, length, opts) {
/* [MS-XLSB] 2.1.7.61 Workbook */
function parse_wb_bin(data, opts) {
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
var state = [];
var pass = false;
if(!opts) opts = {};
@ -14924,18 +14929,20 @@ function parse_wb_bin(data, opts) {
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
state.push(R_n); pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */ break;
case 0x0026: /* 'BrtACEnd' */ break;
state.pop(); pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); pass = true; break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); pass = false; break;
case 0x0010: /* 'BrtFRTArchID$' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
else if(!pass || (opts.WTF && state[state.length-1] != "BrtACBegin" && state[state.length-1] != "BrtFRTBegin")) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
@ -16549,7 +16556,8 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
case 'WsBool':
if(val.fDialog) out["!type"] = "dialog";
break; // TODO
case 'XF': XFs.push(val); break;
case 'XF':
XFs.push(val); break;
case 'ExtSST': break; // TODO
case 'BookExt': break; // TODO
case 'RichTextStream': break;
@ -18067,6 +18075,9 @@ var XLSBRecordEnum = {
0x085D: { n:"BrtModelTimeGroupingCalcCol" },
0x0C00: { n:"BrtUid" },
0x0C01: { n:"BrtRevisionPtr" },
0x13e7: { n:"BrtBeginCalcFeatures" },
0x13e8: { n:"BrtEndCalcFeatures" },
0x13e9: { n:"BrtCalcFeature" },
0xFFFF: { n:"" }
};
@ -19020,16 +19031,17 @@ function get_get_computed_style_function(element) {
/* OpenDocument */
var parse_content_xml = (function() {
/* 6.1.2 White Space Characters */
var parse_text_p = function(text) {
return unescapexml(text
/* 6.1.2 White Space Characters */
var fixed = text
.replace(/[\t\r\n]/g, " ").trim().replace(/ +/g, " ")
.replace(/<text:s\/>/g," ")
.replace(/<text:s text:c="(\d+)"\/>/g, function($$,$1) { return Array(parseInt($1,10)+1).join(" "); })
.replace(/<text:tab[^>]*\/>/g,"\t")
.replace(/<text:line-break\/>/g,"\n")
.replace(/<[^>]*>/g,"")
);
.replace(/<text:line-break\/>/g,"\n");
var v = unescapexml(fixed.replace(/<[^>]*>/g,""));
return [v];
};
var number_formats = {
@ -19061,6 +19073,7 @@ var parse_content_xml = (function() {
var Rn, q;
var ctag = ({value:""});
var textp = "", textpidx = 0, textptag;
var textR = [];
var R = -1, C = -1, range = {s: {r:1000000,c:10000000}, e: {r:0, c:0}};
var row_ol = 0;
var number_format_map = {};
@ -19116,11 +19129,12 @@ var parse_content_xml = (function() {
if(rowpeat < 10) for(i = 0; i < rowpeat; ++i) if(row_ol > 0) rowinfo[R + i] = {level: row_ol};
C = -1; break;
case 'covered-table-cell': // 9.1.5 <table:covered-table-cell>
++C;
if(Rn[1] !== '/') ++C;
if(opts.sheetStubs) {
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = {t:'z'}; }
else ws[encode_cell({r:R,c:C})] = {t:'z'};
}
textp = ""; textR = [];
break; /* stub */
case 'table-cell': case '数据':
if(Rn[0].charAt(Rn[0].length-2) === '/') {
@ -19189,13 +19203,14 @@ var parse_content_xml = (function() {
default:
if(q.t === 'string' || q.t === 'text' || !q.t) {
q.t = 's';
if(ctag['string-value'] != null) textp = unescapexml(ctag['string-value']);
if(ctag['string-value'] != null) { textp = unescapexml(ctag['string-value']); textR = []; }
} else throw new Error('Unsupported value type ' + q.t);
}
} else {
isstub = false;
if(q.t === 's') {
q.v = textp || '';
if(textR.length) q.R = textR;
isstub = textpidx == 0;
}
if(atag.Target) q.l = atag;
@ -19220,7 +19235,7 @@ var parse_content_xml = (function() {
colpeat = parseInt(ctag['number-columns-repeated']||"1", 10);
C += colpeat-1; colpeat = 0;
q = {};
textp = "";
textp = ""; textR = [];
}
atag = ({});
break; // 9.1.4 <table:table-cell>
@ -19240,12 +19255,13 @@ var parse_content_xml = (function() {
if(Rn[1]==='/'){
if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;
comment.t = textp;
if(textR.length) comment.R = textR;
comment.a = creator;
comments.push(comment);
}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') {state.push([Rn[3], false]);}
creator = ""; creatoridx = 0;
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'creator': // 4.3.2.7 <dc:creator>
@ -19272,7 +19288,7 @@ var parse_content_xml = (function() {
case 'chart': // TODO
if(Rn[1]==='/'){if((tmp=state.pop())[0]!==Rn[3]) throw "Bad state: "+tmp;}
else if(Rn[0].charAt(Rn[0].length-2) !== '/') state.push([Rn[3], false]);
textp = ""; textpidx = 0;
textp = ""; textpidx = 0; textR = [];
break;
case 'scientific-number': // TODO: <number:scientific-number>
@ -19301,7 +19317,8 @@ var parse_content_xml = (function() {
case 'default-style': // TODO: <style:default-style>
case 'page-layout': break; // TODO: <style:page-layout>
case 'style': break; // 16.2 <style:style>
case 'style': // 16.2 <style:style>
break;
case 'map': break; // 16.3 <style:map>
case 'font-face': break; // 16.21 <style:font-face>
@ -19393,8 +19410,10 @@ var parse_content_xml = (function() {
case 'line-break': break; // 6.1.5 <text:line-break>
case 'span': break; // 6.1.7 <text:span>
case 'p': case '文本串': // 5.1.3 <text:p>
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) textp = (textp.length > 0 ? textp + "\n" : "") + parse_text_p(str.slice(textpidx,Rn.index), textptag);
else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
if(Rn[1]==='/' && (!ctag || !ctag['string-value'])) {
var ptp = parse_text_p(str.slice(textpidx,Rn.index), textptag);
textp = (textp.length > 0 ? textp + "\n" : "") + ptp[0];
} else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }
break; // <text:p>
case 's': break; // <text:s>
@ -20163,14 +20182,16 @@ f = "docProps/app.xml";
if(ws) {
var comments = ws['!comments'];
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];