I'm trying to automate some processes in Excel using R language and openxlsx library.
When I write new data to a cell (which works fine) that is a reference to a formula in other cells, those cells with formulas do not update their values, even after I save the file and try to read it again.
Is there any workaround to fix this behavior?
Code and workbook follow.
library(openxlsx)
getwd()
setwd('Downloads')
wb = loadWorkbook('Plan.xlsx')
wb
activeSheet(wb) = 2
activeSheet(wb)
writeData(wb, sheet=2, startCol = 2, startRow = 2, x = 'p2')
print(read.xlsx(wb, sheet=2, startRow = 2, cols = c(3,4,5), colNames = F))
saveWorkbook(wb, file = 'Plan.xlsx', overwrite = T, returnValue = T)
Tried to:
- save the file;
- close it;
- read it again;
expecting to have the cells updated with their new values.