-
Notifications
You must be signed in to change notification settings - Fork 64
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
Dealing with NAN #47
Comments
This work for me x) |
Merged
Thank you for your PR. |
I have the same problem in the last version 1.10.2, how i resolve? |
send me a sample which raises exception, please. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excel uses NaN to indicate missing points in a chart, so the charting skips over the point. However, if you set a data point to Float::NaN in ruby, and write an array containing this value, the gem falls over here:
[worksheet.rb: ~line 5773]
def write_cell_value(value = '') #:nodoc:
value ||= ''
value = value.to_i if value == value.to_i
@writer.data_element('v', value)
end
on the == value.to_i test,
You get a FloatDomainError:
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/write_xlsx-0.85.3/lib/write_xlsx/worksheet.rb:5773:in `to_i': NaN (FloatDomainError)
I have fixed my local version, by adding a line to the start of the method to convert the cell to a formula:
Was wondering whether you could provide a permanent fix for the problem? I am not sure whether my approach is the correct solution, but it does work. I would be reluctant to have to write a wrapper around the gem which checks all array writes for NaNs and then convert to writing individual cells as formulas? The problem exists because Excel represents NaN as a formula rather than a type of Float.
The text was updated successfully, but these errors were encountered: