diff options
| author | Stefan Daschek <[email protected]> | 2012-04-05 14:31:28 +0200 |
|---|---|---|
| committer | Stefan Daschek <[email protected]> | 2012-04-05 14:31:28 +0200 |
| commit | 4338184111e19487665070f928208c15e539bd96 (patch) | |
| tree | 253166d088717d1c0802db03bcd36f527e0fdd54 | |
| parent | 2861af86f3b4b0fd4caa22b74e084ab0277da220 (diff) | |
| download | caxlsx-4338184111e19487665070f928208c15e539bd96.tar.gz caxlsx-4338184111e19487665070f928208c15e539bd96.zip | |
Fix position of pageMargins XML element.
Must appear after mergeCells but before drawing element.
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 2 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_worksheet.rb | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 4f26b568..7d26b088 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -402,9 +402,9 @@ module Axlsx str.concat '<sheetData>' @rows.each_with_index { |row, index| row.to_xml_string(index, str) } str.concat '</sheetData>' - page_margins.to_xml_string(str) if @page_margins 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? + page_margins.to_xml_string(str) if @page_margins str.concat "<drawing r:id='rId1'></drawing>" if @drawing unless @tables.empty? str.concat "<tableParts count='%s'>%s</tableParts>" % [@tables.size, @tables.reduce('') { |memo, obj| memo += "<tablePart r:id='%s'/>" % obj.rId }] diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index 499df864..67b11d3c 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -252,8 +252,14 @@ class TestWorksheet < Test::Unit::TestCase assert(errors.empty?, "error free validation") end - def test_valid_with_page_margins + # Make sure the XML for all optional elements (like pageMargins, autoFilter, ...) + # is generated in correct order. + def test_valid_with_optional_elements @ws.page_margins.set :left => 9 + @ws.auto_filter = "A1:C3" + @ws.merge_cells "A4:A5" + @ws.add_chart Axlsx::Pie3DChart + @ws.add_table "E1:F3" schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD)) doc = Nokogiri::XML(@ws.to_xml_string) errors = [] |
