R/rfl_calculate_wb.R

Defines functions rfl_calculate_wb

Documented in rfl_calculate_wb

#' Open, evaluate and save the SPC working file
#' This function calcuates the values required for the SPC by opening, evaluating and saving the the SPC template in excel
#'
#' @param workingFile Path to working file wiht data loaded into it from rfl_load_spc_model_input
#' @return location of the workingFile with the SPC calculations complete
#' @usage rfl_calculate_wb('fileToCalculate.xlsx')
rfl_calculate_wb <- function(workingFile) {
  require("RDCOMClient") # not allowed usually but only works by doing this
  # Create COM Connection to Excel
  xlApp <- COMCreate("Excel.Application")
  xlApp[['Visible']] <- FALSE
  xlApp[['DisplayAlerts']] <- FALSE

  # Open workbook
  xlWB <- xlApp[["Workbooks"]]$Open(workingFile)
  xlWB$Save()
  xlWB$Close(TRUE)

  return(workingFile)
}
royal-free-london/RFLspc documentation built on Aug. 19, 2020, 12:09 a.m.