R/update_excel.R

Defines functions update_excel

Documented in update_excel

#' Update an Excel file with a File Details tab
#' @importFrom broca read_full_excel
#' @export

update_excel <-
    function(readi_object, path_to_excel) {

        excel <- broca::read_full_excel(path_to_excel)
        if ("File Details" %in% names(excel)) {
            excel[["File Details"]] <-
                dplyr::bind_rows(excel[["File Details"]],
                                  readi_object@dataframe)

            broca::write_full_excel(x = excel,
                                    file = path_to_excel)
        } else {
            excel[[length(excel)+1]] <- readi_object@dataframe
            names(excel)[length(excel)] <- "File Details"

            broca::write_full_excel(x = excel,
                                    file = path_to_excel)
        }

    }
patelm9/readi documentation built on Dec. 2, 2020, 5:08 p.m.