aboutsummaryrefslogtreecommitdiffstats
path: root/lib/roo/excelx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/roo/excelx')
-rw-r--r--lib/roo/excelx/cell/number.rb3
-rw-r--r--lib/roo/excelx/cell/time.rb2
-rwxr-xr-xlib/roo/excelx/sheet_doc.rb18
3 files changed, 10 insertions, 13 deletions
diff --git a/lib/roo/excelx/cell/number.rb b/lib/roo/excelx/cell/number.rb
index 9f23c4f..7ea48b5 100644
--- a/lib/roo/excelx/cell/number.rb
+++ b/lib/roo/excelx/cell/number.rb
@@ -48,7 +48,7 @@ module Roo
when /^(0+)$/ then "%0#{$1.size}d"
when /^0\.(0+)$/ then "%.#{$1.size}f"
when '#,##0' then number_format('%.0f')
- when '#,##0.00' then number_format('%.2f')
+ when /^#,##0.(0+)$/ then number_format("%.#{$1.size}f")
when '0%'
proc do |number|
Kernel.format('%d%%', number.to_f * 100)
@@ -64,6 +64,7 @@ module Roo
when '#,##0.00;[Red](#,##0.00)' then number_format('%.2f', '[Red](%.2f)')
# FIXME: not quite sure what the format should look like in this case.
when '##0.0E+0' then '%.1E'
+ when "_-* #,##0.00\\ _€_-;\\-* #,##0.00\\ _€_-;_-* \"-\"??\\ _€_-;_-@_-" then number_format('%.2f', '-%.2f')
when '@' then proc { |number| number }
else
raise "Unknown format: #{format.inspect}"
diff --git a/lib/roo/excelx/cell/time.rb b/lib/roo/excelx/cell/time.rb
index a1f0864..5fed1e2 100644
--- a/lib/roo/excelx/cell/time.rb
+++ b/lib/roo/excelx/cell/time.rb
@@ -13,7 +13,7 @@ module Roo
super
@format = excelx_type.last
@datetime = create_datetime(base_date, value)
- @value = link ? Roo::Link.new(link, value) : (value.to_f * 86_400).to_i
+ @value = link ? Roo::Link.new(link, value) : (value.to_f * 86_400).round.to_i
end
def formatted_value
diff --git a/lib/roo/excelx/sheet_doc.rb b/lib/roo/excelx/sheet_doc.rb
index 6da4c26..adbb77a 100755
--- a/lib/roo/excelx/sheet_doc.rb
+++ b/lib/roo/excelx/sheet_doc.rb
@@ -101,12 +101,7 @@ module Roo
cell_xml_children.each do |cell|
case cell.name
when 'is'
- content = +""
- cell.children.each do |inline_str|
- if inline_str.name == 't'
- content << inline_str.content
- end
- end
+ content = cell.search('t').map(&:content).join
unless content.empty?
return Excelx::Cell.cell_class(:string).new(content, formula, style, hyperlink, coordinate)
end
@@ -197,11 +192,12 @@ module Roo
# Extract merged ranges from xml
merges = {}
doc.xpath('/worksheet/mergeCells/mergeCell').each do |mergecell_xml|
- tl, br = mergecell_xml["ref"].split(/:/).map { |ref| ::Roo::Utils.ref_to_key(ref) }
- for row in tl[0]..br[0] do
- for col in tl[1]..br[1] do
- next if row == tl[0] && col == tl[1]
- merges[[row, col]] = tl
+ src, dst = mergecell_xml["ref"].split(/:/).map { |ref| ::Roo::Utils.ref_to_key(ref) }
+ next unless cells[src]
+ for row in src[0]..dst[0] do
+ for col in src[1]..dst[1] do
+ next if row == src[0] && col == src[1]
+ merges[[row, col]] = src
end
end
end