R/form_to_xlsx.R

Defines functions form_to_xlsx

Documented in form_to_xlsx

#' Export a (pre)registration form to an Excel spreadsheet
#'
#' @param x The (pre)registration form (as produced by a call
#' to [preregr::form_create()]) or initialized `preregr` object
#' (as produced by a call to [preregr::prereg_initialize()]).
#' @param file The file to write the spreadsheet to.
#'
#' @return x, invisibly
#' @export
form_to_xlsx <- function(x,
                         file) {

  x <- retrieve_form(x);

  if (!requireNamespace("writexl", quietly = TRUE)) {
    stop("To write spreadsheets, you need to have `writexl` installed!");
  }

  writexl::write_xlsx(
    x,
    file
  );

  return(invisible(x));

}

Try the preregr package in your browser

Any scripts or data that you put into this service are public.

preregr documentation built on May 31, 2023, 7:10 p.m.