aboutsummaryrefslogtreecommitdiffstats
path: root/lib/roo/excelx
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2023-02-08 00:40:16 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2023-02-08 00:40:16 -0500
commitb0bc0772184c68b8d4baac678c5fb707dc23af7f (patch)
tree62c95563dd5d57e9db8268227acf4cc91e75af04 /lib/roo/excelx
parente44f5d5d1935ee40a6bbb232e649d91e8aa9ce74 (diff)
parentae103e148eb3c15606b816505492d870ef062ad3 (diff)
Update upstream source from tag 'upstream/2.10.0'
Update to upstream version '2.10.0' with Debian dir 3c0f78b1f632920ec992d7bf7e43a8b0ced0b21d
Diffstat (limited to 'lib/roo/excelx')
-rw-r--r--lib/roo/excelx/cell/number.rb10
-rwxr-xr-xlib/roo/excelx/sheet_doc.rb17
-rw-r--r--lib/roo/excelx/workbook.rb1
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)