diff options
| author | Ankur Sethi <[email protected]> | 2013-05-26 13:10:40 -0300 |
|---|---|---|
| committer | Ankur Sethi <[email protected]> | 2013-05-26 13:10:40 -0300 |
| commit | 061d16b216f14e90f535ccd36e2eb902b4af3b9e (patch) | |
| tree | c0bd89176e1e7508c9509f93db871bcd8c9230ea /lib | |
| parent | 7caf2ea9dfe92fa418f40132ea3c94d3da109f2c (diff) | |
| download | caxlsx-061d16b216f14e90f535ccd36e2eb902b4af3b9e.tar.gz caxlsx-061d16b216f14e90f535ccd36e2eb902b4af3b9e.zip | |
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.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/stylesheet/styles.rb | 6 |
1 files changed, 4 insertions, 2 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. |
