提交 1988338d 编写于 作者: S SheetJS

version bump 0.10.6: encoding tweaks

- updated codepage to 1.9.0
- replaced \u2603 with \s\S (fixes #687 h/t @clgnik)
上级 56cf1926
...@@ -1165,6 +1165,11 @@ Max Digit Width is the width of the largest digit when rendered (generally the ...@@ -1165,6 +1165,11 @@ Max Digit Width is the width of the largest digit when rendered (generally the
"0" character is the widest). The internal width must be an integer multiple of "0" character is the widest). The internal width must be an integer multiple of
the the width divided by 256. ECMA-376 describes a formula for converting the the width divided by 256. ECMA-376 describes a formula for converting
between pixels and the internal width. This represents a hybrid approach. between pixels and the internal width. This represents a hybrid approach.
Read functions attempt to populate all three properties. Write functions will
try to cycle specified values to the desired type. In order to avoid potential
conflicts, manipulation should delete the other properties first. For example,
when changing the pixel width, delete the `wch` and `width` properties.
</details> </details>
<details> <details>
...@@ -1403,8 +1408,6 @@ The exported `read` and `readFile` functions accept an options argument: ...@@ -1403,8 +1408,6 @@ The exported `read` and `readFile` functions accept an options argument:
errors on single worksheets, allowing you to read from the worksheets that do errors on single worksheets, allowing you to read from the worksheets that do
parse properly. Setting `WTF:1` forces those errors to be thrown. parse properly. Setting `WTF:1` forces those errors to be thrown.
The defaults are enumerated in bits/84\_defaults.js
### Input Type ### Input Type
Strings can be interpreted in multiple ways. The `type` parameter for `read` Strings can be interpreted in multiple ways. The `type` parameter for `read`
......
XLSX.version = '0.10.5'; XLSX.version = '0.10.6';
...@@ -8,10 +8,22 @@ function reset_cp() { set_cp(1200); } ...@@ -8,10 +8,22 @@ function reset_cp() { set_cp(1200); }
var set_cp = function(cp) { current_codepage = cp; }; var set_cp = function(cp) { current_codepage = cp; };
function char_codes(data) { var o = []; for(var i = 0, len = data.length; i < len; ++i) o[i] = data.charCodeAt(i); return o; } function char_codes(data) { var o = []; for(var i = 0, len = data.length; i < len; ++i) o[i] = data.charCodeAt(i); return o; }
function utf16leread(data/*:string*/)/*:string*/ {
var o = [];
for(var i = 0; i < (data.length>>1); ++i) o[i] = String.fromCharCode(data.charCodeAt(2*i) + (data.charCodeAt(2*i+1)<<8));
return o.join("");
}
function utf16beread(data/*:string*/)/*:string*/ {
var o = [];
for(var i = 0; i < (data.length>>1); ++i) o[i] = String.fromCharCode(data.charCodeAt(2*i+1) + (data.charCodeAt(2*i)<<8));
return o.join("");
}
var debom = function(data/*:string*/)/*:string*/ { var debom = function(data/*:string*/)/*:string*/ {
var c1 = data.charCodeAt(0), c2 = data.charCodeAt(1); var c1 = data.charCodeAt(0), c2 = data.charCodeAt(1);
if(c1 == 0xFF && c2 == 0xFE) return data.substr(2); if(c1 == 0xFF && c2 == 0xFE) return utf16leread(data.substr(2));
if(c1 == 0xFE && c2 == 0xFF) return data.substr(2); if(c1 == 0xFE && c2 == 0xFF) return utf16beread(data.substr(2));
if(c1 == 0xFEFF) return data.substr(1); if(c1 == 0xFEFF) return data.substr(1);
return data; return data;
}; };
......
...@@ -128,7 +128,7 @@ var matchtag = (function() { ...@@ -128,7 +128,7 @@ var matchtag = (function() {
return function matchtag(f,g/*:?string*/)/*:RegExp*/ { return function matchtag(f,g/*:?string*/)/*:RegExp*/ {
var t = f+"|"+(g||""); var t = f+"|"+(g||"");
if(mtcache[t]) return mtcache[t]; if(mtcache[t]) return mtcache[t];
return (mtcache[t] = new RegExp('<(?:\\w+:)?'+f+'(?: xml:space="preserve")?(?:[^>]*)>([^\u2603]*)</(?:\\w+:)?'+f+'>',((g||"")/*:any*/))); return (mtcache[t] = new RegExp('<(?:\\w+:)?'+f+'(?: xml:space="preserve")?(?:[^>]*)>([\\s\\S]*?)</(?:\\w+:)?'+f+'>',((g||"")/*:any*/)));
}; };
})(); })();
......
...@@ -61,9 +61,9 @@ function parse_fontScheme(t, themes, opts) { } ...@@ -61,9 +61,9 @@ function parse_fontScheme(t, themes, opts) { }
/* 20.1.4.1.15 fmtScheme CT_StyleMatrix */ /* 20.1.4.1.15 fmtScheme CT_StyleMatrix */
function parse_fmtScheme(t, themes, opts) { } function parse_fmtScheme(t, themes, opts) { }
var clrsregex = /<a:clrScheme([^>]*)>[^\u2603]*<\/a:clrScheme>/; var clrsregex = /<a:clrScheme([^>]*)>[\s\S]*<\/a:clrScheme>/;
var fntsregex = /<a:fontScheme([^>]*)>[^\u2603]*<\/a:fontScheme>/; var fntsregex = /<a:fontScheme([^>]*)>[\s\S]*<\/a:fontScheme>/;
var fmtsregex = /<a:fmtScheme([^>]*)>[^\u2603]*<\/a:fmtScheme>/; var fmtsregex = /<a:fmtScheme([^>]*)>[\s\S]*<\/a:fmtScheme>/;
/* 20.1.6.10 themeElements CT_BaseStyles */ /* 20.1.6.10 themeElements CT_BaseStyles */
function parse_themeElements(data, themes, opts) { function parse_themeElements(data, themes, opts) {
...@@ -84,7 +84,7 @@ function parse_themeElements(data, themes, opts) { ...@@ -84,7 +84,7 @@ function parse_themeElements(data, themes, opts) {
}); });
} }
var themeltregex = /<a:themeElements([^>]*)>[^\u2603]*<\/a:themeElements>/; var themeltregex = /<a:themeElements([^>]*)>[\s\S]*<\/a:themeElements>/;
/* 14.2.7 Theme Part */ /* 14.2.7 Theme Part */
function parse_theme_xml(data/*:string*/, opts) { function parse_theme_xml(data/*:string*/, opts) {
......
...@@ -4,13 +4,13 @@ function parse_comments_xml(data/*:string*/, opts)/*:Array<Comment>*/ { ...@@ -4,13 +4,13 @@ function parse_comments_xml(data/*:string*/, opts)/*:Array<Comment>*/ {
if(data.match(/<(?:\w+:)?comments *\/>/)) return []; if(data.match(/<(?:\w+:)?comments *\/>/)) return [];
var authors = []; var authors = [];
var commentList = []; var commentList = [];
var authtag = data.match(/<(?:\w+:)?authors>([^\u2603]*)<\/(?:\w+:)?authors>/); var authtag = data.match(/<(?:\w+:)?authors>([\s\S]*)<\/(?:\w+:)?authors>/);
if(authtag && authtag[1]) authtag[1].split(/<\/\w*:?author>/).forEach(function(x) { if(authtag && authtag[1]) authtag[1].split(/<\/\w*:?author>/).forEach(function(x) {
if(x === "" || x.trim() === "") return; if(x === "" || x.trim() === "") return;
var a = x.match(/<(?:\w+:)?author[^>]*>(.*)/); var a = x.match(/<(?:\w+:)?author[^>]*>(.*)/);
if(a) authors.push(a[1]); if(a) authors.push(a[1]);
}); });
var cmnttag = data.match(/<(?:\w+:)?commentList>([^\u2603]*)<\/(?:\w+:)?commentList>/); var cmnttag = data.match(/<(?:\w+:)?commentList>([\s\S]*)<\/(?:\w+:)?commentList>/);
if(cmnttag && cmnttag[1]) cmnttag[1].split(/<\/\w*:?comment>/).forEach(function(x, index) { if(cmnttag && cmnttag[1]) cmnttag[1].split(/<\/\w*:?comment>/).forEach(function(x, index) {
if(x === "" || x.trim() === "") return; if(x === "" || x.trim() === "") return;
var cm = x.match(/<(?:\w+:)?comment[^>]*>/); var cm = x.match(/<(?:\w+:)?comment[^>]*>/);
...@@ -19,7 +19,7 @@ function parse_comments_xml(data/*:string*/, opts)/*:Array<Comment>*/ { ...@@ -19,7 +19,7 @@ function parse_comments_xml(data/*:string*/, opts)/*:Array<Comment>*/ {
var comment/*:Comment*/ = ({ author: y.authorId && authors[y.authorId] ? authors[y.authorId] : "sheetjsghost", ref: y.ref, guid: y.guid }/*:any*/); var comment/*:Comment*/ = ({ author: y.authorId && authors[y.authorId] ? authors[y.authorId] : "sheetjsghost", ref: y.ref, guid: y.guid }/*:any*/);
var cell = decode_cell(y.ref); var cell = decode_cell(y.ref);
if(opts.sheetRows && opts.sheetRows <= cell.r) return; if(opts.sheetRows && opts.sheetRows <= cell.r) return;
var textMatch = x.match(/<(?:\w+:)?text>([^\u2603]*)<\/(?:\w+:)?text>/); var textMatch = x.match(/<(?:\w+:)?text>([\s\S]*)<\/(?:\w+:)?text>/);
var rt = !!textMatch && !!textMatch[1] && parse_si(textMatch[1]) || {r:"",t:"",h:""}; var rt = !!textMatch && !!textMatch[1] && parse_si(textMatch[1]) || {r:"",t:"",h:""};
comment.r = rt.r; comment.r = rt.r;
if(rt.r == "<t></t>") rt.t = rt.h = ""; if(rt.r == "<t></t>") rt.t = rt.h = "";
......
...@@ -3,11 +3,11 @@ function parse_ws_xml_dim(ws, s) { ...@@ -3,11 +3,11 @@ function parse_ws_xml_dim(ws, s) {
if(d.s.r<=d.e.r && d.s.c<=d.e.c && d.s.r>=0 && d.s.c>=0) ws["!ref"] = encode_range(d); if(d.s.r<=d.e.r && d.s.c<=d.e.c && d.s.r>=0 && d.s.c>=0) ws["!ref"] = encode_range(d);
} }
var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g; var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
var sheetdataregex = /<(?:\w+:)?sheetData>([^\u2603]*)<\/(?:\w+:)?sheetData>/; var sheetdataregex = /<(?:\w+:)?sheetData>([\s\S]*)<\/(?:\w+:)?sheetData>/;
var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg; var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
var dimregex = /"(\w*:\w*)"/; var dimregex = /"(\w*:\w*)"/;
var colregex = /<(?:\w:)?col[^>]*[\/]?>/g; var colregex = /<(?:\w:)?col[^>]*[\/]?>/g;
var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([^\u2603]*)<\/(?:\w:)?autoFilter)>/g; var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g; var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g;
/* 18.3 Worksheets */ /* 18.3 Worksheets */
function parse_ws_xml(data/*:?string*/, opts, rels, wb, themes, styles)/*:Worksheet*/ { function parse_ws_xml(data/*:?string*/, opts, rels, wb, themes, styles)/*:Worksheet*/ {
......
...@@ -170,7 +170,8 @@ function xlml_normalize(d)/*:string*/ { ...@@ -170,7 +170,8 @@ function xlml_normalize(d)/*:string*/ {
/* UOS uses CJK in tags */ /* UOS uses CJK in tags */
var xlmlregex = /<(\/?)([^\s?>!\/:]*:|)([^\s?>]*[^\s?>\/])[^>]*>/mg; var xlmlregex = /<(\/?)([^\s?>!\/:]*:|)([^\s?>]*[^\s?>\/])[^>]*>/mg;
//var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg; //var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg;
function parse_xlml_xml(d, opts)/*:Workbook*/ { function parse_xlml_xml(d, _opts)/*:Workbook*/ {
var opts = _opts || {};
make_ssf(SSF); make_ssf(SSF);
var str = debom(xlml_normalize(d)); var str = debom(xlml_normalize(d));
if(opts && opts.type == 'binary' && typeof cptable !== 'undefined') str = cptable.utils.decode(65001, char_codes(str)); if(opts && opts.type == 'binary' && typeof cptable !== 'undefined') str = cptable.utils.decode(65001, char_codes(str));
...@@ -193,7 +194,7 @@ function parse_xlml_xml(d, opts)/*:Workbook*/ { ...@@ -193,7 +194,7 @@ function parse_xlml_xml(d, opts)/*:Workbook*/ {
var rowinfo = [], rowobj = {}; var rowinfo = [], rowobj = {};
var Workbook/*:WBWBProps*/ = ({ Sheets:[], WBProps:{date1904:false} }/*:any*/), wsprops = {}; var Workbook/*:WBWBProps*/ = ({ Sheets:[], WBProps:{date1904:false} }/*:any*/), wsprops = {};
xlmlregex.lastIndex = 0; xlmlregex.lastIndex = 0;
str = str.replace(/<!--([^\u2603]*?)-->/mg,""); str = str.replace(/<!--([\s\S]*?)-->/mg,"");
while((Rn = xlmlregex.exec(str))) switch(Rn[3]) { while((Rn = xlmlregex.exec(str))) switch(Rn[3]) {
case 'Data': case 'Data':
if(state[state.length-1][1]) break; if(state[state.length-1][1]) break;
......
...@@ -40,7 +40,7 @@ var parse_content_xml = (function() { ...@@ -40,7 +40,7 @@ var parse_content_xml = (function() {
var rept = 1, isstub = false; var rept = 1, isstub = false;
var i = 0; var i = 0;
xlmlregex.lastIndex = 0; xlmlregex.lastIndex = 0;
str = str.replace(/<!--([^\u2603]*?)-->/mg,"").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm,""); str = str.replace(/<!--([\s\S]*?)-->/mg,"").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm,"");
while((Rn = xlmlregex.exec(str))) switch((Rn[3]=Rn[3].replace(/_.*$/,""))) { while((Rn = xlmlregex.exec(str))) switch((Rn[3]=Rn[3].replace(/_.*$/,""))) {
case 'table': case '工作表': // 9.1.2 <table:table> case 'table': case '工作表': // 9.1.2 <table:table>
......
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
...@@ -25,7 +25,8 @@ CDNjs automatically pulls the latest version and makes all versions available at ...@@ -25,7 +25,8 @@ CDNjs automatically pulls the latest version and makes all versions available at
The `demos` directory includes sample projects for: The `demos` directory includes sample projects for:
- [`angular`](demos/angular/) - [`angular 1.x`](demos/angular/)
- [`angular 2.x / 4.x`](demos/angular2/)
- [`browserify`](demos/browserify/) - [`browserify`](demos/browserify/)
- [`Adobe ExtendScript`](demos/extendscript/) - [`Adobe ExtendScript`](demos/extendscript/)
- [`meteor`](demos/meteor/) - [`meteor`](demos/meteor/)
......
...@@ -38,6 +38,11 @@ Max Digit Width is the width of the largest digit when rendered (generally the ...@@ -38,6 +38,11 @@ Max Digit Width is the width of the largest digit when rendered (generally the
"0" character is the widest). The internal width must be an integer multiple of "0" character is the widest). The internal width must be an integer multiple of
the the width divided by 256. ECMA-376 describes a formula for converting the the width divided by 256. ECMA-376 describes a formula for converting
between pixels and the internal width. This represents a hybrid approach. between pixels and the internal width. This represents a hybrid approach.
Read functions attempt to populate all three properties. Write functions will
try to cycle specified values to the desired type. In order to avoid potential
conflicts, manipulation should delete the other properties first. For example,
when changing the pixel width, delete the `wch` and `width` properties.
</details> </details>
<details> <details>
......
...@@ -39,8 +39,6 @@ The exported `read` and `readFile` functions accept an options argument: ...@@ -39,8 +39,6 @@ The exported `read` and `readFile` functions accept an options argument:
errors on single worksheets, allowing you to read from the worksheets that do errors on single worksheets, allowing you to read from the worksheets that do
parse properly. Setting `WTF:1` forces those errors to be thrown. parse properly. Setting `WTF:1` forces those errors to be thrown.
The defaults are enumerated in bits/84\_defaults.js
### Input Type ### Input Type
Strings can be interpreted in multiple ways. The `type` parameter for `read` Strings can be interpreted in multiple ways. The `type` parameter for `read`
......
{ {
"name": "xlsx", "name": "xlsx",
"version": "0.10.5", "version": "0.10.6",
"author": "sheetjs", "author": "sheetjs",
"description": "Excel (XLSB/XLSX/XLS/XML) ODS and other spreadsheet format (CSV/DIF/DBF/SYLK) parser and writer", "description": "Excel (XLSB/XLSX/XLS/XML) ODS and other spreadsheet format (CSV/DIF/DBF/SYLK) parser and writer",
"keywords": [ "excel", "xls", "xlsx", "xlsb", "xlsm", "ods", "csv", "dbf", "dif", "sylk", "office", "spreadsheet" ], "keywords": [ "excel", "xls", "xlsx", "xlsb", "xlsm", "ods", "csv", "dbf", "dif", "sylk", "office", "spreadsheet" ],
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
"dependencies": { "dependencies": {
"exit-on-epipe":"~1.0.0", "exit-on-epipe":"~1.0.0",
"ssf":"~0.9.4", "ssf":"~0.9.4",
"codepage":"~1.8.0", "codepage":"~1.9.0",
"cfb":"~0.11.1", "cfb":"~0.11.1",
"crc-32":"~1.0.2", "crc-32":"~1.0.2",
"adler-32":"~1.0.0", "adler-32":"~1.0.0",
......
此差异由.gitattributes 抑制。
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"no-sparse-arrays": false, "no-sparse-arrays": false,
"only-arrow-functions": false, "only-arrow-functions": false,
"no-consecutive-blank-lines": false, "no-consecutive-blank-lines": false,
"prefer-conditional-expression": false,
"one-variable-per-declaration": false "one-variable-per-declaration": false
} }
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false */ /*global global, exports, module, require:false, process:false, Buffer:false */
var XLSX = {}; var XLSX = {};
(function make_xlsx(XLSX){ (function make_xlsx(XLSX){
XLSX.version = '0.10.5'; XLSX.version = '0.10.6';
var current_codepage = 1200; var current_codepage = 1200;
/*:: declare var cptable:any; */ /*:: declare var cptable:any; */
/*global cptable:true */ /*global cptable:true */
...@@ -17,10 +17,22 @@ function reset_cp() { set_cp(1200); } ...@@ -17,10 +17,22 @@ function reset_cp() { set_cp(1200); }
var set_cp = function(cp) { current_codepage = cp; }; var set_cp = function(cp) { current_codepage = cp; };
function char_codes(data) { var o = []; for(var i = 0, len = data.length; i < len; ++i) o[i] = data.charCodeAt(i); return o; } function char_codes(data) { var o = []; for(var i = 0, len = data.length; i < len; ++i) o[i] = data.charCodeAt(i); return o; }
function utf16leread(data/*:string*/)/*:string*/ {
var o = [];
for(var i = 0; i < (data.length>>1); ++i) o[i] = String.fromCharCode(data.charCodeAt(2*i) + (data.charCodeAt(2*i+1)<<8));
return o.join("");
}
function utf16beread(data/*:string*/)/*:string*/ {
var o = [];
for(var i = 0; i < (data.length>>1); ++i) o[i] = String.fromCharCode(data.charCodeAt(2*i+1) + (data.charCodeAt(2*i)<<8));
return o.join("");
}
var debom = function(data/*:string*/)/*:string*/ { var debom = function(data/*:string*/)/*:string*/ {
var c1 = data.charCodeAt(0), c2 = data.charCodeAt(1); var c1 = data.charCodeAt(0), c2 = data.charCodeAt(1);
if(c1 == 0xFF && c2 == 0xFE) return data.substr(2); if(c1 == 0xFF && c2 == 0xFE) return utf16leread(data.substr(2));
if(c1 == 0xFE && c2 == 0xFF) return data.substr(2); if(c1 == 0xFE && c2 == 0xFF) return utf16beread(data.substr(2));
if(c1 == 0xFEFF) return data.substr(1); if(c1 == 0xFEFF) return data.substr(1);
return data; return data;
}; };
...@@ -1763,7 +1775,7 @@ var matchtag = (function() { ...@@ -1763,7 +1775,7 @@ var matchtag = (function() {
return function matchtag(f,g/*:?string*/)/*:RegExp*/ { return function matchtag(f,g/*:?string*/)/*:RegExp*/ {
var t = f+"|"+(g||""); var t = f+"|"+(g||"");
if(mtcache[t]) return mtcache[t]; if(mtcache[t]) return mtcache[t];
return (mtcache[t] = new RegExp('<(?:\\w+:)?'+f+'(?: xml:space="preserve")?(?:[^>]*)>([^\u2603]*)</(?:\\w+:)?'+f+'>',((g||"")/*:any*/))); return (mtcache[t] = new RegExp('<(?:\\w+:)?'+f+'(?: xml:space="preserve")?(?:[^>]*)>([\\s\\S]*?)</(?:\\w+:)?'+f+'>',((g||"")/*:any*/)));
}; };
})(); })();
...@@ -7669,9 +7681,9 @@ function parse_fontScheme(t, themes, opts) { } ...@@ -7669,9 +7681,9 @@ function parse_fontScheme(t, themes, opts) { }
/* 20.1.4.1.15 fmtScheme CT_StyleMatrix */ /* 20.1.4.1.15 fmtScheme CT_StyleMatrix */
function parse_fmtScheme(t, themes, opts) { } function parse_fmtScheme(t, themes, opts) { }
var clrsregex = /<a:clrScheme([^>]*)>[^\u2603]*<\/a:clrScheme>/; var clrsregex = /<a:clrScheme([^>]*)>[\s\S]*<\/a:clrScheme>/;
var fntsregex = /<a:fontScheme([^>]*)>[^\u2603]*<\/a:fontScheme>/; var fntsregex = /<a:fontScheme([^>]*)>[\s\S]*<\/a:fontScheme>/;
var fmtsregex = /<a:fmtScheme([^>]*)>[^\u2603]*<\/a:fmtScheme>/; var fmtsregex = /<a:fmtScheme([^>]*)>[\s\S]*<\/a:fmtScheme>/;
/* 20.1.6.10 themeElements CT_BaseStyles */ /* 20.1.6.10 themeElements CT_BaseStyles */
function parse_themeElements(data, themes, opts) { function parse_themeElements(data, themes, opts) {
...@@ -7692,7 +7704,7 @@ function parse_themeElements(data, themes, opts) { ...@@ -7692,7 +7704,7 @@ function parse_themeElements(data, themes, opts) {
}); });
} }
var themeltregex = /<a:themeElements([^>]*)>[^\u2603]*<\/a:themeElements>/; var themeltregex = /<a:themeElements([^>]*)>[\s\S]*<\/a:themeElements>/;
/* 14.2.7 Theme Part */ /* 14.2.7 Theme Part */
function parse_theme_xml(data/*:string*/, opts) { function parse_theme_xml(data/*:string*/, opts) {
...@@ -8135,13 +8147,13 @@ function parse_comments_xml(data/*:string*/, opts)/*:Array<Comment>*/ { ...@@ -8135,13 +8147,13 @@ function parse_comments_xml(data/*:string*/, opts)/*:Array<Comment>*/ {
if(data.match(/<(?:\w+:)?comments *\/>/)) return []; if(data.match(/<(?:\w+:)?comments *\/>/)) return [];
var authors = []; var authors = [];
var commentList = []; var commentList = [];
var authtag = data.match(/<(?:\w+:)?authors>([^\u2603]*)<\/(?:\w+:)?authors>/); var authtag = data.match(/<(?:\w+:)?authors>([\s\S]*)<\/(?:\w+:)?authors>/);
if(authtag && authtag[1]) authtag[1].split(/<\/\w*:?author>/).forEach(function(x) { if(authtag && authtag[1]) authtag[1].split(/<\/\w*:?author>/).forEach(function(x) {
if(x === "" || x.trim() === "") return; if(x === "" || x.trim() === "") return;
var a = x.match(/<(?:\w+:)?author[^>]*>(.*)/); var a = x.match(/<(?:\w+:)?author[^>]*>(.*)/);
if(a) authors.push(a[1]); if(a) authors.push(a[1]);
}); });
var cmnttag = data.match(/<(?:\w+:)?commentList>([^\u2603]*)<\/(?:\w+:)?commentList>/); var cmnttag = data.match(/<(?:\w+:)?commentList>([\s\S]*)<\/(?:\w+:)?commentList>/);
if(cmnttag && cmnttag[1]) cmnttag[1].split(/<\/\w*:?comment>/).forEach(function(x, index) { if(cmnttag && cmnttag[1]) cmnttag[1].split(/<\/\w*:?comment>/).forEach(function(x, index) {
if(x === "" || x.trim() === "") return; if(x === "" || x.trim() === "") return;
var cm = x.match(/<(?:\w+:)?comment[^>]*>/); var cm = x.match(/<(?:\w+:)?comment[^>]*>/);
...@@ -8150,7 +8162,7 @@ function parse_comments_xml(data/*:string*/, opts)/*:Array<Comment>*/ { ...@@ -8150,7 +8162,7 @@ function parse_comments_xml(data/*:string*/, opts)/*:Array<Comment>*/ {
var comment/*:Comment*/ = ({ author: y.authorId && authors[y.authorId] ? authors[y.authorId] : "sheetjsghost", ref: y.ref, guid: y.guid }/*:any*/); var comment/*:Comment*/ = ({ author: y.authorId && authors[y.authorId] ? authors[y.authorId] : "sheetjsghost", ref: y.ref, guid: y.guid }/*:any*/);
var cell = decode_cell(y.ref); var cell = decode_cell(y.ref);
if(opts.sheetRows && opts.sheetRows <= cell.r) return; if(opts.sheetRows && opts.sheetRows <= cell.r) return;
var textMatch = x.match(/<(?:\w+:)?text>([^\u2603]*)<\/(?:\w+:)?text>/); var textMatch = x.match(/<(?:\w+:)?text>([\s\S]*)<\/(?:\w+:)?text>/);
var rt = !!textMatch && !!textMatch[1] && parse_si(textMatch[1]) || {r:"",t:"",h:""}; var rt = !!textMatch && !!textMatch[1] && parse_si(textMatch[1]) || {r:"",t:"",h:""};
comment.r = rt.r; comment.r = rt.r;
if(rt.r == "<t></t>") rt.t = rt.h = ""; if(rt.r == "<t></t>") rt.t = rt.h = "";
...@@ -10711,11 +10723,11 @@ function parse_ws_xml_dim(ws, s) { ...@@ -10711,11 +10723,11 @@ function parse_ws_xml_dim(ws, s) {
if(d.s.r<=d.e.r && d.s.c<=d.e.c && d.s.r>=0 && d.s.c>=0) ws["!ref"] = encode_range(d); if(d.s.r<=d.e.r && d.s.c<=d.e.c && d.s.r>=0 && d.s.c>=0) ws["!ref"] = encode_range(d);
} }
var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g; var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
var sheetdataregex = /<(?:\w+:)?sheetData>([^\u2603]*)<\/(?:\w+:)?sheetData>/; var sheetdataregex = /<(?:\w+:)?sheetData>([\s\S]*)<\/(?:\w+:)?sheetData>/;
var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg; var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
var dimregex = /"(\w*:\w*)"/; var dimregex = /"(\w*:\w*)"/;
var colregex = /<(?:\w:)?col[^>]*[\/]?>/g; var colregex = /<(?:\w:)?col[^>]*[\/]?>/g;
var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([^\u2603]*)<\/(?:\w:)?autoFilter)>/g; var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g; var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g;
/* 18.3 Worksheets */ /* 18.3 Worksheets */
function parse_ws_xml(data/*:?string*/, opts, rels, wb, themes, styles)/*:Worksheet*/ { function parse_ws_xml(data/*:?string*/, opts, rels, wb, themes, styles)/*:Worksheet*/ {
...@@ -10816,7 +10828,7 @@ function write_ws_xml_protection(sp)/*:string*/ { ...@@ -10816,7 +10828,7 @@ function write_ws_xml_protection(sp)/*:string*/ {
function parse_ws_xml_hlinks(s, data/*:Array<string>*/, rels) { function parse_ws_xml_hlinks(s, data/*:Array<string>*/, rels) {
var dense = Array.isArray(s); var dense = Array.isArray(s);
for(var i = 0; i != data.length; ++i) { for(var i = 0; i != data.length; ++i) {
var val = parsexmltag(data[i], true); var val = parsexmltag(utf8read(data[i]), true);
if(!val.ref) return; if(!val.ref) return;
var rel = rels ? rels['!id'][val.id] : null; var rel = rels ? rels['!id'][val.id] : null;
if(rel) { if(rel) {
...@@ -13058,7 +13070,8 @@ function xlml_normalize(d)/*:string*/ { ...@@ -13058,7 +13070,8 @@ function xlml_normalize(d)/*:string*/ {
/* UOS uses CJK in tags */ /* UOS uses CJK in tags */
var xlmlregex = /<(\/?)([^\s?>!\/:]*:|)([^\s?>]*[^\s?>\/])[^>]*>/mg; var xlmlregex = /<(\/?)([^\s?>!\/:]*:|)([^\s?>]*[^\s?>\/])[^>]*>/mg;
//var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg; //var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg;
function parse_xlml_xml(d, opts)/*:Workbook*/ { function parse_xlml_xml(d, _opts)/*:Workbook*/ {
var opts = _opts || {};
make_ssf(SSF); make_ssf(SSF);
var str = debom(xlml_normalize(d)); var str = debom(xlml_normalize(d));
if(opts && opts.type == 'binary' && typeof cptable !== 'undefined') str = cptable.utils.decode(65001, char_codes(str)); if(opts && opts.type == 'binary' && typeof cptable !== 'undefined') str = cptable.utils.decode(65001, char_codes(str));
...@@ -13081,7 +13094,7 @@ function parse_xlml_xml(d, opts)/*:Workbook*/ { ...@@ -13081,7 +13094,7 @@ function parse_xlml_xml(d, opts)/*:Workbook*/ {
var rowinfo = [], rowobj = {}; var rowinfo = [], rowobj = {};
var Workbook/*:WBWBProps*/ = ({ Sheets:[], WBProps:{date1904:false} }/*:any*/), wsprops = {}; var Workbook/*:WBWBProps*/ = ({ Sheets:[], WBProps:{date1904:false} }/*:any*/), wsprops = {};
xlmlregex.lastIndex = 0; xlmlregex.lastIndex = 0;
str = str.replace(/<!--([^\u2603]*?)-->/mg,""); str = str.replace(/<!--([\s\S]*?)-->/mg,"");
while((Rn = xlmlregex.exec(str))) switch(Rn[3]) { while((Rn = xlmlregex.exec(str))) switch(Rn[3]) {
case 'Data': case 'Data':
if(state[state.length-1][1]) break; if(state[state.length-1][1]) break;
...@@ -16363,7 +16376,7 @@ var parse_content_xml = (function() { ...@@ -16363,7 +16376,7 @@ var parse_content_xml = (function() {
var rept = 1, isstub = false; var rept = 1, isstub = false;
var i = 0; var i = 0;
xlmlregex.lastIndex = 0; xlmlregex.lastIndex = 0;
str = str.replace(/<!--([^\u2603]*?)-->/mg,"").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm,""); str = str.replace(/<!--([\s\S]*?)-->/mg,"").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm,"");
while((Rn = xlmlregex.exec(str))) switch((Rn[3]=Rn[3].replace(/_.*$/,""))) { while((Rn = xlmlregex.exec(str))) switch((Rn[3]=Rn[3].replace(/_.*$/,""))) {
case 'table': case '工作表': // 9.1.2 <table:table> case 'table': case '工作表': // 9.1.2 <table:table>
......
此差异由.gitattributes 抑制。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册