Skip to content

Commit

Permalink
Added support of writing a list of tables into xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanVoronin committed Jan 30, 2024
1 parent d9cfd47 commit f925bd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 13 additions & 5 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -607,15 +607,23 @@ xlsx.writer.openxlsx <- function(tblList, file, overwrite) {
#' Write the contents of `OUTPUT` list to an `xlsx` file. This function is supposed to be used
#' at the very end of the analysis when all output tables are prepared.
#' @param file is the name of `xlsx` file.
#' @param x a list of output tables.
#' @param overwrite should we overwrite the existing output file?
#' @param writer is the function that writes list of tables into an xlsx file.
#'
#' @export
write.xlsx.output <- function(file, overwrite = TRUE, writer = xlsx.writer.openxlsx) {
if (!exists('OUTPUT', where = globalenv()))
stop('OUTPUT does not exist in globalenv, I have nothing to write')
else
x <- OUTPUT
write.xlsx.output <- function(
file,
x = list(),
overwrite = TRUE,
writer = xlsx.writer.openxlsx
) {
if (length(x) == 0) {
if (!exists('OUTPUT', where = globalenv()))
stop('OUTPUT does not exist in globalenv, I have nothing to write')
else
x <- OUTPUT
}

x <- lapply(x, behead)

Expand Down
9 changes: 8 additions & 1 deletion man/write.xlsx.output.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f925bd8

Please sign in to comment.