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

wb_add_data(..., na.string = NULL) does not work with NA_character_ #429

Closed
nicojx opened this issue Nov 21, 2022 · 2 comments
Closed

wb_add_data(..., na.string = NULL) does not work with NA_character_ #429

nicojx opened this issue Nov 21, 2022 · 2 comments

Comments

@nicojx
Copy link

nicojx commented Nov 21, 2022

Hopefully my last one.. I have nearly everything working :)

When writing a character NA (NA_character_) using the option wb_add_data(..., na.strings = NULL), the cell is not left blank, but instead _openxlsx_NA is written in the cell.

wb_workbook()$
  add_worksheet("Sheet1")$
  add_data(
    dims = "A1",
    x = NA,
    na.strings = NULL
  )$
  add_data(
    dims = "A2",
    x = NA_character_,
    na.strings = NULL
  )$
  open()
@nicojx nicojx changed the title na.string = NULL does not respect NA_character_ wb_add_data(..., na.string = NULL) does not work with NA_character_ Nov 21, 2022
@JanMarvin
Copy link
Owner

PR in #430. Thanks again! For the time being you can use na.strings = "". The effect on the user side will be the same.

  • NULL erases the cell entirely in XML we write: <c r="A1"/>. The cell has no content.
  • With na.strings = "" we will write: <c r="A1"><is><t></t></is></c>.

The effect will be the same, just that the file will be a little larger in the second case (and Excel will know that the current cell content is of type character).

@nicojx
Copy link
Author

nicojx commented Nov 22, 2022

Amazing, thanks for your quick responses! :)

@nicojx nicojx closed this as completed Nov 22, 2022
JanMarvin added a commit that referenced this issue Nov 24, 2022
* handle NULL with characters

* add test

* fix test

* copy & paste error
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