Skip to content

Commit

Permalink
Merge bbac656 into a0533c3
Browse files Browse the repository at this point in the history
  • Loading branch information
chopraanmol1 committed Jan 7, 2019
2 parents a0533c3 + bbac656 commit a610888
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/roo/excelx/cell/number.rb
Expand Up @@ -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, 10)
end
end

Expand Down
20 changes: 16 additions & 4 deletions spec/lib/roo/excelx_spec.rb
Expand Up @@ -320,6 +320,18 @@
end
end

describe '#row' do
context 'integers with leading zero'
let(:path) { 'test/files/number_with_zero_prefix.xlsx' }

it 'returns base 10 integer' do
(1..50).each do |row_index|
range_start = (row_index - 1) * 20 + 1
expect(subject.row(row_index)).to eq (range_start..(range_start+19)).to_a
end
end
end

describe '#excelx_format' do
let(:path) { 'test/files/style.xlsx' }

Expand Down Expand Up @@ -498,15 +510,15 @@
describe '#html_strings' do
describe "HTML Parsing Enabling" do
let(:path) { 'test/files/html_strings_formatting.xlsx' }

it 'returns the expected result' do
expect(subject.excelx_value(1, 1, "Sheet1")).to eq("This has no formatting.")
expect(subject.excelx_value(2, 1, "Sheet1")).to eq("<html>This has<b> bold </b>formatting.</html>")
expect(subject.excelx_value(2, 2, "Sheet1")).to eq("<html>This has <i>italics</i> formatting.</html>")
expect(subject.excelx_value(2, 3, "Sheet1")).to eq("<html>This has <u>underline</u> format.</html>")
expect(subject.excelx_value(2, 4, "Sheet1")).to eq("<html>Superscript. x<sup>123</sup></html>")
expect(subject.excelx_value(2, 5, "Sheet1")).to eq("<html>SubScript. T<sub>j</sub></html>")

expect(subject.excelx_value(3, 1, "Sheet1")).to eq("<html>Bold, italics <b><i>together</i></b>.</html>")
expect(subject.excelx_value(3, 2, "Sheet1")).to eq("<html>Bold, Underline <b><u>together</u></b>.</html>")
expect(subject.excelx_value(3, 3, "Sheet1")).to eq("<html>Bold, Superscript. <b>x</b><sup><b>N</b></sup></html>")
Expand Down Expand Up @@ -575,15 +587,15 @@
describe '#html_strings' do
describe "HTML Parsing Disabled" do
let(:path) { 'test/files/html_strings_formatting.xlsx' }

it 'returns the expected result' do
expect(subject.excelx_value(1, 1, "Sheet1")).to eq("This has no formatting.")
expect(subject.excelx_value(2, 1, "Sheet1")).to eq("This has bold formatting.")
expect(subject.excelx_value(2, 2, "Sheet1")).to eq("This has italics formatting.")
expect(subject.excelx_value(2, 3, "Sheet1")).to eq("This has underline format.")
expect(subject.excelx_value(2, 4, "Sheet1")).to eq("Superscript. x123")
expect(subject.excelx_value(2, 5, "Sheet1")).to eq("SubScript. Tj")

expect(subject.excelx_value(3, 1, "Sheet1")).to eq("Bold, italics together.")
expect(subject.excelx_value(3, 2, "Sheet1")).to eq("Bold, Underline together.")
expect(subject.excelx_value(3, 3, "Sheet1")).to eq("Bold, Superscript. xN")
Expand Down
Binary file added test/files/number_with_zero_prefix.xlsx
Binary file not shown.

0 comments on commit a610888

Please sign in to comment.