ropensci / writexl

Portable, light-weight data frame to xlsx exporter for R
https://docs.ropensci.org/writexl
Other
210 stars 17 forks source link

write_xlsx gives 2 errors when writing dates with NA - version 1.4.1 #63

Closed mikecrobp closed 2 years ago

mikecrobp commented 2 years ago

The following code generates 2 issues

TodayDate <- as.POSIXct.Date(Sys.Date(),tz = "UTC")

df <- as_tibble(cbind.data.frame(datecol = rep(TodayDate,2), numcol = 1:2))

df[1,1] = NA
df[1,2] = NA

write_xlsx(df, path = "wxl.xlsx")

Issues:

  1. Excel says the file is corrupt and then prompts to fix it
  2. NA in Date col is now shown as nan(snan)

No issue with 1.4.0

jeroen commented 2 years ago

Hmm I don't think anything has changed in writexl, but maybe this is related to recent changes in base R wrt dates? Did you maybe test with r-devel?

mikecrobp commented 2 years ago

I am using very vanilla environment. R 4.2.1 plus packages based on binaries and source. Regressing 4.1.1 to 4.1.0 seemed to make the difference.

I am very happy to do any other testing you need

jeroen commented 2 years ago

Can you test with the new version?

install.packages("writexl", repos = "https://ropensci.r-universe.dev")
mikecrobp commented 2 years ago

Can you test with the new version?

install.packages("writexl", repos = "https://ropensci.r-universe.dev")

Yes - that works for me. Thank you