awalker89 / openxlsx

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

Data not formatted correctly on some Windows platforms #476

Open hughjonesd opened 5 years ago

hughjonesd commented 5 years ago

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.

Any ideas of what might cause such a bug?