ycphs/openxlsx

Can not save workbook with deleted data

Opened this issue · 1 comments

Description
If some data is deleted from a workbook via deleteData, the workbook can not be saved due to the following error:
Error: invalid assignment for reference class field ‘cols’, should be from class “integer” or a subclass (was class “numeric”)
Explicitly setting the cols argument to integer does not resolve the problem.

To Reproduce

wb <- createWorkbook()
addWorksheet(wb, "Worksheet 1")
x <- data.frame(matrix(runif(200), ncol = 10))
writeData(wb, sheet = 1, x = x, startCol = 2, startRow = 3, colNames = FALSE)
deleteData(wb, sheet = 1, cols = 3:5, rows = 5:7, gridExpand = TRUE)

saveWorkbook(wb, file = "./file.xlsx", overwrite = T)

Additional context
R version 4.3.3 (2024-02-29 ucrt)
openxlsx_4.2.5.2

The above code works fine with me, R 4.3.3 and openxlsx 4.2.5.2