Is there a way to calculate excel formulas without opening the file manually? If openxlsx is not the best option please feel free to suggest other packages. Thanks!
My goal is to paste data into an excel file (already existing) with formulas referencing the range that i am pasting data to and have excel refresh it's formulas and calculate summary stats(sums for example). I would like to update the formulas with R code and save the file so that i can read the summary values into R without opening/saving the excel file.
I want to remove the manual step (Bold below).
Workbook that i am using has two sheets: rawData and summary. the only data before i start in the file is the sum formulas on A2:D2. A2 contains =SUM(rawData!A:A)
require("openxlsx")
wb <- loadWorkbook("MyTestWorkBook.xlsx")
writeData(wb,iris, sheet="rawData")
saveWorkbook(wb,"MyTestWorkBook.xlsx",overwrite = TRUE)
From here I have the sheet 'summary' with sums of each column. I read the sheet.
read.xlsx("MyTestWorkBook.xlsx","summary")
sumA sumB sumC sumD
1 0 0 0 0
I now manually open workbook (not with R) and save
read.xlsx("MyTestWorkBook.xlsx","summary")
sumA sumB sumC sumD
1 876.5 458.6 563.7 179.9
Formulas have now calculated.