Read + write style information to .xlsx #263

Open
protobi wants to merge 104 commits from protobi/master into master
3 changed files with 50 additions and 4 deletions
Showing only changes of commit 37a031caee - Show all commits

View File

@ -49,20 +49,36 @@ function parse_fonts(t, opts) {
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x);
switch(y[0]) {
case '<fonts': case '<fonts>': case '</fonts>': break;
case '<font>': break;
case '</font>': styles.Fonts.push(font); font = {}; break;
case '<font':
break;
case '</font>': styles.Fonts.push(font); console.log(font);font = {}; break;
case '<name':
if(y.val) font.name = y.val;
break;
case '<name/>': case '</name>': break;
case '<b/>': font.bold = true;break;
case '<u/>': font.underline = true;break;
case '<i/>': font.italic = true;break;
case '<strike/>': font.strike = true;break;
case '<outline/>': font.outline = true;break;
case '<shadow/>': font.shadow = true;break;
case '<sz':
if(y.val) font.sz = y.val;
break;
case '<sz/>': case '</sz>': break;
case '<vertAlign':
if(y.val) font.vertAlign = y.val;
break;
case '<vertAlign/>': case '</vertAlign>': break;
case '<color':
if (!font.color) font.color = {};

View File

@ -215,6 +215,13 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
if (attributes.bold) $font.append(XmlNode('b'));
if (attributes.underline) $font.append(XmlNode('u'));
if (attributes.italic) $font.append(XmlNode('i'));
if (attributes.strike) $font.append(XmlNode('strike'));
if (attributes.outline) $font.append(XmlNode('outline'));
if (attributes.shadow) $font.append(XmlNode('shadow'));
if (attributes.vertAlign) {
$font.append(XmlNode('vertAlign').attr('val', attributes.vertAlign))
}
if (attributes.color) {

27
xlsx.js
View File

@ -2241,20 +2241,36 @@ function parse_fonts(t, opts) {
t[0].match(tagregex).forEach(function(x) {
var y = parsexmltag(x);
switch(y[0]) {
case '<fonts': case '<fonts>': case '</fonts>': break;
case '<font>': break;
case '</font>': styles.Fonts.push(font); font = {}; break;
case '<font':
break;
case '</font>': styles.Fonts.push(font); console.log(font);font = {}; break;
case '<name':
if(y.val) font.name = y.val;
break;
case '<name/>': case '</name>': break;
case '<b/>': font.bold = true;break;
case '<u/>': font.underline = true;break;
case '<i/>': font.italic = true;break;
case '<strike/>': font.strike = true;break;
case '<outline/>': font.outline = true;break;
case '<shadow/>': font.shadow = true;break;
case '<sz':
if(y.val) font.sz = y.val;
break;
case '<sz/>': case '</sz>': break;
case '<vertAlign':
if(y.val) font.vertAlign = y.val;
break;
case '<vertAlign/>': case '</vertAlign>': break;
case '<color':
if (!font.color) font.color = {};
@ -5791,6 +5807,13 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
if (attributes.bold) $font.append(XmlNode('b'));
if (attributes.underline) $font.append(XmlNode('u'));
if (attributes.italic) $font.append(XmlNode('i'));
if (attributes.strike) $font.append(XmlNode('strike'));
if (attributes.outline) $font.append(XmlNode('outline'));
if (attributes.shadow) $font.append(XmlNode('shadow'));
if (attributes.vertAlign) {
$font.append(XmlNode('vertAlign').attr('val', attributes.vertAlign))
}
if (attributes.color) {