openxlsx
openxlsx copied to clipboard
Data not formatted correctly on some Windows platforms
Expected Behavior
This is a tricky bug, because it only appears on win-builder. As a result, I can't get a minimal working example.
huxtable depends on openxlsx to write to Excel files. It does so cell-by-cell, allowing for different styles or even numeric formats in each cell.
On most platforms, the following test works:
hx <- huxtable(a = 1:2 + 0.5, b = -1:-2 + 0.5, d = letters[1:2], add_colnames = TRUE)
wb <- as_Workbook(hx)
openxlsx::saveWorkbook(wb, file = "test-xlsx.xlsx", overwrite = TRUE)
dfr <- openxlsx::read.xlsx("test-xlsx.xlsx")
expect_equal(dfr[[1]], 1:2 + 0.5)
The code for as_Workbook is visible at https://github.com/hughjonesd/huxtable/blob/master/R/Workbook.R .
Actual Behavior
But on win-builder it fails, with dfr[[1]] equal to 1:2 rather than c(1.5, 2.5).
sessionInfo()
I don't know exact win-builder details, but whatever is on there. I can't reproduce the problem on appveyor or on any non-Windows platform.
- Version of openxlsx: 4.1.0.1
- Version of R: R-devel, R-release and R-oldrel as of June 2019.
Any ideas of what might cause such a bug?