diff options
| author | sato-s <[email protected]> | 2016-10-07 01:11:18 +0900 |
|---|---|---|
| committer | sato-s <[email protected]> | 2016-11-14 20:13:08 +0900 |
| commit | 926aa7167b4cab48db99b964a480e9d7c5313a27 (patch) | |
| tree | 33f6a6824595c91cef40fc0212afd9786aadd879 | |
| parent | 731639b7d8871e79e96167b64c83f55e06bf78f6 (diff) | |
| download | caxlsx-926aa7167b4cab48db99b964a480e9d7c5313a27.tar.gz caxlsx-926aa7167b4cab48db99b964a480e9d7c5313a27.zip | |
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)) |
