forked from sheetjs/sheetjs
Use jQuery parseXML to preserve case in XML
This commit is contained in:
parent
845d2a8880
commit
a562150b96
@ -1,6 +1,14 @@
|
||||
function writeSync(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
|
||||
if (typeof module != 'undefined' && typeof 'require' != 'undefined') {
|
||||
style_builder = new StyleBuilder(opts);
|
||||
}
|
||||
else if (typeof $ != 'undefined' || typeof 'jQuery' != 'undefined') {
|
||||
style_builder = new StyleBuilder(opts);
|
||||
}
|
||||
|
||||
var z = write_zip(wb, o);
|
||||
switch(o.type) {
|
||||
case "base64": return z.generate({type:"base64"});
|
||||
case "binary": return z.generate({type:"string"});
|
||||
@ -13,13 +21,6 @@ function writeSync(wb, opts) {
|
||||
function writeFileSync(wb, filename, opts) {
|
||||
var o = opts||{}; o.type = 'file';
|
||||
|
||||
if (typeof module != 'undefined' && typeof 'require' != 'undefined') {
|
||||
style_builder = new StyleBuilder(opts);
|
||||
}
|
||||
else if (typeof $ != 'undefined' || typeof 'jQuery' != 'undefined') {
|
||||
style_builder = new StyleBuilder(opts);
|
||||
}
|
||||
|
||||
o.file = filename;
|
||||
switch(o.file.substr(-5).toLowerCase()) {
|
||||
case '.xlsm': o.bookType = 'xlsm'; break;
|
||||
|
@ -205,10 +205,12 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
|
||||
createElement = function(str) { return cheerio(cheerio(str, null, null, {xmlMode: true})); };
|
||||
}
|
||||
else if (typeof jQuery !== 'undefined' || typeof $ !== 'undefined') {
|
||||
createElement = function(str) { return $(str); }
|
||||
createElement = function(str) {
|
||||
return $($.parseXML(str).documentElement);
|
||||
} //http://stackoverflow.com/a/11719466
|
||||
}
|
||||
else {
|
||||
createElement = function() { }
|
||||
createElement = function() { } // this class should never have been instantiated
|
||||
}
|
||||
|
||||
|
||||
@ -287,7 +289,7 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
|
||||
this.$styles.find = function(q) { return this(q)}
|
||||
}
|
||||
else {
|
||||
this.$styles = $(baseXml);
|
||||
this.$styles = $($.parseXML(baseXml).documentElement);
|
||||
}
|
||||
|
||||
|
||||
@ -539,7 +541,10 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
|
||||
this.$styles.find('numFmts').remove();
|
||||
}
|
||||
if (this.$styles.xml) { return this.$styles.xml(); }
|
||||
else { return baseXmlprefix + this.$styles.html(); }
|
||||
else {
|
||||
var s = new XMLSerializer(); //http://stackoverflow.com/a/5744268
|
||||
return baseXmlprefix + s.serializeToString(this.$styles[0]);;
|
||||
}
|
||||
}
|
||||
}.initialize(options||{});
|
||||
}
|
||||
|
30
xlsx.js
30
xlsx.js
@ -5184,7 +5184,15 @@ function readFileSync(data, opts) {
|
||||
|
||||
function writeSync(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
|
||||
if (typeof module != 'undefined' && typeof 'require' != 'undefined') {
|
||||
style_builder = new StyleBuilder(opts);
|
||||
}
|
||||
else if (typeof $ != 'undefined' || typeof 'jQuery' != 'undefined') {
|
||||
style_builder = new StyleBuilder(opts);
|
||||
}
|
||||
|
||||
var z = write_zip(wb, o);
|
||||
switch(o.type) {
|
||||
case "base64": return z.generate({type:"base64"});
|
||||
case "binary": return z.generate({type:"string"});
|
||||
@ -5197,13 +5205,6 @@ function writeSync(wb, opts) {
|
||||
function writeFileSync(wb, filename, opts) {
|
||||
var o = opts||{}; o.type = 'file';
|
||||
|
||||
if (typeof module != 'undefined' && typeof 'require' != 'undefined') {
|
||||
style_builder = new StyleBuilder(opts);
|
||||
}
|
||||
else if (typeof $ != 'undefined' || typeof 'jQuery' != 'undefined') {
|
||||
style_builder = new StyleBuilder(opts);
|
||||
}
|
||||
|
||||
o.file = filename;
|
||||
switch(o.file.substr(-5).toLowerCase()) {
|
||||
case '.xlsm': o.bookType = 'xlsm'; break;
|
||||
@ -5419,10 +5420,12 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
|
||||
createElement = function(str) { return cheerio(cheerio(str, null, null, {xmlMode: true})); };
|
||||
}
|
||||
else if (typeof jQuery !== 'undefined' || typeof $ !== 'undefined') {
|
||||
createElement = function(str) { return $(str); }
|
||||
createElement = function(str) {
|
||||
return $($.parseXML(str).documentElement);
|
||||
} //http://stackoverflow.com/a/11719466
|
||||
}
|
||||
else {
|
||||
createElement = function() { }
|
||||
createElement = function() { } // this class should never have been instantiated
|
||||
}
|
||||
|
||||
|
||||
@ -5501,7 +5504,7 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
|
||||
this.$styles.find = function(q) { return this(q)}
|
||||
}
|
||||
else {
|
||||
this.$styles = $(baseXml);
|
||||
this.$styles = $($.parseXML(baseXml).documentElement);
|
||||
}
|
||||
|
||||
|
||||
@ -5753,7 +5756,10 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
|
||||
this.$styles.find('numFmts').remove();
|
||||
}
|
||||
if (this.$styles.xml) { return this.$styles.xml(); }
|
||||
else { return baseXmlprefix + this.$styles.html(); }
|
||||
else {
|
||||
var s = new XMLSerializer(); //http://stackoverflow.com/a/5744268
|
||||
return baseXmlprefix + s.serializeToString(this.$styles[0]);;
|
||||
}
|
||||
}
|
||||
}.initialize(options||{});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user