Skip to content

Floats formatted as Ints not being rounded #60

@dorsma

Description

@dorsma

I believe this is the same as issue #16

I have a spreadsheet that contains float values in two columns, with column B formatted the floats as integers. In the spreadsheet I see the column B values rounded, however when I read those values though simple_xlsx_reader column B values are floored.

require 'simple_xlsx_reader'

reader = SimpleXlsxReader.open('FLOATS_FORMATTED_AS_INTs.xlsx')
worksheet = reader.sheets.first

worksheet.rows.each do |row|
  break if not row[0]
  puts "#{row[0]}, #{row[1]}"
end

Output:

ORIG FLOAT, INT FORMAT
22.33, 22
21.69, 21
22.25, 22
22.24, 22
21.54, 21
21.71, 21
21.34, 21
21.22, 21
21.35, 21
20.83, 20
20.5, 20

Compare to the screenshot from the spreadsheet:
FLOATS_FORMATTED_AS_INTs

Spreadsheet attached:

FLOATS_FORMATTED_AS_INTs.xlsx

Is there any way we could have access to the actual non-formatted cell value? eg. row[1].actual

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions