diff options
| author | 2023-02-08 00:39:56 -0500 | |
|---|---|---|
| committer | 2023-02-08 00:39:56 -0500 | |
| commit | ae103e148eb3c15606b816505492d870ef062ad3 (patch) | |
| tree | b7916225d76ac8d1db28feff7aa46a4ee672b3dc /lib | |
| parent | f5fb17e5a64b215644bc104f099dad8c2f10c37d (diff) | |
New upstream version 2.10.0.upstream/2.10.0
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/roo/base.rb | 6 | ||||
| -rw-r--r-- | lib/roo/excelx/cell/number.rb | 10 | ||||
| -rwxr-xr-x | lib/roo/excelx/sheet_doc.rb | 17 | ||||
| -rw-r--r-- | lib/roo/excelx/workbook.rb | 1 | ||||
| -rw-r--r-- | lib/roo/open_office.rb | 7 | ||||
| -rw-r--r-- | lib/roo/version.rb | 2 |
6 files changed, 34 insertions, 9 deletions
diff --git a/lib/roo/base.rb b/lib/roo/base.rb index f4ac9a3..91c8d1c 100644 --- a/lib/roo/base.rb +++ b/lib/roo/base.rb @@ -250,8 +250,10 @@ class Roo::Base # iterate through all worksheets of a document def each_with_pagename - sheets.each do |s| - yield sheet(s, true) + Enumerator.new do |yielder| + sheets.each do |s| + yielder << sheet(s, true) + end end end diff --git a/lib/roo/excelx/cell/number.rb b/lib/roo/excelx/cell/number.rb index 7ea48b5..5cd9b55 100644 --- a/lib/roo/excelx/cell/number.rb +++ b/lib/roo/excelx/cell/number.rb @@ -66,6 +66,16 @@ module Roo when '##0.0E+0' then '%.1E' when "_-* #,##0.00\\ _€_-;\\-* #,##0.00\\ _€_-;_-* \"-\"??\\ _€_-;_-@_-" then number_format('%.2f', '-%.2f') when '@' then proc { |number| number } + when /^(?:_\()?"([^"]*)"(?:\* )?([^_]+)/ + proc do |number| + formatted_number = generate_formatter($2).call(number) + "#{$1}#{formatted_number}" + end + when /^_[- \(]\[\$([^-]*)[^#@]+([^_]+)/ + proc do |number| + formatted_number = generate_formatter($2).call(number) + "#{$1}#{formatted_number}" + end else raise "Unknown format: #{format.inspect}" end diff --git a/lib/roo/excelx/sheet_doc.rb b/lib/roo/excelx/sheet_doc.rb index adbb77a..7a09725 100755 --- a/lib/roo/excelx/sheet_doc.rb +++ b/lib/roo/excelx/sheet_doc.rb @@ -211,10 +211,19 @@ module Roo extracted_cells = {} empty_cell = @options[:empty_cell] - doc.xpath('/worksheet/sheetData/row/c').each do |cell_xml| - coordinate = ::Roo::Utils.extract_coordinate(cell_xml["r"]) - cell = cell_from_xml(cell_xml, hyperlinks(relationships)[coordinate], coordinate, empty_cell) - extracted_cells[coordinate] = cell if cell + doc.xpath('/worksheet/sheetData/row').each.with_index(1) do |row_xml, ycoord| + row_xml.xpath('c').each.with_index(1) do |cell_xml, xcoord| + r = cell_xml['r'] + coordinate = + if r.nil? + ::Roo::Excelx::Coordinate.new(ycoord, xcoord) + else + ::Roo::Utils.extract_coordinate(r) + end + + cell = cell_from_xml(cell_xml, hyperlinks(relationships)[coordinate], coordinate, empty_cell) + extracted_cells[coordinate] = cell if cell + end end expand_merged_ranges(extracted_cells) if @options[:expand_merged_ranges] diff --git a/lib/roo/excelx/workbook.rb b/lib/roo/excelx/workbook.rb index c21bb1f..aba5720 100644 --- a/lib/roo/excelx/workbook.rb +++ b/lib/roo/excelx/workbook.rb @@ -32,6 +32,7 @@ module Roo doc.xpath('//definedName').each_with_object({}) do |defined_name, hash| # "Sheet1!$C$5" sheet, coordinates = defined_name.text.split('!$', 2) + next unless coordinates col, row = coordinates.split('$') name = defined_name['name'] hash[name] = Label.new(name, sheet, row, col) diff --git a/lib/roo/open_office.rb b/lib/roo/open_office.rb index f172363..542c5b4 100644 --- a/lib/roo/open_office.rb +++ b/lib/roo/open_office.rb @@ -423,7 +423,10 @@ module Roo @style[sheet][key] = style_name case @cell_type[sheet][key] when :float - @cell[sheet][key] = (table_cell.attributes['value'].to_s.include?(".") || table_cell.children.first.text.include?(".")) ? v.to_f : v.to_i + value = (table_cell.attributes['value'].to_s.include?(".") || table_cell.children.first.text.include?(".")) ? v.to_f : v.to_i + value = 'true' if formula == '=TRUE()' + value = 'false' if formula == '=FALSE()' + @cell[sheet][key] = value when :percentage @cell[sheet][key] = v.to_f when :string @@ -517,7 +520,7 @@ module Roo str_v += child.content #.text end end - str_v.gsub!(/'/, "'") # special case not supported by unescapeHTML + str_v = str_v.gsub(/'/, "'") # special case not supported by unescapeHTML str_v = CGI.unescapeHTML(str_v) end # == 'p' end diff --git a/lib/roo/version.rb b/lib/roo/version.rb index d2bb2bf..0ad4acc 100644 --- a/lib/roo/version.rb +++ b/lib/roo/version.rb @@ -1,3 +1,3 @@ module Roo - VERSION = "2.9.0" + VERSION = "2.10.0" end |
