ycphs / openxlsx

openxlsx - a fast way to read and write complex xslx files
https://ycphs.github.io/openxlsx/
Other
226 stars 75 forks source link

Can not save workbook with deleted data #471

Open cosmosByCarlSagan opened 5 months ago

cosmosByCarlSagan commented 5 months ago

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

torbjorn commented 5 months ago

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