Save fill color to .rgb but not tint

This commit is contained in:
Pieter Sheth-Voss 2015-04-17 11:18:51 -04:00
parent 51b7cabd2c
commit 89066b45b6
3 changed files with 32 additions and 26 deletions

@ -35,7 +35,8 @@ function parse_fills(t, opts) {
if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
fill.bgColor.raw_rgb = rgb_tint(themes.themeElements.clrScheme[fill.bgColor.theme].rgb, fill.fgColor.tint || 0);
fill.bgColor.rgb = rgb_tint(themes.themeElements.clrScheme[fill.bgColor.theme].rgb, 0) ; //fill.fgColor.tint || 0);
if (opts.WTF) fill.bgColor.raw_rgb = fill.bgColor.rgb;
}
/* Excel uses ARGB strings */
if (y.rgb) fill.bgColor.rgb = y.rgb;//.substring(y.rgb.length - 6);
@ -51,7 +52,8 @@ function parse_fills(t, opts) {
if (y.tint) fill.fgColor.tint = parseFloat(y.tint);
if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
fill.fgColor.raw_rgb = rgb_tint(themes.themeElements.clrScheme[fill.fgColor.theme].rgb, fill.fgColor.tint || 0);
fill.fgColor.rgb = rgb_tint(themes.themeElements.clrScheme[fill.fgColor.theme].rgb, 0); //fill.fgColor.tint || 0);
if (opts.WTF) fill.fgColor.raw_rgb = fill.fgColor.rgb;
}
/* Excel uses ARGB strings */
@ -134,7 +136,7 @@ function parse_fonts(t, opts) {
if (y.theme) font.color.theme = y.theme;
if (y.tint) font.color.tint = y.tint;
if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
font.color.raw_rgb = rgb_tint(themes.themeElements.clrScheme[font.color.theme].rgb, font.color.tint || 0);
font.color.rgb = rgb_tint(themes.themeElements.clrScheme[font.color.theme].rgb, font.color.tint || 0);
}
if (y.rgb) font.color.rgb = y.rgb;
break;
@ -202,7 +204,7 @@ function parse_borders(t, opts) {
sub_border.color = {};
if (y.theme) sub_border.color.theme = y.theme;
if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
sub_border.color.raw_rgb = rgb_tint(themes.themeElements.clrScheme[sub_border.color.theme].rgb, sub_border.color.tint || 0);
sub_border.color.rgb = rgb_tint(themes.themeElements.clrScheme[sub_border.color.theme].rgb, sub_border.color.tint || 0);
}
if (y.tint) sub_border.color.tint = y.tint;

38
test.js

