diff options
| author | 2023-02-08 00:39:56 -0500 | |
|---|---|---|
| committer | 2023-02-08 00:39:56 -0500 | |
| commit | ae103e148eb3c15606b816505492d870ef062ad3 (patch) | |
| tree | b7916225d76ac8d1db28feff7aa46a4ee672b3dc /lib/roo/excelx | |
| parent | f5fb17e5a64b215644bc104f099dad8c2f10c37d (diff) | |
New upstream version 2.10.0.upstream/2.10.0
Diffstat (limited to 'lib/roo/excelx')
| -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 |
3 files changed, 24 insertions, 4 deletions
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) |
