openxlsx icon indicating copy to clipboard operation
openxlsx copied to clipboard

Can not save workbook with deleted data

Open cosmosByCarlSagan opened this issue 8 months ago • 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

cosmosByCarlSagan avatar May 29 '24 14:05 cosmosByCarlSagan