version bump 0.5.17: do not throw for unknown tags

Fixes #53
This commit is contained in:
SheetJS 2014-04-04 16:03:43 -07:00
parent 03588e332c
commit 0af8b20f0e
7 changed files with 30 additions and 30 deletions

View File

@ -1 +1 @@
XLSX.version = '0.5.16';
XLSX.version = '0.5.17';

View File

@ -1,5 +1,5 @@
/* 18.8.31 numFmts CT_NumFmts */
function parseNumFmts(t) {
function parseNumFmts(t, opts) {
styles.NumberFmt = [];
for(var y in SSF._table) styles.NumberFmt[y] = SSF._table[y];
t[0].match(/<[^>]*>/g).forEach(function(x) {
@ -10,13 +10,13 @@ function parseNumFmts(t) {
var f=unescapexml(y.formatCode), i=parseInt(y.numFmtId,10);
styles.NumberFmt[i] = f; if(i>0) SSF.load(f,i);
} break;
default: throw 'unrecognized ' + y[0] + ' in numFmts';
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in numFmts';
}
});
}
/* 18.8.10 cellXfs CT_CellXfs */
function parseCXfs(t) {
function parseCXfs(t, opts) {
styles.CellXf = [];
t[0].match(/<[^>]*>/g).forEach(function(x) {
var y = parsexmltag(x);
@ -30,25 +30,25 @@ function parseCXfs(t) {
case '</xf>': break;
/* 18.8.1 alignment CT_CellAlignment */
case '<alignment': break;
case '<alignment': case '<alignment/>': break;
/* 18.8.33 protection CT_CellProtection */
case '<protection': case '</protection>': case '<protection/>': break;
case '<extLst': case '</extLst>': break;
case '<ext': break;
default: throw 'unrecognized ' + y[0] + ' in cellXfs';
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in cellXfs';
}
});
}
/* 18.8 Styles CT_Stylesheet*/
function parse_sty_xml(data) {
function parse_sty_xml(data, opts) {
/* 18.8.39 styleSheet CT_Stylesheet */
var t;
/* numFmts CT_NumFmts ? */
if((t=data.match(/<numFmts([^>]*)>.*<\/numFmts>/))) parseNumFmts(t);
if((t=data.match(/<numFmts([^>]*)>.*<\/numFmts>/))) parseNumFmts(t, opts);
/* fonts CT_Fonts ? */
/* fills CT_Fills ? */
@ -56,7 +56,7 @@ function parse_sty_xml(data) {
/* cellStyleXfs CT_CellStyleXfs ? */
/* cellXfs CT_CellXfs ? */
if((t=data.match(/<cellXfs([^>]*)>.*<\/cellXfs>/))) parseCXfs(t);
if((t=data.match(/<cellXfs([^>]*)>.*<\/cellXfs>/))) parseCXfs(t, opts);
/* dxfs CT_Dxfs ? */
/* tableStyles CT_TableStyles ? */

18
dist/xlsx.js vendored
View File

@ -498,7 +498,7 @@ SSF.load_table = function(tbl) { for(var i=0; i!=0x0188; ++i) if(tbl[i]) SSF.loa
make_ssf(SSF);
var XLSX = {};
(function(XLSX){
XLSX.version = '0.5.16';
XLSX.version = '0.5.17';
var current_codepage, current_cptable, cptable;
if(typeof module !== "undefined" && typeof require !== 'undefined') {
if(typeof cptable === 'undefined') cptable = require('codepage');
@ -1009,7 +1009,7 @@ var parse_sst_bin = function(data, opts) {
var styles = {}; // shared styles
/* 18.8.31 numFmts CT_NumFmts */
function parseNumFmts(t) {
function parseNumFmts(t, opts) {
styles.NumberFmt = [];
for(var y in SSF._table) styles.NumberFmt[y] = SSF._table[y];
t[0].match(/<[^>]*>/g).forEach(function(x) {
@ -1020,13 +1020,13 @@ function parseNumFmts(t) {
var f=unescapexml(y.formatCode), i=parseInt(y.numFmtId,10);
styles.NumberFmt[i] = f; if(i>0) SSF.load(f,i);
} break;
default: throw 'unrecognized ' + y[0] + ' in numFmts';
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in numFmts';
}
});
}
/* 18.8.10 cellXfs CT_CellXfs */
function parseCXfs(t) {
function parseCXfs(t, opts) {
styles.CellXf = [];
t[0].match(/<[^>]*>/g).forEach(function(x) {
var y = parsexmltag(x);
@ -1040,25 +1040,25 @@ function parseCXfs(t) {
case '</xf>': break;
/* 18.8.1 alignment CT_CellAlignment */
case '<alignment': break;
case '<alignment': case '<alignment/>': break;
/* 18.8.33 protection CT_CellProtection */
case '<protection': case '</protection>': case '<protection/>': break;
case '<extLst': case '</extLst>': break;
case '<ext': break;
default: throw 'unrecognized ' + y[0] + ' in cellXfs';
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in cellXfs';
}
});
}
/* 18.8 Styles CT_Stylesheet*/
function parse_sty_xml(data) {
function parse_sty_xml(data, opts) {
/* 18.8.39 styleSheet CT_Stylesheet */
var t;
/* numFmts CT_NumFmts ? */
if((t=data.match(/<numFmts([^>]*)>.*<\/numFmts>/))) parseNumFmts(t);
if((t=data.match(/<numFmts([^>]*)>.*<\/numFmts>/))) parseNumFmts(t, opts);
/* fonts CT_Fonts ? */
/* fills CT_Fills ? */
@ -1066,7 +1066,7 @@ function parse_sty_xml(data) {
/* cellStyleXfs CT_CellStyleXfs ? */
/* cellXfs CT_CellXfs ? */
if((t=data.match(/<cellXfs([^>]*)>.*<\/cellXfs>/))) parseCXfs(t);
if((t=data.match(/<cellXfs([^>]*)>.*<\/cellXfs>/))) parseCXfs(t, opts);
/* dxfs CT_Dxfs ? */
/* tableStyles CT_TableStyles ? */

2
dist/xlsx.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.min.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.5.16",
"version": "0.5.17",
"author": "sheetjs",
"description": "XLSB / XLSX / XLSM (Excel 2007+ Spreadsheet) parser",
"keywords": [ "xlsx", "xlsb", "xlsm", "office", "excel", "spreadsheet" ],

18
xlsx.js
View File

@ -498,7 +498,7 @@ SSF.load_table = function(tbl) { for(var i=0; i!=0x0188; ++i) if(tbl[i]) SSF.loa
make_ssf(SSF);
var XLSX = {};
(function(XLSX){
XLSX.version = '0.5.16';
XLSX.version = '0.5.17';
var current_codepage, current_cptable, cptable;
if(typeof module !== "undefined" && typeof require !== 'undefined') {
if(typeof cptable === 'undefined') cptable = require('codepage');
@ -1009,7 +1009,7 @@ var parse_sst_bin = function(data, opts) {
var styles = {}; // shared styles
/* 18.8.31 numFmts CT_NumFmts */
function parseNumFmts(t) {
function parseNumFmts(t, opts) {
styles.NumberFmt = [];
for(var y in SSF._table) styles.NumberFmt[y] = SSF._table[y];
t[0].match(/<[^>]*>/g).forEach(function(x) {
@ -1020,13 +1020,13 @@ function parseNumFmts(t) {
var f=unescapexml(y.formatCode), i=parseInt(y.numFmtId,10);
styles.NumberFmt[i] = f; if(i>0) SSF.load(f,i);
} break;
default: throw 'unrecognized ' + y[0] + ' in numFmts';
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in numFmts';
}
});
}
/* 18.8.10 cellXfs CT_CellXfs */
function parseCXfs(t) {
function parseCXfs(t, opts) {
styles.CellXf = [];
t[0].match(/<[^>]*>/g).forEach(function(x) {
var y = parsexmltag(x);
@ -1040,25 +1040,25 @@ function parseCXfs(t) {
case '</xf>': break;
/* 18.8.1 alignment CT_CellAlignment */
case '<alignment': break;
case '<alignment': case '<alignment/>': break;
/* 18.8.33 protection CT_CellProtection */
case '<protection': case '</protection>': case '<protection/>': break;
case '<extLst': case '</extLst>': break;
case '<ext': break;
default: throw 'unrecognized ' + y[0] + ' in cellXfs';
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in cellXfs';
}
});
}
/* 18.8 Styles CT_Stylesheet*/
function parse_sty_xml(data) {
function parse_sty_xml(data, opts) {
/* 18.8.39 styleSheet CT_Stylesheet */
var t;
/* numFmts CT_NumFmts ? */
if((t=data.match(/<numFmts([^>]*)>.*<\/numFmts>/))) parseNumFmts(t);
if((t=data.match(/<numFmts([^>]*)>.*<\/numFmts>/))) parseNumFmts(t, opts);
/* fonts CT_Fonts ? */
/* fills CT_Fills ? */
@ -1066,7 +1066,7 @@ function parse_sty_xml(data) {
/* cellStyleXfs CT_CellStyleXfs ? */
/* cellXfs CT_CellXfs ? */
if((t=data.match(/<cellXfs([^>]*)>.*<\/cellXfs>/))) parseCXfs(t);
if((t=data.match(/<cellXfs([^>]*)>.*<\/cellXfs>/))) parseCXfs(t, opts);
/* dxfs CT_Dxfs ? */
/* tableStyles CT_TableStyles ? */