diff options
| author | Randy Morgan (@morgan_randy) <[email protected]> | 2016-11-15 11:02:18 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-11-15 11:02:18 +0900 |
| commit | 27f1507035f460471620ef7b3fe0b448211f0096 (patch) | |
| tree | 61c02173d5f5853eba9a7e7617bba73d368b7b41 | |
| parent | f525dfcf1ced51f235d1868310f5a65c8999d491 (diff) | |
| parent | 193227481e8439a65bb07d94a6121f9f1884150d (diff) | |
| download | caxlsx-27f1507035f460471620ef7b3fe0b448211f0096.tar.gz caxlsx-27f1507035f460471620ef7b3fe0b448211f0096.zip | |
Merge pull request #492 from sato-s/color
set color with Row#color=
| -rw-r--r-- | lib/axlsx/workbook/worksheet/row.rb | 7 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_row.rb | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb index 078e281f..b394279f 100644 --- a/lib/axlsx/workbook/worksheet/row.rb +++ b/lib/axlsx/workbook/worksheet/row.rb @@ -103,6 +103,13 @@ module Axlsx c end + # sets the color for every cell in this row + def color=(color) + each_with_index do | cell, index | + cell.color = color.is_a?(Array) ? color[index] : color + end + end + # sets the style for every cell in this row def style=(style) each_with_index do | cell, index | diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb index 808e0138..43e7d23f 100644 --- a/test/workbook/worksheet/tc_row.rb +++ b/test/workbook/worksheet/tc_row.rb @@ -27,6 +27,11 @@ class TestRow < Test::Unit::TestCase r.cells.each { |c| assert_equal(c.style,1) } end + def test_color + r = @ws.add_row([1,2,3,4,5]) + r.color = "FF00FF00" + r.cells.each { |c| assert_equal(c.color.rgb, "FF00FF00") } + end def test_index assert_equal(@row.row_index, @row.worksheet.rows.index(@row)) |
