diff options
| author | Randy Morgan (@morgan_randy) <[email protected]> | 2013-06-08 10:03:39 -0700 |
|---|---|---|
| committer | Randy Morgan (@morgan_randy) <[email protected]> | 2013-06-08 10:03:39 -0700 |
| commit | 00cb09391927aaea08de304f3faad3afdbff2b18 (patch) | |
| tree | 9b81e7c9ed0d6e2a6a25838684a6af51068dcfbb | |
| parent | 7caf2ea9dfe92fa418f40132ea3c94d3da109f2c (diff) | |
| parent | e23558c0bd7bb9027c8ce872ca2b08089b7d1c78 (diff) | |
| download | caxlsx-00cb09391927aaea08de304f3faad3afdbff2b18.tar.gz caxlsx-00cb09391927aaea08de304f3faad3afdbff2b18.zip | |
Merge pull request #190 from amalagaura/patch-1
Update bg_color in conditional formatting
| -rw-r--r-- | lib/axlsx/stylesheet/styles.rb | 6 | ||||
| -rw-r--r-- | test/stylesheet/tc_styles.rb | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index 8cd2275c..44ccb752 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -296,9 +296,11 @@ module Axlsx def parse_fill_options(options={}) return unless options[:bg_color] color = Color.new(:rgb=>options[:bg_color]) - pattern = PatternFill.new(:patternType =>:solid, :fgColor=>color) + dxf = options[:type] == :dxf + color_key = dxf ? :bgColor : :fgColor + pattern = PatternFill.new(:patternType =>:solid, color_key=>color) fill = Fill.new(pattern) - options[:type] == :dxf ? fill : fills << fill + dxf ? fill : fills << fill end # parses Style#add_style options for borders. diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb index b9d0b28a..98c8e3ef 100644 --- a/test/stylesheet/tc_styles.rb +++ b/test/stylesheet/tc_styles.rb @@ -150,7 +150,7 @@ class TestStyles < Test::Unit::TestCase assert_equal(@styles.parse_fill_options(:bg_color => "DE").class, Fixnum, "return index of fill if not :dxf type") assert_equal(@styles.parse_fill_options(:bg_color => "DE", :type => :dxf).class, Axlsx::Fill, "return fill object if :dxf type") f = @styles.parse_fill_options(:bg_color => "DE", :type => :dxf) - assert(f.fill_type.fgColor.rgb == "FFDEDEDE") + assert(f.fill_type.bgColor.rgb == "FFDEDEDE") end def test_parse_protection_options @@ -210,7 +210,7 @@ class TestStyles < Test::Unit::TestCase assert_equal(0, style, "returns the zero-based dxfId") dxf = @styles.dxfs.last - assert_equal(@styles.dxfs.last.fill.fill_type.fgColor.rgb, "FF000000", "fill created with color") + assert_equal(@styles.dxfs.last.fill.fill_type.bgColor.rgb, "FF000000", "fill created with color") assert_equal(font_count, (@styles.fonts.size), "font not created under styles") assert_equal(fill_count, (@styles.fills.size), "fill not created under styles") |
