Skip to content

Commit

Permalink
corrects loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbarbone committed May 22, 2021
1 parent 83efcf4 commit 6d34c73
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions R/build_workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,23 @@ buildWorkbook <- function(x, asTable = FALSE, ...) {
do_call_params(writeData, params, x = x, wb = wb, .map = TRUE)
}

do_setColWidths(wb, x, params, isList)
do_call_params(freezePane, params, wb = list(wb), .map = TRUE)
invisible(wb)
}


do_setColWidths <- function(wb, x, params, isList) {
if (!isList) {
x <- list(x)
}

params$startCol <- params$startCol %||% 1
# TODO colWidths as globalOption
params$startCol <- rep_len(list(params$startCol), length.out = length(x))
params$colWidths <- params$colWidths %||% ""
params$colWidths <- rep_len(params$colWidths, length.out = length(x))
params$colWidths <- rep_len(as.list(params$colWidths), length.out = length(x))

for (i in seq_along(x)) {
for (i in seq_along(wb$worksheets)) {
if (identical(params$colWidths[[i]], "auto")) {
setColWidths(
wb,
Expand All @@ -73,12 +84,10 @@ buildWorkbook <- function(x, asTable = FALSE, ...) {
setColWidths(
wb,
sheet = i,
cols = seq_along(x[[i]]) + params$startCol[[i]] - 1L,
cols = seq_along(x[[i]]) + params$startCol[[i]] - 1L,
widths = params$colWidths[[i]]
)
}
}

do_call_params(freezePane, params, wb = list(wb), .map = TRUE)
invisible(wb)
wb
}

0 comments on commit 6d34c73

Please sign in to comment.