summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-04-25 20:30:57 +0900
committerRandy Morgan <[email protected]>2012-04-25 20:30:57 +0900
commit4242c992d411125d09519c27e56933c1e6a9ae16 (patch)
tree8ef61ace71b40cce6ffb8035e3c5ea66a2d9dfa9
parent672aae6fd76c761006868c42062e153e56da2a09 (diff)
downloadcaxlsx-4242c992d411125d09519c27e56933c1e6a9ae16.tar.gz
caxlsx-4242c992d411125d09519c27e56933c1e6a9ae16.zip
bug fix to properly assign style/type data when creating rows and partial style/types arrays
-rw-r--r--lib/axlsx/workbook/worksheet/row.rb2
-rw-r--r--test/workbook/worksheet/tc_row.rb11
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb
index 4e5150da..e04784b3 100644
--- a/lib/axlsx/workbook/worksheet/row.rb
+++ b/lib/axlsx/workbook/worksheet/row.rb
@@ -132,6 +132,8 @@ module Axlsx
cell_type = types.is_a?(Array)? types[index] : types
options[:type] = cell_type if cell_type
Cell.new(self, value, options)
+ options.delete(:style)
+ options.delete(:type)
end
end
end
diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb
index a953566e..a6b4c74a 100644
--- a/test/workbook/worksheet/tc_row.rb
+++ b/test/workbook/worksheet/tc_row.rb
@@ -32,7 +32,7 @@ class TestRow < Test::Unit::TestCase
r_s_xml = Nokogiri::XML(row.to_xml_string(0, ''))
assert_equal(r_s_xml.xpath(".//row/c").size, 4)
end
-
+
def test_nil_cell_r
row = @ws.add_row([nil,1,2,nil,4,5,nil])
r_s_xml = Nokogiri::XML(row.to_xml_string(0, ''))
@@ -50,8 +50,15 @@ class TestRow < Test::Unit::TestCase
end
def test_array_to_cells
- r = @ws.add_row [1,2,3], :style=>0, :types=>:integer
+ r = @ws.add_row [1,2,3], :style=>1, :types=>[:integer, :string, :float]
assert_equal(r.cells.size, 3)
+ r.cells.each do |c|
+ assert_equal(c.style, 1)
+ end
+ r = @ws.add_row [1,2,3], :style=>[1]
+ assert_equal(r.cells.first.style, 1, "only apply style to cells with at the same index of of the style array")
+ assert_equal(r.cells.last.style, 0, "only apply style to cells with at the same index of of the style array")
+
end
def test_custom_height