ycphs/openxlsx

writeData( withFilter = TRUE ) fails to apply filters when opened with LibreOffice Calc

Opened this issue · 0 comments

Bug
Parameter withFilter = TRUE in function writeData() works only on the last sheet when opened by Libreoffice Calc.

To Reproduce

library(openxlsx)
wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
addWorksheet(wb, "Sheet 2")
writeData(wb, 1, x = iris, withFilter = TRUE)
writeData(wb, 2, x = iris, withFilter = TRUE)
saveWorkbook(wb, file = "addFilterExample.xlsx", overwrite = TRUE)
openXL("addFilterExample.xlsx")
#> Only Libreoffice/OpenOffice found; I'll use it.

Created on 2023-10-09 with reprex v2.0.2.9000

Expected behavior
"Sheet 1" should also have filters applied to the header.
(Works as expected in MS Excel.)

Additional context
Adding more sheets results in the same behavior, where only the final sheet contains filters.

Test on in Libreoffice 7.3.2.2 on Ubuntu, and Libreoffice 7.6.2 on Windows. Same results in both.

Also, thank you for making a great package; I use it constantly.