From 1c2c69e88c5d4c02ecf85d896efcba8ac7949084 Mon Sep 17 00:00:00 2001 From: Aaron Michal Date: Mon, 8 Oct 2018 09:03:00 -0400 Subject: [PATCH] Add support for "1e6" as scientific notation (#433) --- lib/roo/excelx/cell/number.rb | 2 +- test/excelx/cell/test_number.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/roo/excelx/cell/number.rb b/lib/roo/excelx/cell/number.rb index 8c7bd184..ca2dac3a 100644 --- a/lib/roo/excelx/cell/number.rb +++ b/lib/roo/excelx/cell/number.rb @@ -24,7 +24,7 @@ def create_numeric(number) when /\.0/ Float(number) else - (number.include?('.') || (/\A[-+]?\d+E[-+]\d+\z/i =~ number)) ? Float(number) : Integer(number) + (number.include?('.') || (/\A[-+]?\d+E[-+]?\d+\z/i =~ number)) ? Float(number) : Integer(number) end end diff --git a/test/excelx/cell/test_number.rb b/test/excelx/cell/test_number.rb index 0f22a093..5c8d726a 100644 --- a/test/excelx/cell/test_number.rb +++ b/test/excelx/cell/test_number.rb @@ -25,6 +25,11 @@ def test_simple_scientific_notation assert_kind_of(Float, cell.value) end + def test_very_simple_scientific_notation + cell = Roo::Excelx::Cell::Number.new '1e6', nil, ['0'], nil, nil, nil + assert_kind_of(Float, cell.value) + end + def test_percent cell = Roo::Excelx::Cell::Number.new '42.1', nil, ['0.00%'], nil, nil, nil assert_kind_of(Float, cell.value)