awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
364 stars 79 forks source link

openxlsx writedata in RStudio renders blank or trimmed sheets #470

Open joseluissarotto opened 5 years ago

joseluissarotto commented 5 years ago

Expected Behavior

Running the following script sample from the Internet:

library(openxlsx) wb <- loadWorkbook("D:/downloads/template.xlsx") writeData(wb, sheet = "Iris Data", x = head(iris, 20)) fn <- "populated_templatev3.xlsx" if (file.exists(fn))

Delete file if it exists

file.remove(fn) saveWorkbook(wb, fn) openXL(fn)

in R and in RStudio shows a table in first sheet and a graphic in the second sheet. As shown in image

Actual Behavior

Running the script in RStudio it shows blank sheets. I also have a larger script that does a similar thing, that was running ok until I loaded R 3.6.0 and RStudio Version 1.2.1518 and now does not work any more. Please tell me if you need more information.

Steps to Reproduce the Problem

(please attach an example xlsx file if possible)

1.

2.

3.

sessionInfo()

R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18898)

Matrix products: default

Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding

locale: [1] LC_COLLATE=Spanish_Uruguay.1252 LC_CTYPE=Spanish_Uruguay.1252
[3] LC_MONETARY=Spanish_Uruguay.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Uruguay.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] openxlsx_4.1.1 forcats_0.4.0 dplyr_0.8.1 purrr_0.3.2 readr_1.3.1
[6] tidyr_0.8.3 tibble_2.1.1 ggplot2_3.1.1 tidyverse_1.2.1 stringr_1.4.0
[11] rJava_0.9-11

loaded via a namespace (and not attached): [1] tidyselect_0.2.5 xfun_0.7 haven_2.1.0 lattice_0.20-38 [5] colorspace_1.4-1 generics_0.0.2 htmltools_0.3.6 yaml_2.2.0
[9] base64enc_0.1-3 rlang_0.3.4 pillar_1.4.0 withr_2.1.2
[13] glue_1.3.1 modelr_0.1.4 readxl_1.3.1 plyr_1.8.4
[17] munsell_0.5.0 gtable_0.3.0 cellranger_1.1.0 rvest_0.3.4
[21] zip_2.0.2 evaluate_0.13 knitr_1.22 xlsxjars_0.6.1
[25] broom_0.5.2 Rcpp_1.0.1 backports_1.1.4 scales_1.0.0
[29] jsonlite_1.6 hms_0.4.2 digest_0.6.18 stringi_1.4.3
[33] grid_3.6.0 cli_1.1.0 tools_3.6.0 magrittr_1.5
[37] lazyeval_0.2.2 crayon_1.3.4 pkgconfig_2.0.2 xml2_1.2.0
[41] lubridate_1.7.4 assertthat_0.2.1 rmarkdown_1.12.2 httr_1.4.0
[45] rstudioapi_0.10 R6_2.4.0 nlme_3.1-139 compiler_3.6.0

joseluissarotto commented 5 years ago

In R works but in RStudio don't. Here is what the console shows:

library(openxlsx) wb <- loadWorkbook("D:/downloads/template.xlsx") writeData(wb, sheet = "Iris Data", x = head(iris, 20)) fn <- "populated_templatev3.xlsx" if (file.exists(fn))

  • Delete file if it exists

  • file.remove(fn) [1] TRUE saveWorkbook(wb, fn) Warning message: In .self$setColWidths(i) : NAs introduced by coercion openXL(fn)