[GH-ISSUE #122] Support for NaN, Inf, -Inf #101

Closed
opened 2026-05-05 11:40:47 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @jeroen on GitHub (Aug 22, 2017).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/122

Originally assigned to: @jmcnamara on GitHub.

Would it be possible to add a line to the worksheet_write_number documentation if excel supports special values NaN, Inf, and -Inf. I just tried:

assert_lxw(worksheet_write_number(sheet, x, y, INFINITY, NULL));

Which does not raise an error in lxw, however when I open the file in excel it gives an error that it is "damaged".

Originally created by @jeroen on GitHub (Aug 22, 2017). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/122 Originally assigned to: @jmcnamara on GitHub. Would it be possible to add a line to the `worksheet_write_number` documentation if excel supports special values `NaN`, `Inf`, and `-Inf`. I just tried: ```c assert_lxw(worksheet_write_number(sheet, x, y, INFINITY, NULL)); ``` Which does not raise an error in lxw, however when I open the file in excel it gives an error that it is "damaged".
gitea-mirror 2026-05-05 11:40:47 -06:00
Author
Owner

@jmcnamara commented on GitHub (Aug 22, 2017):

Excel doesn't support NaN, Inf or -Inf as a value. It does support them as the result of a formula but not as a number.

I can add something to the docs to say Excel, and thus libxlsxwriter, doesn't support them but, for performance reasons, I won't add a check. The end user can do it in their application if they need it.

<!-- gh-comment-id:324134304 --> @jmcnamara commented on GitHub (Aug 22, 2017): Excel doesn't support `NaN`, `Inf` or `-Inf` as a value. It does support them as the result of a formula but not as a number. I can add something to the docs to say Excel, and thus libxlsxwriter, doesn't support them but, for performance reasons, I won't add a check. The end user can do it in their application if they need it.
Author
Owner

@jeroen commented on GitHub (Aug 22, 2017):

OK thanks. I figured this from trying but wasn't sure. The weird thing is that if you insert INFINITY or NAN, excel first shows a warning that the document is damanged, but then does properly display nan or inf inside the cell, making it look as if it can be supported.

<!-- gh-comment-id:324136033 --> @jeroen commented on GitHub (Aug 22, 2017): OK thanks. I figured this from trying but wasn't sure. The weird thing is that if you insert `INFINITY` or `NAN`, excel first shows a warning that the document is damanged, but then does properly display `nan` or `inf` inside the cell, making it look as if it can be supported.
Author
Owner

@jmcnamara commented on GitHub (Aug 22, 2017):

but then does properly display nan or inf inside the cell, making it look as if it can be supported.

Yes, but they are just converted to strings, right? As I said Excel doesn't support them as numbers.

You can handle the values as strings in your application in a similar way if you like.

Btw, what lib/application are you using libxlsxwriter in. I see that you have a very active GitHub timeline. :-)

<!-- gh-comment-id:324142820 --> @jmcnamara commented on GitHub (Aug 22, 2017): > but then does properly display nan or inf inside the cell, making it look as if it can be supported. Yes, but they are just converted to strings, right? As I said Excel doesn't support them as numbers. You can handle the values as strings in your application in a similar way if you like. Btw, what lib/application are you using libxlsxwriter in. I see that you have a very active GitHub timeline. :-)
Author
Owner

@jeroen commented on GitHub (Aug 22, 2017):

I am writing bindings for R: https://github.com/ropensci/writexl

<!-- gh-comment-id:324143844 --> @jeroen commented on GitHub (Aug 22, 2017): I am writing bindings for R: https://github.com/ropensci/writexl
Author
Owner

@jmcnamara commented on GitHub (Aug 30, 2017):

I am writing bindings for R: https://github.com/ropensci/writexl

Cool.

Could you add libxlsxwriter as a "topic" under the title of your GitHub project like in libxlsxwriter so that your project shows up in this list.

I can add something to the docs to say Excel, and thus libxlsxwriter, doesn't support them but, for performance reasons, I won't add a check. The end user can do it in their application if they need it.

I've added a note about handling (or not handling) NaN, Inf or -Inf to the worksheet_write_number() docs.

Thanks.

<!-- gh-comment-id:325846165 --> @jmcnamara commented on GitHub (Aug 30, 2017): > I am writing bindings for R: https://github.com/ropensci/writexl Cool. Could you add `libxlsxwriter` as a "topic" under the title of your GitHub project like in [libxlsxwriter](https://github.com/jmcnamara/libxlsxwriter) so that your project shows up in [this list](https://github.com/search?q=topic%3Alibxlsxwriter&type=Repositories). > I can add something to the docs to say Excel, and thus libxlsxwriter, doesn't support them but, for performance reasons, I won't add a check. The end user can do it in their application if they need it. I've added a note about handling (or not handling) NaN, Inf or -Inf to the [worksheet_write_number() docs](http://libxlsxwriter.github.io/worksheet_8h.html#ad9fc47d3beaa2ab4759414e8580c2289). Thanks.
Author
Owner

@jeroen commented on GitHub (Aug 30, 2017):

OK I have added the topic to the repo.

<!-- gh-comment-id:325931073 --> @jeroen commented on GitHub (Aug 30, 2017): OK I have added the topic to the repo.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#101
No description provided.