From ed19433c505417d4b08b4aa1da2f80d1da7f8358 Mon Sep 17 00:00:00 2001 From: Steven Daniels Date: Fri, 30 Dec 2016 22:21:16 -0500 Subject: [PATCH 1/3] Extracted testing classes for formatters --- README.md | 10 + lib/roo/base.rb | 36 --- lib/roo/formatters/csv.rb | 1 - lib/roo/formatters/yaml.rb | 3 +- test/files/expected_results/time-test.yml | 26 ++ test/formatters/test_csv.rb | 102 ++++++++ test/formatters/test_matrix.rb | 76 ++++++ test/formatters/test_xml.rb | 74 ++++++ test/formatters/test_yaml.rb | 20 ++ test/test_helper.rb | 42 +++ test/test_roo.rb | 299 +--------------------- 11 files changed, 353 insertions(+), 336 deletions(-) create mode 100644 test/files/expected_results/time-test.yml create mode 100644 test/formatters/test_csv.rb create mode 100644 test/formatters/test_matrix.rb create mode 100644 test/formatters/test_xml.rb create mode 100644 test/formatters/test_yaml.rb diff --git a/README.md b/README.md index 905abe3f..b00b0a74 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,16 @@ Roo's public methods have stayed relatively consistent between 1.13.x and 2.0.0, 5. Push to the branch (`git push origin my-new-feature`) 6. Create a new Pull Request +### Testing +Roo uses Minitest and RSpec. The best of both worlds! Run `bundle exec rake` to +run the tests/examples. + +Roo also has a few tests that take a long time (5+ seconds). To run these, use +`LONG_RUN=true bundle exec rake` + +When testing using Ruby 2.0 or 2.1, use this command: +`BUNDLE_GEMFILE=Gemfile_ruby2 bundle exec rake` + ### Issues If you find an issue, please create a gist and refer to it in an issue ([sample gist](https://gist.github.com/stevendaniels/98a05849036e99bb8b3c)). Here are some instructions for creating such a gist. diff --git a/lib/roo/base.rb b/lib/roo/base.rb index a524c2d0..d18a4126 100644 --- a/lib/roo/base.rb +++ b/lib/roo/base.rb @@ -221,32 +221,6 @@ def info end end - # # returns an XML representation of all sheets of a spreadsheet file - # def to_xml - # Nokogiri::XML::Builder.new do |xml| - # xml.spreadsheet do - # sheets.each do |sheet| - # self.default_sheet = sheet - # xml.sheet(name: sheet) do |x| - # if first_row && last_row && first_column && last_column - # # sonst gibt es Fehler bei leeren Blaettern - # first_row.upto(last_row) do |row| - # first_column.upto(last_column) do |col| - # next if empty?(row, col) - # - # x.cell(cell(row, col), - # row: row, - # column: col, - # type: celltype(row, col)) - # end - # end - # end - # end - # end - # end - # end.to_xml - # end - # when a method like spreadsheet.a42 is called # convert it to a call of spreadsheet.cell('a',42) def method_missing(m, *args) @@ -622,14 +596,4 @@ def process_zipfile_packed(zip, tmpdir, path = '') ret end end - - # # converts an integer value to a time string like '02:05:06' - # def integer_to_timestring(content) - # h = (content / 3600.0).floor - # content -= h * 3600 - # m = (content / 60.0).floor - # content -= m * 60 - # s = content - # sprintf('%02d:%02d:%02d', h, m, s) - # end end diff --git a/lib/roo/formatters/csv.rb b/lib/roo/formatters/csv.rb index 0eea0900..14b44845 100644 --- a/lib/roo/formatters/csv.rb +++ b/lib/roo/formatters/csv.rb @@ -33,7 +33,6 @@ def write_csv_content(file = nil, sheet = nil, separator = ",") end end - # The content of a cell in the csv output def cell_to_csv(row, col, sheet) return "" if empty?(row, col, sheet) diff --git a/lib/roo/formatters/yaml.rb b/lib/roo/formatters/yaml.rb index 2e716729..69ef3ab0 100644 --- a/lib/roo/formatters/yaml.rb +++ b/lib/roo/formatters/yaml.rb @@ -5,7 +5,8 @@ module YAML # you can add additional attributes with the prefix parameter like: # oo.to_yaml({"file"=>"flightdata_2007-06-26", "sheet" => "1"}) def to_yaml(prefix = {}, from_row = nil, from_column = nil, to_row = nil, to_column = nil, sheet = default_sheet) - return '' unless first_row # empty result if there is no first_row in a sheet + # return an empty string if there is no first_row, i.e. the sheet is empty + return "" unless first_row from_row ||= first_row(sheet) to_row ||= last_row(sheet) diff --git a/test/files/expected_results/time-test.yml b/test/files/expected_results/time-test.yml new file mode 100644 index 00000000..7ca4e5f8 --- /dev/null +++ b/test/files/expected_results/time-test.yml @@ -0,0 +1,26 @@ +--- +cell_1_1: + row: 1 + col: 1 + celltype: string + value: Mittags: +cell_1_2: + row: 1 + col: 2 + celltype: time + value: 12:13:14 +cell_1_3: + row: 1 + col: 3 + celltype: time + value: 15:16:00 +cell_1_4: + row: 1 + col: 4 + celltype: time + value: 23:00:00 +cell_2_1: + row: 2 + col: 1 + celltype: date + value: 2007-11-21 diff --git a/test/formatters/test_csv.rb b/test/formatters/test_csv.rb new file mode 100644 index 00000000..5c2c47c9 --- /dev/null +++ b/test/formatters/test_csv.rb @@ -0,0 +1,102 @@ +require "test_helper" + +class TestRooFormatterCSV < Minitest::Test + def test_date_time_to_csv + with_each_spreadsheet(name: "time-test") do |workbook| + Dir.mktmpdir do |tempdir| + csv_output = File.join(tempdir, "time_test.csv") + assert workbook.to_csv(csv_output) + assert File.exist?(csv_output) + assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/time-test.csv #{csv_output}` + # --strip-trailing-cr is needed because the test-file use 0A and + # the test on an windows box generates 0D 0A as line endings + end + end + end + + def test_boolean_to_csv + with_each_spreadsheet(name: "boolean") do |workbook| + Dir.mktmpdir do |tempdir| + csv_output = File.join(tempdir,"boolean.csv") + assert workbook.to_csv(csv_output) + assert File.exist?(csv_output) + assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/boolean.csv #{csv_output}` + # --strip-trailing-cr is needed because the test-file use 0A and + # the test on an windows box generates 0D 0A as line endings + end + end + end + + def test_link_to_csv + with_each_spreadsheet(name: "link", format: :excelx) do |workbook| + Dir.mktmpdir do |tempdir| + csv_output = File.join(tempdir, "link.csv") + assert workbook.to_csv(csv_output) + assert File.exist?(csv_output) + assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/link.csv #{csv_output}` + # --strip-trailing-cr is needed because the test-file use 0A and + # the test on an windows box generates 0D 0A as line endings + end + end + end + + # "/tmp/xxxx" darf man unter Windows nicht verwenden, weil das nicht erkannt + # wird. + # Besser: Methode um temporaeres Dir. portabel zu bestimmen + def test_huge_document_to_csv + skip unless ENV["LONG_RUN"] + + original_csv_path = File.join(TESTDIR, "Bibelbund.csv") + with_each_spreadsheet(name: "Bibelbund", format: [:openoffice, :excelx]) do |workbook| + Dir.mktmpdir do |tempdir| + new_csv_path = File.join(tempdir, "Bibelbund.csv") + assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", workbook.cell(45, "A") + assert_equal "Tagebuch des Sekret\303\244rs. Nachrichten aus Chile", workbook.cell(46, "A") + assert_equal "Tagebuch aus Chile Juli 1977", workbook.cell(55, "A") + assert workbook.to_csv(new_csv_path) + assert File.exist?(new_csv_path) + assert FileUtils.identical?(original_csv_path, new_csv_path), "error in class #{workbook.class}" + end + end + end + + def test_bug_empty_sheet + with_each_spreadsheet(name: "formula", format: [:openoffice, :excelx]) do |workbook| + workbook.default_sheet = "Sheet3" # is an empty sheet + Dir.mktmpdir do |tempdir| + workbook.to_csv(File.join(tempdir, "emptysheet.csv")) + assert_equal "", `cat #{File.join(tempdir, "emptysheet.csv")}` + end + end + end + + def test_bug_quotes_excelx + skip unless ENV["LONG_RUN"] + # TODO: run this test with a much smaller document + with_each_spreadsheet(name: "Bibelbund", format: [:openoffice, :excelx]) do |workbook| + workbook.default_sheet = workbook.sheets.first + assert_equal( + 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"', + workbook.cell("A", 76) + ) + workbook.to_csv("csv#{$$}") + assert_equal( + 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"', + workbook.cell("A", 78) + ) + File.delete_if_exist("csv#{$$}") + end + end + + def test_bug_datetime_to_csv + with_each_spreadsheet(name: "datetime") do |workbook| + Dir.mktmpdir do |tempdir| + datetime_csv_file = File.join(tempdir, "datetime.csv") + + assert workbook.to_csv(datetime_csv_file) + assert File.exist?(datetime_csv_file) + assert_equal "", file_diff("#{TESTDIR}/so_datetime.csv", datetime_csv_file) + end + end + end +end diff --git a/test/formatters/test_matrix.rb b/test/formatters/test_matrix.rb new file mode 100644 index 00000000..f2cb51f3 --- /dev/null +++ b/test/formatters/test_matrix.rb @@ -0,0 +1,76 @@ +require "test_helper" +require "matrix" + +class TestRooFormatterMatrix < Minitest::Test + def test_matrix + expected_result = Matrix[ + [1.0, 2.0, 3.0], + [4.0, 5.0, 6.0], + [7.0, 8.0, 9.0] + ] + with_each_spreadsheet(name: "matrix", format: :openoffice) do |workbook| + workbook.default_sheet = workbook.sheets.first + assert_equal expected_result, workbook.to_matrix + end + end + + def test_matrix_selected_range + expected_result = Matrix[ + [1.0, 2.0, 3.0], + [4.0, 5.0, 6.0], + [7.0, 8.0, 9.0] + ] + with_each_spreadsheet(name: "matrix", format: :openoffice) do |workbook| + workbook.default_sheet = "Sheet2" + assert_equal expected_result, workbook.to_matrix(3, 4, 5, 6) + end + end + + def test_matrix_all_nil + expected_result = Matrix[ + [nil, nil, nil], + [nil, nil, nil], + [nil, nil, nil] + ] + with_each_spreadsheet(name: "matrix", format: :openoffice) do |workbook| + workbook.default_sheet = "Sheet2" + assert_equal expected_result, workbook.to_matrix(10, 10, 12, 12) + end + end + + def test_matrix_values_and_nil + expected_result = Matrix[ + [1.0, nil, 3.0], + [4.0, 5.0, 6.0], + [7.0, 8.0, nil] + ] + with_each_spreadsheet(name: "matrix", format: :openoffice) do |workbook| + workbook.default_sheet = "Sheet3" + assert_equal expected_result, workbook.to_matrix(1, 1, 3, 3) + end + end + + def test_matrix_specifying_sheet + expected_result = Matrix[ + [1.0, nil, 3.0], + [4.0, 5.0, 6.0], + [7.0, 8.0, nil] + ] + with_each_spreadsheet(name: "matrix", format: :openoffice) do |workbook| + workbook.default_sheet = workbook.sheets.first + assert_equal expected_result, workbook.to_matrix(nil, nil, nil, nil, "Sheet3") + end + end + + # #to_matrix of an empty sheet should return an empty matrix and not result in + # an error message + # 2011-06-25 + def test_bug_to_matrix_empty_sheet + options = { name: "emptysheets", format: [:openoffice, :excelx] } + with_each_spreadsheet(options) do |workbook| + workbook.default_sheet = workbook.sheets.first + workbook.to_matrix + assert_equal(Matrix.empty(0, 0), workbook.to_matrix) + end + end +end diff --git a/test/formatters/test_xml.rb b/test/formatters/test_xml.rb new file mode 100644 index 00000000..db30a766 --- /dev/null +++ b/test/formatters/test_xml.rb @@ -0,0 +1,74 @@ +require "test_helper" + +class TestRooFormatterXML < Minitest::Test + def test_to_xml + expected_sheet_count = 5 + with_each_spreadsheet(name: "numbers1", encoding: "utf8") do |workbook| + skip if defined? JRUBY_VERSION + workbook.to_xml + sheetname = workbook.sheets.first + doc = Nokogiri::XML(workbook.to_xml) + all_cells = init_all_cells(workbook, sheetname) + + assert_equal expected_sheet_count, doc.xpath("//spreadsheet/sheet").count + + doc.xpath("//spreadsheet/sheet").each do |xml_sheet| + assert_equal sheetname, xml_sheet.attributes["name"].value + xml_sheet.children.each_with_index do |cell, i| + next unless cell.attributes["name"] + + expected = [ + all_cells[i][:row], + all_cells[i][:column], + all_cells[i][:content], + all_cells[i][:type], + ] + result = [ + cell.attributes["row"], + cell.attributes["column"], + cell.content, + cell.attributes["type"], + ] + assert_equal expected, result + end # end of sheet + sheetname = workbook.sheets[workbook.sheets.index(sheetname) + 1] + end + end + end + + def test_bug_to_xml_with_empty_sheets + with_each_spreadsheet(name: "emptysheets", format: [:openoffice, :excelx]) do |workbook| + workbook.sheets.each do |sheet| + assert_nil workbook.first_row, "first_row not nil in sheet #{sheet}" + assert_nil workbook.last_row, "last_row not nil in sheet #{sheet}" + assert_nil workbook.first_column, "first_column not nil in sheet #{sheet}" + assert_nil workbook.last_column, "last_column not nil in sheet #{sheet}" + assert_nil workbook.first_row(sheet), "first_row not nil in sheet #{sheet}" + assert_nil workbook.last_row(sheet), "last_row not nil in sheet #{sheet}" + assert_nil workbook.first_column(sheet), "first_column not nil in sheet #{sheet}" + assert_nil workbook.last_column(sheet), "last_column not nil in sheet #{sheet}" + end + workbook.to_xml + end + end + + # Erstellt eine Liste aller Zellen im Spreadsheet. Dies ist nötig, weil ein einfacher + # Textvergleich des XML-Outputs nicht funktioniert, da xml-builder die Attribute + # nicht immer in der gleichen Reihenfolge erzeugt. + def init_all_cells(workbook, sheet) + all = [] + workbook.first_row(sheet).upto(workbook.last_row(sheet)) do |row| + workbook.first_column(sheet).upto(workbook.last_column(sheet)) do |col| + next if workbook.empty?(row, col, sheet) + + all << { + row: row.to_s, + column: col.to_s, + content: workbook.cell(row, col, sheet).to_s, + type: workbook.celltype(row, col, sheet).to_s, + } + end + end + all + end +end diff --git a/test/formatters/test_yaml.rb b/test/formatters/test_yaml.rb new file mode 100644 index 00000000..dafc03e0 --- /dev/null +++ b/test/formatters/test_yaml.rb @@ -0,0 +1,20 @@ +require "test_helper" + +class TestRooFormatterYAML < Minitest::Test + def test_date_time_yaml + name = "time-test" + expected = File.open(TESTDIR + "/expected_results/#{name}.yml").read + with_each_spreadsheet(name: name) do |workbook| + assert_equal expected, workbook.to_yaml + end + end + + def test_bug_to_yaml_empty_sheet + formats = [:openoffice, :excelx] + with_each_spreadsheet(name: "emptysheets", format: formats) do |workbook| + workbook.default_sheet = workbook.sheets.first + workbook.to_yaml + assert_equal "", workbook.to_yaml + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 199c16f0..a5abf5f5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -81,3 +81,45 @@ def start_local_server(filename, port = nil) ensure t.kill end + +ROO_FORMATS = [ + :excelx, + :excelxm, + :openoffice, + :libreoffice +] + +# call a block of code for each spreadsheet type +# and yield a reference to the roo object +def with_each_spreadsheet(options) + if options[:format] + formats = Array(options[:format]) + invalid_formats = formats - ROO_FORMATS + unless invalid_formats.empty? + raise "invalid spreadsheet types: #{invalid_formats.join(', ')}" + end + else + formats = ROO_FORMATS + end + formats.each do |format| + begin + yield Roo::Spreadsheet.open(File.join(TESTDIR, + fixture_filename(options[:name], format))) + rescue => e + raise e, "#{e.message} for #{format}", e.backtrace unless options[:ignore_errors] + end + end +end + +def fixture_filename(name, format) + case format + when :excelx + "#{name}.xlsx" + when :excelxm + "#{name}.xlsm" + when :openoffice, :libreoffice + "#{name}.ods" + else + raise ArgumentError, "unexpected format #{format}" + end +end diff --git a/test/test_roo.rb b/test/test_roo.rb index 31127b75..44ce1f1d 100644 --- a/test/test_roo.rb +++ b/test/test_roo.rb @@ -10,49 +10,7 @@ require 'stringio' class TestRoo < Minitest::Test - FORMATS = [ - :excelx, - :excelxm, - :openoffice, - :libreoffice - ] - - LONG_RUN = false - - def fixture_filename(name, format) - case format - when :excelx - "#{name}.xlsx" - when :excelxm - "#{name}.xlsm" - when :openoffice, :libreoffice - "#{name}.ods" - else - raise ArgumentError, "unexpected format #{format}" - end - end - - # call a block of code for each spreadsheet type - # and yield a reference to the roo object - def with_each_spreadsheet(options) - if options[:format] - formats = Array(options[:format]) - invalid_formats = formats - FORMATS - unless invalid_formats.empty? - raise "invalid spreadsheet types: #{invalid_formats.join(', ')}" - end - else - formats = FORMATS - end - formats.each do |format| - begin - yield Roo::Spreadsheet.open(File.join(TESTDIR, - fixture_filename(options[:name], format))) - rescue => e - raise e, "#{e.message} for #{format}", e.backtrace unless options[:ignore_errors] - end - end - end + LONG_RUN = ENV["LONG_RUN"] ? true : false def test_sheets with_each_spreadsheet(:name=>'numbers1') do |oo| @@ -389,45 +347,6 @@ def test_mehrteilig end end - # "/tmp/xxxx" darf man unter Windows nicht verwenden, weil das nicht erkannt - # wird. - # Besser: Methode um temporaeres Dir. portabel zu bestimmen - def test_huge_document_to_csv - if LONG_RUN - with_each_spreadsheet(:name=>'Bibelbund', :format=>[ - :openoffice, - :excelx - # Google hier nicht, weil Google-Spreadsheets nicht so gross werden - # duerfen - ]) do |oo| - Dir.mktmpdir do |tempdir| - assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A') - assert_equal "Tagebuch des Sekret\303\244rs. Nachrichten aus Chile", oo.cell(46,'A') - assert_equal "Tagebuch aus Chile Juli 1977", oo.cell(55,'A') - assert oo.to_csv(File.join(tempdir,"Bibelbund.csv")) - assert File.exists?(File.join(tempdir,"Bibelbund.csv")) - assert_equal "", file_diff(File.join(TESTDIR, "Bibelbund.csv"), File.join(tempdir,"Bibelbund.csv")), - "error in class #{oo.class}" - #end - end - end - end - end - - def test_bug_quotes_excelx - if LONG_RUN - with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice, :excelx]) do |oo| - oo.default_sheet = oo.sheets.first - assert_equal 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"', - oo.cell('a',76) - oo.to_csv("csv#{$$}") - assert_equal 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"', - oo.cell('a',78) - File.delete_if_exist("csv#{$$}") - end - end - end - def test_bug_mehrere_datum with_each_spreadsheet(:name=>'numbers1') do |oo| oo.default_sheet = 'Sheet5' @@ -507,17 +426,6 @@ def test_multiple_sheets end end - - def test_bug_empty_sheet - with_each_spreadsheet(:name=>'formula', :format=>[:openoffice, :excelx]) do |oo| - oo.default_sheet = 'Sheet3' # is an empty sheet - Dir.mktmpdir do |tempdir| - oo.to_csv(File.join(tempdir,"emptysheet.csv")) - assert_equal "", `cat #{File.join(tempdir,"emptysheet.csv")}` - end - end - end - def test_find_by_row_huge_document if LONG_RUN with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice, :excelx]) do |oo| @@ -796,123 +704,6 @@ def test_bug_time_nil end end - def test_date_time_to_csv - with_each_spreadsheet(:name=>'time-test') do |oo| - Dir.mktmpdir do |tempdir| - csv_output = File.join(tempdir,'time_test.csv') - assert oo.to_csv(csv_output) - assert File.exists?(csv_output) - assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/time-test.csv #{csv_output}` - # --strip-trailing-cr is needed because the test-file use 0A and - # the test on an windows box generates 0D 0A as line endings - end - end - end - - def test_boolean_to_csv - with_each_spreadsheet(:name=>'boolean') do |oo| - Dir.mktmpdir do |tempdir| - csv_output = File.join(tempdir,'boolean.csv') - assert oo.to_csv(csv_output) - assert File.exists?(csv_output) - assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/boolean.csv #{csv_output}` - # --strip-trailing-cr is needed because the test-file use 0A and - # the test on an windows box generates 0D 0A as line endings - end - end - end - def test_link_to_csv - with_each_spreadsheet(:name=>'link',:format=>:excelx) do |oo| - Dir.mktmpdir do |tempdir| - csv_output = File.join(tempdir,'link.csv') - assert oo.to_csv(csv_output) - assert File.exists?(csv_output) - assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/link.csv #{csv_output}` - # --strip-trailing-cr is needed because the test-file use 0A and - # the test on an windows box generates 0D 0A as line endings - end - end - end - def test_date_time_yaml - with_each_spreadsheet(:name=>'time-test') do |oo| - expected = - "--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n" - assert_equal expected, oo.to_yaml - end - end - - # Erstellt eine Liste aller Zellen im Spreadsheet. Dies ist nötig, weil ein einfacher - # Textvergleich des XML-Outputs nicht funktioniert, da xml-builder die Attribute - # nicht immer in der gleichen Reihenfolge erzeugt. - def init_all_cells(oo,sheet) - all = [] - oo.first_row(sheet).upto(oo.last_row(sheet)) do |row| - oo.first_column(sheet).upto(oo.last_column(sheet)) do |col| - unless oo.empty?(row,col,sheet) - all << {:row => row.to_s, - :column => col.to_s, - :content => oo.cell(row,col,sheet).to_s, - :type => oo.celltype(row,col,sheet).to_s, - } - end - end - end - all - end - - def test_to_xml - with_each_spreadsheet(:name=>'numbers1', :encoding => 'utf8') do |oo| - skip if defined? JRUBY_VERSION - oo.to_xml - sheetname = oo.sheets.first - doc = Nokogiri::XML(oo.to_xml) - sheet_count = 0 - doc.xpath('//spreadsheet/sheet').each {|tmpelem| - sheet_count += 1 - } - assert_equal 5, sheet_count - doc.xpath('//spreadsheet/sheet').each { |xml_sheet| - all_cells = init_all_cells(oo, sheetname) - x = 0 - assert_equal sheetname, xml_sheet.attributes['name'].value - xml_sheet.children.each {|cell| - if cell.attributes['name'] - expected = [all_cells[x][:row], - all_cells[x][:column], - all_cells[x][:content], - all_cells[x][:type], - ] - result = [ - cell.attributes['row'], - cell.attributes['column'], - cell.content, - cell.attributes['type'], - ] - assert_equal expected, result - x += 1 - end # if - } # end of sheet - sheetname = oo.sheets[oo.sheets.index(sheetname)+1] - } - end - end - - def test_bug_to_xml_with_empty_sheets - with_each_spreadsheet(:name=>'emptysheets', :format=>[:openoffice, :excelx]) do |oo| - oo.sheets.each { |sheet| - assert_nil oo.first_row, "first_row not nil in sheet #{sheet}" - assert_nil oo.last_row, "last_row not nil in sheet #{sheet}" - assert_nil oo.first_column, "first_column not nil in sheet #{sheet}" - assert_nil oo.last_column, "last_column not nil in sheet #{sheet}" - assert_nil oo.first_row(sheet), "first_row not nil in sheet #{sheet}" - assert_nil oo.last_row(sheet), "last_row not nil in sheet #{sheet}" - assert_nil oo.first_column(sheet), "first_column not nil in sheet #{sheet}" - assert_nil oo.last_column(sheet), "last_column not nil in sheet #{sheet}" - } - oo.to_xml - end - end - def test_bug_simple_spreadsheet_time_bug # really a bug? are cells really of type time? # No! :float must be the correct type @@ -1290,57 +1081,6 @@ def test_labeled_cells end end - require 'matrix' - def test_matrix - with_each_spreadsheet(:name => 'matrix', :format => :openoffice) do |oo| - oo.default_sheet = oo.sheets.first - assert_equal Matrix[ - [1.0, 2.0, 3.0], - [4.0, 5.0, 6.0], - [7.0, 8.0, 9.0] ], oo.to_matrix - end - end - - def test_matrix_selected_range - with_each_spreadsheet(:name => 'matrix', :format=>:openoffice) do |oo| - oo.default_sheet = 'Sheet2' - assert_equal Matrix[ - [1.0, 2.0, 3.0], - [4.0, 5.0, 6.0], - [7.0, 8.0, 9.0] ], oo.to_matrix(3,4,5,6) - end - end - - def test_matrix_all_nil - with_each_spreadsheet(:name => 'matrix', :format=>:openoffice) do |oo| - oo.default_sheet = 'Sheet2' - assert_equal Matrix[ - [nil, nil, nil], - [nil, nil, nil], - [nil, nil, nil] ], oo.to_matrix(10,10,12,12) - end - end - - def test_matrix_values_and_nil - with_each_spreadsheet(:name => 'matrix', :format=>:openoffice) do |oo| - oo.default_sheet = 'Sheet3' - assert_equal Matrix[ - [1.0, nil, 3.0], - [4.0, 5.0, 6.0], - [7.0, 8.0, nil] ], oo.to_matrix(1,1,3,3) - end - end - - def test_matrix_specifying_sheet - with_each_spreadsheet(:name => 'matrix', :format => :openoffice) do |oo| - oo.default_sheet = oo.sheets.first - assert_equal Matrix[ - [1.0, nil, 3.0], - [4.0, 5.0, 6.0], - [7.0, 8.0, nil] ], oo.to_matrix(nil, nil, nil, nil, 'Sheet3') - end - end - # #formulas of an empty sheet should return an empty array and not result in # an error message # 2011-06-24 @@ -1353,43 +1093,6 @@ def test_bug_formulas_empty_sheet end end - # #to_yaml of an empty sheet should return an empty string and not result in - # an error message - # 2011-06-24 - def test_bug_to_yaml_empty_sheet - with_each_spreadsheet(:name =>'emptysheets', - :format=>[:openoffice,:excelx]) do |oo| - oo.default_sheet = oo.sheets.first - oo.to_yaml - assert_equal('', oo.to_yaml) - end - end - - # #to_matrix of an empty sheet should return an empty matrix and not result in - # an error message - # 2011-06-25 - def test_bug_to_matrix_empty_sheet - with_each_spreadsheet(:name =>'emptysheets', - :format=>[:openoffice,:excelx]) do |oo| - oo.default_sheet = oo.sheets.first - oo.to_matrix - assert_equal(Matrix.empty(0,0), oo.to_matrix) - end - end - - # 2011-08-03 - def test_bug_datetime_to_csv - with_each_spreadsheet(:name=>'datetime') do |oo| - Dir.mktmpdir do |tempdir| - datetime_csv_file = File.join(tempdir,"datetime.csv") - - assert oo.to_csv(datetime_csv_file) - assert File.exists?(datetime_csv_file) - assert_equal "", file_diff('test/files/so_datetime.csv', datetime_csv_file) - end - end - end - def test_bug_pfand_from_windows_phone_xlsx return if defined? JRUBY_VERSION with_each_spreadsheet(:name=>'Pfand_from_windows_phone', :format=>:excelx) do |oo| From 4336db4af6d6f8932cffc5dfe59a057ee9b7d738 Mon Sep 17 00:00:00 2001 From: Steven Daniels Date: Sat, 31 Dec 2016 11:16:12 -0500 Subject: [PATCH 2/3] Add additional formula cell types: Date, TrueClass, FalseClass --- lib/roo/formatters/csv.rb | 2 +- test/files/formula_cell_types.xlsx | Bin 0 -> 23324 bytes test/formatters/test_csv.rb | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/files/formula_cell_types.xlsx diff --git a/lib/roo/formatters/csv.rb b/lib/roo/formatters/csv.rb index 14b44845..3181f091 100644 --- a/lib/roo/formatters/csv.rb +++ b/lib/roo/formatters/csv.rb @@ -64,7 +64,7 @@ def cell_to_csv(row, col, sheet) else onecell.to_s end - when DateTime + when Date, DateTime, TrueClass, FalseClass onecell.to_s else fail "unhandled onecell-class #{onecell.class}" diff --git a/test/files/formula_cell_types.xlsx b/test/files/formula_cell_types.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..2d1700b7e9a426e469f7bd47c1b78ef9055557fd GIT binary patch literal 23324 zcmeHvcUTkMw)a4gUZqM49TX9jCPjiGT?AB$ARy8^N-;_ay%zxi0clbd0Y!=e(u)-7 zy@!r~B!CbgB;VlazUMvn-1qqXai4pKCrq+4d(Yl$R{5>9c9ymVgoptk21o$_;0E5# z2#k6V0Kl~q06-6r5*jHwJGogpxtZR6>|*I^d=BpD!1a=dP$&~11h4*E>;6KI88|R1AQ@xe6;JyE1CjRU-E23M&3Ths-pBrPx`3Fy{G(|YL zhJ+IbGziB0_c4v)r2|DTO@~Y5-xxDay-MRQ)8&^Y?Hpk()FWE<3+n~06@`~ErKq{y z`-aj=f@pTa?>&{Ql7%B6ri}8KD2aj6+L(S|Nq4Ff3a---O}I0HK;eA zrw!ip-=uvwlUE%c>QKc@w<~ZHdQURBVoWmmsYUtWt}=~X7DL138&+FAd&@l@QsaJ~ z%tC`-EUdj;piJX&yeqtKe^gerd{)4PmH461{wdxW-4Xo>W_GScjdx=5rElh5E*Puh z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B%vrA>$*o<`{uT8=3ZMhOjQ8A~U3u3jt zF#H&CH}Ox^Vr75H1p7jc@-6Xz*| zHzB)F$|*MKDH%$?H}_Sgc6#p<#CcfX$TQC>qZf3+Z|YXqSl zc^v3ePj_bDM7xr-=|J)xz3tHUYn3K$Mhnv|LQy3&8!5?K^_{0@;oZIg4(hF=N^?1g zpq*;ce~8$MNk{0&7fI z&NZnoGf_xN&U~Yh&O)XAS6z6S!qfXcLkEoito%Y^cxz<__>?-q7cKY#D{+~dIhZTj znAtiVbFo~s&T(a-B|he}Yrc}yid&AfvIsG_|I~Qmo8=owrl)YJ{{VGh2~;64rUUlP2To9q-q7Vr zVmkm!Mf|pwMAKJ+k?WvHdV)Waru%!5GG3y7ND1;c=IU?Ng+KQZoHb-fVm{?8G(wyn=~RD-OcKRsdD{75nQL(ti&1Sr z%GhVwXUrOoc1zekhX+j<*$KiMbMR<;m+R--Tu3NWV?(1=8&oW|&0ceIT?!_*)9${1 zk`BA!e$Vc3O`+uai*mP+)<-g}X{9Hi&3&ILABtBvvX$FHo0bJJ?%z?9`c%1JJz5AD zlV_i?-Mf)`pZ{Z@UeY=ES&eq?QG@fR(l1px>UC8mn0lSQGRcW!m619~I=J8D%0&oG zpl-R*q4DHVoykj{uy#2nfR(}ic@f~hQ2a0Fe^L@yTjL)G_{XxOf9ZI9E&)x=-xVqSx#K_9W&Hb& z%V0&Y->=g6^Ef|O=lk18r^$X(tMBK|KbK4UTjwE)ADw?wJniQZelB75w-Ev;e~j>R zL9?F+__?Ia-v$r|OQL~vaQ$n6nV-As;5T^m95`R6i)zo`cDr%`^tCdA)H*#S#L z{1qttV}*#Hr{et&_~LIv0KkUM-wpC-wDEKApY{6R`oF*ZVb<$vz|kBanfeF4B% c_wVlg7qzObaROv80H6f_ARv!I430njKbkU0VgLXD literal 0 HcmV?d00001 diff --git a/test/formatters/test_csv.rb b/test/formatters/test_csv.rb index 5c2c47c9..77216793 100644 --- a/test/formatters/test_csv.rb +++ b/test/formatters/test_csv.rb @@ -99,4 +99,21 @@ def test_bug_datetime_to_csv end end end + + def test_true_class + assert_equal "true", cell_to_csv(1, 1) + end + + def test_false_class + assert_equal "false", cell_to_csv(2, 1) + end + + def test_date_class + assert_equal "2017-01-01", cell_to_csv(3, 1) + end + + def cell_to_csv(row, col) + filename = File.join(TESTDIR, "formula_cell_types.xlsx") + Roo::Spreadsheet.open(filename).send("cell_to_csv", row, col, "Sheet1") + end end From a3915b1647f24944dc1a402c043a6a617e883a26 Mon Sep 17 00:00:00 2001 From: Steven Daniels Date: Sat, 31 Dec 2016 11:21:32 -0500 Subject: [PATCH 3/3] Removed unnecessary method --- test/test_roo.rb | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/test/test_roo.rb b/test/test_roo.rb index 44ce1f1d..83b02991 100644 --- a/test/test_roo.rb +++ b/test/test_roo.rb @@ -560,7 +560,6 @@ def test_find_by_conditions end end - #TODO: temporaerer Test def test_seiten_als_date if LONG_RUN @@ -959,7 +958,6 @@ def test_cell_methods end end - # compare large spreadsheets def test_compare_large_spreadsheets # problematisch, weil Formeln in Excel nicht unterstützt werden @@ -1158,24 +1156,6 @@ def common_possible_bug_snowboard_cells(ss) assert_equal "168W", ss.cell(13,'o'), ss.class end - def split_coord(s) - letter = "" - number = 0 - i = 0 - while i'bug-numbered-sheet-names', :format=>:excelx) do |oo| oo.each_with_pagename { }