From 061d16b216f14e90f535ccd36e2eb902b4af3b9e Mon Sep 17 00:00:00 2001 From: Ankur Sethi Date: Sun, 26 May 2013 13:10:40 -0300 Subject: Update bg_color in conditional formatting Conditional formatting for background color fills is different for DXF. This must be undocumented and is quite annoying. I verified the behavior in Excel 2010 Mac and Windows. I didn't understand why background colors were not being applied even though the style was being applied for conditional formatting. Looking at styles.xml I saw that it is different in a file created by Excel. I have updated the code to reflect it and tested in Mac and Windows. --- lib/axlsx/stylesheet/styles.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') 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. -- cgit v1.2.3