Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounding #16

Closed
hvilela opened this issue Oct 16, 2014 · 2 comments
Closed

Rounding #16

hvilela opened this issue Oct 16, 2014 · 2 comments

Comments

@hvilela
Copy link

hvilela commented Oct 16, 2014

I have a spreadsheet that contains float values formatted as integers. When I read those values though simple_xlsx_reader it returns integers instead of floats, but that's not the real problem, the thing is that it rounds differently.

Any advice? Maybe a way of force simple_xlsx_reader to always read numbers as float.

simple_xlsx_reader output:
139702
35519
3488

REF!

113544
120874
92441
10262
11017
13339
4923

captura de tela 2014-10-16 as 11 34 55

@woahdae
Copy link
Owner

woahdae commented Oct 16, 2014

First, it looks like your numbers are floats since they have a decimal in them, could you send a screenshot of the whole window? Maybe an excel file example? It's hard to get specific enough about what's going on without things like screenshots and files.

Second, what's the actual values? Based on what you provided, it looks like excel is flooring the values, where ruby is rounding half-up. I'd have to look up the spec to see what it says, maybe it differs in different versions, or it's a part of the format? Again, actual numbers and format screenshots or files would be good here. For example, if the format or data is part of a function, this could be an expression of the table-makers dilemma. Probably solvable, but not without more info.

Although better float/rounding support is the best strategy, it's worth noting this is the second issue opened about custom formatting and integer casting (see #12). As noted in #12, casting is done statically. It would be relatively easy to have a configurable casting method, and for your case you could then translate all number styles (including integer) to a plain number. However, I don't want to just provide people a way to work around a real bug, so we should investigate getting this working properly first.

@woahdae
Copy link
Owner

woahdae commented Mar 5, 2023

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants