Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix missing merged cells.

Merge cell info for all but the last merged cell was missing from XML output.
  • Loading branch information...
commit ff5d690f8c3ac8fcab2f9c21d5ddeb699cf0e5ef 1 parent 4338184
@noniq noniq authored
View
2  lib/axlsx/workbook/worksheet/worksheet.rb
@@ -403,7 +403,7 @@ def to_xml_string
@rows.each_with_index { |row, index| row.to_xml_string(index, str) }
str.concat '</sheetData>'
str.concat "<autoFilter ref='%s'></autoFilter>" % @auto_filter if @auto_filter
- str.concat "<mergeCells count='%s'>%s</mergeCells>" % [@merged_cells.size, @merged_cells.reduce('') { |memo, obj| "<mergeCell ref='%s'></mergeCell>" % obj } ] unless @merged_cells.empty?
+ str.concat "<mergeCells count='%s'>%s</mergeCells>" % [@merged_cells.size, @merged_cells.reduce('') { |memo, obj| memo += "<mergeCell ref='%s'></mergeCell>" % obj } ] unless @merged_cells.empty?
page_margins.to_xml_string(str) if @page_margins
str.concat "<drawing r:id='rId1'></drawing>" if @drawing
unless @tables.empty?
View
2  test/workbook/worksheet/tc_worksheet.rb
@@ -207,8 +207,10 @@ def test_to_xml_string_auto_filter
def test_to_xml_string_merge_cells
@ws.add_row [1, "two"]
@ws.merge_cells "A1:D1"
+ @ws.merge_cells "E1:F1"
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:mergeCells/xmlns:mergeCell[@ref="A1:D1"]').size, 1)
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:mergeCells/xmlns:mergeCell[@ref="E1:F1"]').size, 1)
end
def test_to_xml_string_page_margins
Please sign in to comment.
Something went wrong with that request. Please try again.