test/workbook/worksheet/tc_worksheet.rb in axlsx-1.2.3 vs test/workbook/worksheet/tc_worksheet.rb in axlsx-1.3.1
- old
+ new
@@ -244,11 +244,11 @@
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetData/xmlns:row').size, 1)
end
def test_to_xml_string_auto_filter
@ws.add_row [1, "two"]
- @ws.auto_filter = "A1:B1"
+ @ws.auto_filter.range = "A1:B1"
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:autoFilter[@ref="A1:B1"]').size, 1)
end
def test_to_xml_string_merge_cells
@@ -322,17 +322,24 @@
nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
@ws.add_row [nasties]
assert_equal(0, @ws.rows.last.cells.last.value.index("\v"))
assert_equal(nil,@ws.to_xml_string.index("\v"))
end
+
+ def test_to_xml_string_with_newlines
+ cell_with_newline = "foo\n\r\nbar"
+ @ws.add_row [cell_with_newline]
+ assert_equal("foo\n\r\nbar", @ws.rows.last.cells.last.value)
+ assert_not_nil(@ws.to_xml_string.index("foo\n\r\nbar"))
+ end
# 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.page_setup.set :fit_to_width => 1
@ws.print_options.set :headings => true
- @ws.auto_filter = "A1:C3"
+ @ws.auto_filter.range = "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)
@@ -415,9 +422,16 @@
end
def test_auto_filter
assert(@ws.auto_filter.range.nil?)
assert_raise(ArgumentError) { @ws.auto_filter = 123 }
- @ws.auto_filter = "A1:D9"
+ @ws.auto_filter.range = "A1:D9"
assert_equal(@ws.auto_filter.range, "A1:D9")
+ end
+
+ def test_sheet_pr_for_auto_filter
+ @ws.auto_filter.range = 'A1:D9'
+ @ws.auto_filter.add_column 0, :filters, :filter_items => [1]
+ doc = Nokogiri::XML(@ws.to_xml_string)
+ assert(doc.xpath('//sheetPr[@filterMode="true"]'))
end
end