Read + write style information to .xlsx #263

Open
protobi wants to merge 104 commits from protobi/master into master
5 changed files with 674 additions and 993 deletions
Showing only changes of commit 9102c8214d - Show all commits

View File

@ -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"];

View File

@ -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;

View File

@ -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
View File

@ -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')