@ -765,31 +765,33 @@ describe('parse features', function() {
'A3:A10', 'B3:B10', 'E1:E10', 'F6:F8', /* cols */
'H1:J4', 'H10' /* blocks */
];
var exp = [
{ patternType: 'darkHorizontal',
fgColor: { theme: 9, "tint":-0.249977111117893, raw_rgb: 'B9B9B9' },
bgColor: { theme: 5, "tint":0.3999755851924192, raw_rgb: '909090' } },
fgColor: { theme: 9, "tint":-0.249977111117893, rgb: 'F79646' },
bgColor: { theme: 5, "tint":0.3999755851924192, rgb: 'C0504D' } },
{ patternType: 'darkUp',
fgColor: { theme: 3, "tint":-0.249977111117893,raw_rgb: 'B3B3B3' },
bgColor: { theme: 7, "tint":0.3999755851924192,raw_rgb: '606060' } },
fgColor: { theme: 3, "tint":-0.249977111117893, rgb: 'EEECE1' },
bgColor: { theme: 7, "tint":0.3999755851924192, rgb: '8064A2' } },
{ patternType: 'darkGray',
fgColor: { theme: 3, raw_rgb: 'EEECE1' },
bgColor: { theme: 1, raw_rgb: 'FFFFFF' } },
fgColor: { theme: 3, rgb: 'EEECE1' },
bgColor: { theme: 1, rgb: 'FFFFFF' } },
{ patternType: 'lightGray',
fgColor: { theme: 6, "tint":0.3999755851924192, raw_rgb: 'C3C3C3' },
bgColor: { theme: 2, "tint":-0.499984740745262, raw_rgb: '797979' } },
fgColor: { theme: 6, "tint":0.3999755851924192, rgb: '9BBB59' },
bgColor: { theme: 2, "tint":-0.499984740745262, rgb: '1F497D' } },
{ patternType: 'lightDown',
fgColor: { theme: 4, raw_rgb: '3B3B3B' },
bgColor: { theme: 7, raw_rgb: '606060' } },
fgColor: { theme: 4, rgb: '4F81BD' },
bgColor: { theme: 7, rgb: '8064A2' } },
{ patternType: 'lightGrid',
fgColor: { theme: 6, "tint":-0.249977111117893, raw_rgb: '747474' },
bgColor: { theme: 9, "tint":-0.249977111117893, raw_rgb: 'B9B9B9' } },
fgColor: { theme: 6, "tint":-0.249977111117893, rgb: '9BBB59' },
bgColor: { theme: 9, "tint":-0.249977111117893, rgb: 'F79646' } },
{ patternType: 'lightGrid',
fgColor: { theme: 4, raw_rgb: '4F81BD' },
bgColor: { theme: 2, "tint":-0.749992370372631, raw_rgb: '1F497D' } },
fgColor: { theme: 4, rgb: '4F81BD' },
bgColor: { theme: 2, "tint":-0.749992370372631, rgb: '1F497D' } },
{ patternType: 'lightVertical',
fgColor: { theme: 3, "tint":0.3999755851924192, raw_rgb: 'F5F5F5' },
bgColor: { theme: 7, "tint":0.3999755851924192, raw_rgb: 'B3B3B3' } }
fgColor: { theme: 3, "tint":0.3999755851924192, rgb: 'EEECE1' },
bgColor: { theme: 7, "tint":0.3999755851924192, rgb: '8064A2' } }
];
ranges.forEach(function(rng) {
it('XLS | ' + rng,function(){cmparr(rn2(rng).map(function(x){ return wsxls[x].s; }));});
@ -809,8 +811,8 @@ describe('parse features', function() {
var stylesxlsx = ranges.map(function(r) { return rn2(r)[0]; }).map(function(r) { return wsxlsx[r].s; });
for(var i = 0; i != exp.length; ++i) {
var props = [
"fgColor.theme","fgColor.raw_rgb",
"bgColor.theme","bgColor.raw_rgb",
"fgColor.theme","fgColor.rgb",
"bgColor.theme","bgColor.rgb",
"patternType"
];

10
xlsx.js

@ -4671,7 +4671,8 @@ function parse_fills(t, opts) {
if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
fill.bgColor.raw_rgb = rgb_tint(themes.themeElements.clrScheme[fill.bgColor.theme].rgb, fill.fgColor.tint || 0);
fill.bgColor.rgb = rgb_tint(themes.themeElements.clrScheme[fill.bgColor.theme].rgb, 0) ; //fill.fgColor.tint || 0);
if (opts.WTF) fill.bgColor.raw_rgb = fill.bgColor.rgb;
}
/* Excel uses ARGB strings */
if (y.rgb) fill.bgColor.rgb = y.rgb;//.substring(y.rgb.length - 6);
@ -4687,7 +4688,8 @@ function parse_fills(t, opts) {
if (y.tint) fill.fgColor.tint = parseFloat(y.tint);
if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
fill.fgColor.raw_rgb = rgb_tint(themes.themeElements.clrScheme[fill.fgColor.theme].rgb, fill.fgColor.tint || 0);
fill.fgColor.rgb = rgb_tint(themes.themeElements.clrScheme[fill.fgColor.theme].rgb, 0); //fill.fgColor.tint || 0);
if (opts.WTF) fill.fgColor.raw_rgb = fill.fgColor.rgb;
}
/* Excel uses ARGB strings */
@ -4770,7 +4772,7 @@ function parse_fonts(t, opts) {
if (y.theme) font.color.theme = y.theme;
if (y.tint) font.color.tint = y.tint;
if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
font.color.raw_rgb = rgb_tint(themes.themeElements.clrScheme[font.color.theme].rgb, font.color.tint || 0);
font.color.rgb = rgb_tint(themes.themeElements.clrScheme[font.color.theme].rgb, font.color.tint || 0);
}
if (y.rgb) font.color.rgb = y.rgb;
break;
@ -4838,7 +4840,7 @@ function parse_borders(t, opts) {
sub_border.color = {};
if (y.theme) sub_border.color.theme = y.theme;
if (y.theme && themes.themeElements && themes.themeElements.clrScheme) {
sub_border.color.raw_rgb = rgb_tint(themes.themeElements.clrScheme[sub_border.color.theme].rgb, sub_border.color.tint || 0);
sub_border.color.rgb = rgb_tint(themes.themeElements.clrScheme[sub_border.color.theme].rgb, sub_border.color.tint || 0);
}
if (y.tint) sub_border.color.tint = y.tint;