Added round-trip test for styles

This commit is contained in:
Pieter Sheth-Voss 2015-03-29 15:21:11 -04:00
parent 995f5e89bf
commit 9102c8214d
5 changed files with 674 additions and 993 deletions

@ -12,11 +12,9 @@ function get_cell_style(styles, cell, opts) {
if (typeof style_builder != 'undefined') {
if (/^\d+$/.exec(cell.s)) { return cell.s} // if its already an integer index, let it be
if (cell.s && (cell.s == +cell.s)) { return cell.s} // if its already an integer index, let it be
if (!cell.s) cell.s = {}
if (cell.z) cell.s.numFmt = cell.z;
cell.s = style_builder.addStyle(cell.s);
return cell.s;
var s = cell.s || {};
if (cell.z) s.numFmt = cell.z;
return style_builder.addStyle(s);
}
else {
var z = opts.revssf[cell.z != null ? cell.z : "General"];

@ -250,7 +250,9 @@ return function parse_ws_xml_data(sdata, s, opts, guess) {
fmtid = fillid = 0;
if(do_format && tag.s !== undefined) {
cf = styles.CellXf[tag.s];
if (opts.cellStyles) p.s = get_cell_style_csf(cf)
if (opts.cellStyles) {
p.s = get_cell_style_csf(cf)
}
if(cf != null) {
if(cf.numFmtId != null) fmtid = cf.numFmtId;
if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId;

@ -244,7 +244,7 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
return count - 1;
},
_addNumFmt: function (numFmt) {
_addNumFmt: function (numFmt) {
if (!numFmt) { return 0; }
if (typeof numFmt == 'string') {
@ -257,6 +257,12 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
if (/^[0-9]+$/.exec(numFmt)) {
return numFmt; // we're matching an integer against some known code
}
numFmt = numFmt
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
var $numFmt = XmlNode('numFmt')

File diff suppressed because it is too large Load Diff

20
xlsx.js

@ -2870,11 +2870,9 @@ function get_cell_style(styles, cell, opts) {
if (typeof style_builder != 'undefined') {
if (/^\d+$/.exec(cell.s)) { return cell.s} // if its already an integer index, let it be
if (cell.s && (cell.s == +cell.s)) { return cell.s} // if its already an integer index, let it be
if (!cell.s) cell.s = {}
if (cell.z) cell.s.numFmt = cell.z;
cell.s = style_builder.addStyle(cell.s);
return cell.s;
var s = cell.s || {};
if (cell.z) s.numFmt = cell.z;
return style_builder.addStyle(s);
}
else {
var z = opts.revssf[cell.z != null ? cell.z : "General"];
@ -3189,7 +3187,9 @@ return function parse_ws_xml_data(sdata, s, opts, guess) {
fmtid = fillid = 0;
if(do_format && tag.s !== undefined) {
cf = styles.CellXf[tag.s];
if (opts.cellStyles) p.s = get_cell_style_csf(cf)
if (opts.cellStyles) {
p.s = get_cell_style_csf(cf)
}
if(cf != null) {
if(cf.numFmtId != null) fmtid = cf.numFmtId;
if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId;
@ -5836,7 +5836,7 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
return count - 1;
},
_addNumFmt: function (numFmt) {
_addNumFmt: function (numFmt) {
if (!numFmt) { return 0; }
if (typeof numFmt == 'string') {
@ -5849,6 +5849,12 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
if (/^[0-9]+$/.exec(numFmt)) {
return numFmt; // we're matching an integer against some known code
}
numFmt = numFmt
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
var $numFmt = XmlNode('numFmt')