diff --git a/R/class-workbook-wrappers.R b/R/class-workbook-wrappers.R index afc15d781..9aed29d4f 100644 --- a/R/class-workbook-wrappers.R +++ b/R/class-workbook-wrappers.R @@ -520,22 +520,22 @@ wb_add_chartsheet <- function( #' #' @param wb A Workbook object to attach the new worksheet #' @param sheet A name for the new worksheet -#' @param gridLines A logical. If `FALSE`, the worksheet grid lines will be +#' @param grid_lines A logical. If `FALSE`, the worksheet grid lines will be #' hidden. -#' @param rowColHeaders A logical. If `FALSE`, the worksheet colname and rowname will be +#' @param row_col_headers A logical. If `FALSE`, the worksheet colname and rowname will be #' hidden. -#' @param tabColor Color of the worksheet tab. A valid color (belonging to +#' @param tab_color Color of the worksheet tab. A valid color (belonging to #' colors()) or a valid hex color beginning with "#" #' @param zoom A numeric between 10 and 400. Worksheet zoom level as a #' percentage. -#' @param header,oddHeader,evenHeader,firstHeader,footer,oddFooter,evenFooter,firstFooter +#' @param header,odd_header,even_header,first_header,footer,odd_footer,even_footer,first_footer #' Character vector of length 3 corresponding to positions left, center, #' right. `header` and `footer` are used to default additional arguments. #' Setting `even`, `odd`, or `first`, overrides `header`/`footer`. Use `NA` to #' skip a position. #' @param visible If FALSE, sheet is hidden else visible. -#' @param hasDrawing If TRUE prepare a drawing output (TODO does this work?) -#' @param paperSize An integer corresponding to a paper size. See ?ws_page_setup for +#' @param has_drawing If TRUE prepare a drawing output (TODO does this work?) +#' @param paper_size An integer corresponding to a paper size. See ?ws_page_setup for #' details. #' @param orientation One of "portrait" or "landscape" #' @param hdpi Horizontal DPI. Can be set with options("openxlsx2.dpi" = X) or @@ -597,46 +597,46 @@ wb_add_chartsheet <- function( #' wb$add_data(sheet = 8, 1:400) wb_add_worksheet <- function( wb, - sheet = next_sheet(), - gridLines = TRUE, - rowColHeaders = TRUE, - tabColor = NULL, - zoom = 100, - header = NULL, - footer = NULL, - oddHeader = header, - oddFooter = footer, - evenHeader = header, - evenFooter = footer, - firstHeader = header, - firstFooter = footer, - visible = c("true", "false", "hidden", "visible", "veryhidden"), - hasDrawing = FALSE, - paperSize = getOption("openxlsx2.paperSize", default = 9), - orientation = getOption("openxlsx2.orientation", default = "portrait"), - hdpi = getOption("openxlsx2.hdpi", default = getOption("openxlsx2.dpi", default = 300)), - vdpi = getOption("openxlsx2.vdpi", default = getOption("openxlsx2.dpi", default = 300)), + sheet = next_sheet(), + grid_lines = TRUE, + row_col_headers = TRUE, + tab_color = NULL, + zoom = 100, + header = NULL, + footer = NULL, + odd_header = header, + odd_footer = footer, + even_header = header, + even_footer = footer, + first_header = header, + first_footer = footer, + visible = c("true", "false", "hidden", "visible", "veryhidden"), + has_drawing = FALSE, + paper_size = getOption("openxlsx2.paperSize", default = 9), + orientation = getOption("openxlsx2.orientation", default = "portrait"), + hdpi = getOption("openxlsx2.hdpi", default = getOption("openxlsx2.dpi", default = 300)), + vdpi = getOption("openxlsx2.vdpi", default = getOption("openxlsx2.dpi", default = 300)), ... ) { assert_workbook(wb) wb$clone()$add_worksheet( - sheet = sheet, - gridLines = gridLines, - rowColHeaders = rowColHeaders, - tabColor = tabColor, - zoom = zoom, - oddHeader = headerFooterSub(oddHeader), - oddFooter = headerFooterSub(oddFooter), - evenHeader = headerFooterSub(evenHeader), - evenFooter = headerFooterSub(evenFooter), - firstHeader = headerFooterSub(firstHeader), - firstFooter = headerFooterSub(firstFooter), - visible = visible, - paperSize = paperSize, - orientation = orientation, - vdpi = vdpi, - hdpi = hdpi, - ... = ... + sheet = sheet, + grid_lines = grid_lines, + row_col_headers = row_col_headers, + tab_color = tab_color, + zoom = zoom, + odd_header = headerFooterSub(odd_header), + odd_footer = headerFooterSub(odd_footer), + even_header = headerFooterSub(even_header), + even_footer = headerFooterSub(even_footer), + first_header = headerFooterSub(first_header), + first_footer = headerFooterSub(first_footer), + visible = visible, + paper_size = paper_size, + orientation = orientation, + vdpi = vdpi, + hdpi = hdpi, + ... = ... ) } diff --git a/R/class-workbook.R b/R/class-workbook.R index 94040020f..fd8d20897 100644 --- a/R/class-workbook.R +++ b/R/class-workbook.R @@ -492,48 +492,51 @@ wbWorkbook <- R6::R6Class( #' @description #' Add worksheet to the `wbWorkbook` object #' @param sheet sheet - #' @param gridLines gridLines - #' @param rowColHeaders rowColHeaders - #' @param tabColor tabColor + #' @param grid_lines gridLines + #' @param row_col_headers rowColHeaders + #' @param tab_color tabColor #' @param zoom zoom #' @param header header #' @param footer footer - #' @param oddHeader oddHeader - #' @param oddFooter oddFooter - #' @param evenHeader evenHeader - #' @param evenFooter evenFooter - #' @param firstHeader firstHeader - #' @param firstFooter firstFooter + #' @param odd_header oddHeader + #' @param odd_footer oddFooter + #' @param even_header evenHeader + #' @param even_footer evenFooter + #' @param first_header firstHeader + #' @param first_footer firstFooter #' @param visible visible - #' @param hasDrawing hasDrawing - #' @param paperSize paperSize + #' @param has_drawing hasDrawing + #' @param paper_size paperSize #' @param orientation orientation #' @param hdpi hdpi #' @param vdpi vdpi #' @param ... ... #' @return The `wbWorkbook` object, invisibly add_worksheet = function( - sheet = next_sheet(), - gridLines = TRUE, - rowColHeaders = TRUE, - tabColor = NULL, - zoom = 100, - header = NULL, - footer = NULL, - oddHeader = header, - oddFooter = footer, - evenHeader = header, - evenFooter = footer, - firstHeader = header, - firstFooter = footer, - visible = c("true", "false", "hidden", "visible", "veryhidden"), - hasDrawing = FALSE, - paperSize = getOption("openxlsx2.paperSize", default = 9), - orientation = getOption("openxlsx2.orientation", default = "portrait"), - hdpi = getOption("openxlsx2.hdpi", default = getOption("openxlsx2.dpi", default = 300)), - vdpi = getOption("openxlsx2.vdpi", default = getOption("openxlsx2.dpi", default = 300)), + sheet = next_sheet(), + grid_lines = TRUE, + row_col_headers = TRUE, + tab_color = NULL, + zoom = 100, + header = NULL, + footer = NULL, + odd_header = header, + odd_footer = footer, + even_header = header, + even_footer = footer, + first_header = header, + first_footer = footer, + visible = c("true", "false", "hidden", "visible", "veryhidden"), + has_drawing = FALSE, + paper_size = getOption("openxlsx2.paperSize", default = 9), + orientation = getOption("openxlsx2.orientation", default = "portrait"), + hdpi = getOption("openxlsx2.hdpi", default = getOption("openxlsx2.dpi", default = 300)), + vdpi = getOption("openxlsx2.vdpi", default = getOption("openxlsx2.dpi", default = 300)), ... ) { + + standardize(...) + visible <- tolower(as.character(visible)) visible <- match.arg(visible) orientation <- match.arg(orientation, c("portrait", "landscape")) @@ -567,17 +570,16 @@ wbWorkbook <- R6::R6Class( sheet_name <- replace_legal_chars(sheet) private$validate_new_sheet(sheet_name) - if (!is.logical(gridLines) | length(gridLines) > 1) { + if (!is.logical(grid_lines) | length(grid_lines) > 1) { fail <- TRUE - msg <- c(msg, "gridLines must be a logical of length 1.") + msg <- c(msg, "grid_lines must be a logical of length 1.") } - standardize_color_names(...) - if (!is.null(tabColor)) { - if (is_wbColour(tabColor)) { - tabColor <- as.character(tabColor) + if (!is.null(tab_color)) { + if (is_wbColour(tab_color)) { + tabColor <- as.character(tab_color) } else { - tabColor <- validateColor(tabColor, "Invalid tabColor in add_worksheet.") + tabColor <- validateColor(tab_color, "Invalid tab_color in add_worksheet.") } } @@ -594,32 +596,32 @@ wbWorkbook <- R6::R6Class( } #nocov end - if (!is.null(oddHeader) & length(oddHeader) != 3) { + if (!is.null(odd_header) & length(odd_header) != 3) { fail <- TRUE msg <- c(msg, lcr("header")) } - if (!is.null(oddFooter) & length(oddFooter) != 3) { + if (!is.null(odd_footer) & length(odd_footer) != 3) { fail <- TRUE msg <- c(msg, lcr("footer")) } - if (!is.null(evenHeader) & length(evenHeader) != 3) { + if (!is.null(even_header) & length(even_header) != 3) { fail <- TRUE msg <- c(msg, lcr("evenHeader")) } - if (!is.null(evenFooter) & length(evenFooter) != 3) { + if (!is.null(even_footer) & length(even_footer) != 3) { fail <- TRUE msg <- c(msg, lcr("evenFooter")) } - if (!is.null(firstHeader) & length(firstHeader) != 3) { + if (!is.null(first_header) & length(first_header) != 3) { fail <- TRUE msg <- c(msg, lcr("firstHeader")) } - if (!is.null(firstFooter) & length(firstFooter) != 3) { + if (!is.null(first_footer) & length(first_footer) != 3) { fail <- TRUE msg <- c(msg, lcr("firstFooter")) } @@ -677,18 +679,18 @@ wbWorkbook <- R6::R6Class( ## append to worksheets list self$append("worksheets", wbWorksheet$new( - tabColor = tabColor, - oddHeader = oddHeader, - oddFooter = oddFooter, - evenHeader = evenHeader, - evenFooter = evenFooter, - firstHeader = firstHeader, - firstFooter = firstFooter, - paperSize = paperSize, - orientation = orientation, - hdpi = hdpi, - vdpi = vdpi, - printGridLines = gridLines + tabColor = tab_color, + oddHeader = odd_header, + oddFooter = odd_footer, + evenHeader = even_header, + evenFooter = even_footer, + firstHeader = first_header, + firstFooter = first_footer, + paperSize = paper_size, + orientation = orientation, + hdpi = hdpi, + vdpi = vdpi, + printGridLines = grid_lines ) ) @@ -699,8 +701,8 @@ wbWorkbook <- R6::R6Class( self$worksheets[[newSheetIndex]]$set_sheetview( workbookViewId = 0, zoomScale = zoom, - showGridLines = gridLines, - showRowColHeaders = rowColHeaders, + showGridLines = grid_lines, + showRowColHeaders = row_col_headers, tabSelected = newSheetIndex == 1, rightToLeft = rightToLeft ) @@ -708,7 +710,7 @@ wbWorkbook <- R6::R6Class( ## update content_tyes ## add a drawing.xml for the worksheet - if (hasDrawing) { + if (has_drawing) { self$append("Content_Types", c( sprintf('', newSheetIndex), sprintf('', newSheetIndex) diff --git a/R/class-worksheet.R b/R/class-worksheet.R index 71b35c4ae..182868e58 100644 --- a/R/class-worksheet.R +++ b/R/class-worksheet.R @@ -140,18 +140,18 @@ wbWorksheet <- R6::R6Class( #' @description #' Creates a new `wbWorksheet` object - #' @param tabColor tabColor - #' @param oddHeader oddHeader - #' @param oddFooter oddFooter - #' @param evenHeader evenHeader - #' @param evenFooter evenFooter - #' @param firstHeader firstHeader - #' @param firstFooter firstFooter - #' @param paperSize paperSize + #' @param tab_color tabColor + #' @param odd_header oddHeader + #' @param odd_footer oddFooter + #' @param even_header evenHeader + #' @param even_footer evenFooter + #' @param first_header firstHeader + #' @param first_footer firstFooter + #' @param paper_size paperSize #' @param orientation orientation #' @param hdpi hdpi #' @param vdpi vdpi - #' @param printGridLines printGridLines + #' @param print_grid_lines printGridLines #' @return a `wbWorksheet` object initialize = function( tabColor = NULL, diff --git a/man/wbWorkbook.Rd b/man/wbWorkbook.Rd index 7dc307f9e..a3745c4c3 100644 --- a/man/wbWorkbook.Rd +++ b/man/wbWorkbook.Rd @@ -472,21 +472,21 @@ Add worksheet to the \code{wbWorkbook} object \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$add_worksheet( sheet = next_sheet(), - gridLines = TRUE, - rowColHeaders = TRUE, - tabColor = NULL, + grid_lines = TRUE, + row_col_headers = TRUE, + tab_color = NULL, zoom = 100, header = NULL, footer = NULL, - oddHeader = header, - oddFooter = footer, - evenHeader = header, - evenFooter = footer, - firstHeader = header, - firstFooter = footer, + odd_header = header, + odd_footer = footer, + even_header = header, + even_footer = footer, + first_header = header, + first_footer = footer, visible = c("true", "false", "hidden", "visible", "veryhidden"), - hasDrawing = FALSE, - paperSize = getOption("openxlsx2.paperSize", default = 9), + has_drawing = FALSE, + paper_size = getOption("openxlsx2.paperSize", default = 9), orientation = getOption("openxlsx2.orientation", default = "portrait"), hdpi = getOption("openxlsx2.hdpi", default = getOption("openxlsx2.dpi", default = 300)), vdpi = getOption("openxlsx2.vdpi", default = getOption("openxlsx2.dpi", default = 300)), @@ -499,11 +499,11 @@ Add worksheet to the \code{wbWorkbook} object \describe{ \item{\code{sheet}}{sheet} -\item{\code{gridLines}}{gridLines} +\item{\code{grid_lines}}{gridLines} -\item{\code{rowColHeaders}}{rowColHeaders} +\item{\code{row_col_headers}}{rowColHeaders} -\item{\code{tabColor}}{tabColor} +\item{\code{tab_color}}{tabColor} \item{\code{zoom}}{zoom} @@ -511,23 +511,23 @@ Add worksheet to the \code{wbWorkbook} object \item{\code{footer}}{footer} -\item{\code{oddHeader}}{oddHeader} +\item{\code{odd_header}}{oddHeader} -\item{\code{oddFooter}}{oddFooter} +\item{\code{odd_footer}}{oddFooter} -\item{\code{evenHeader}}{evenHeader} +\item{\code{even_header}}{evenHeader} -\item{\code{evenFooter}}{evenFooter} +\item{\code{even_footer}}{evenFooter} -\item{\code{firstHeader}}{firstHeader} +\item{\code{first_header}}{firstHeader} -\item{\code{firstFooter}}{firstFooter} +\item{\code{first_footer}}{firstFooter} \item{\code{visible}}{visible} -\item{\code{hasDrawing}}{hasDrawing} +\item{\code{has_drawing}}{hasDrawing} -\item{\code{paperSize}}{paperSize} +\item{\code{paper_size}}{paperSize} \item{\code{orientation}}{orientation} diff --git a/man/wbWorksheet.Rd b/man/wbWorksheet.Rd index 74914bced..b37932885 100644 --- a/man/wbWorksheet.Rd +++ b/man/wbWorksheet.Rd @@ -148,29 +148,29 @@ Creates a new \code{wbWorksheet} object \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{tabColor}}{tabColor} +\item{\code{orientation}}{orientation} -\item{\code{oddHeader}}{oddHeader} +\item{\code{hdpi}}{hdpi} -\item{\code{oddFooter}}{oddFooter} +\item{\code{vdpi}}{vdpi} -\item{\code{evenHeader}}{evenHeader} +\item{\code{tab_color}}{tabColor} -\item{\code{evenFooter}}{evenFooter} +\item{\code{odd_header}}{oddHeader} -\item{\code{firstHeader}}{firstHeader} +\item{\code{odd_footer}}{oddFooter} -\item{\code{firstFooter}}{firstFooter} +\item{\code{even_header}}{evenHeader} -\item{\code{paperSize}}{paperSize} +\item{\code{even_footer}}{evenFooter} -\item{\code{orientation}}{orientation} +\item{\code{first_header}}{firstHeader} -\item{\code{hdpi}}{hdpi} +\item{\code{first_footer}}{firstFooter} -\item{\code{vdpi}}{vdpi} +\item{\code{paper_size}}{paperSize} -\item{\code{printGridLines}}{printGridLines} +\item{\code{print_grid_lines}}{printGridLines} } \if{html}{\out{
}} } diff --git a/man/wb_add_worksheet.Rd b/man/wb_add_worksheet.Rd index 48d5551de..b7a4c6e65 100644 --- a/man/wb_add_worksheet.Rd +++ b/man/wb_add_worksheet.Rd @@ -7,21 +7,21 @@ wb_add_worksheet( wb, sheet = next_sheet(), - gridLines = TRUE, - rowColHeaders = TRUE, - tabColor = NULL, + grid_lines = TRUE, + row_col_headers = TRUE, + tab_color = NULL, zoom = 100, header = NULL, footer = NULL, - oddHeader = header, - oddFooter = footer, - evenHeader = header, - evenFooter = footer, - firstHeader = header, - firstFooter = footer, + odd_header = header, + odd_footer = footer, + even_header = header, + even_footer = footer, + first_header = header, + first_footer = footer, visible = c("true", "false", "hidden", "visible", "veryhidden"), - hasDrawing = FALSE, - paperSize = getOption("openxlsx2.paperSize", default = 9), + has_drawing = FALSE, + paper_size = getOption("openxlsx2.paperSize", default = 9), orientation = getOption("openxlsx2.orientation", default = "portrait"), hdpi = getOption("openxlsx2.hdpi", default = getOption("openxlsx2.dpi", default = 300)), vdpi = getOption("openxlsx2.vdpi", default = getOption("openxlsx2.dpi", default = 300)), @@ -33,28 +33,28 @@ wb_add_worksheet( \item{sheet}{A name for the new worksheet} -\item{gridLines}{A logical. If \code{FALSE}, the worksheet grid lines will be +\item{grid_lines}{A logical. If \code{FALSE}, the worksheet grid lines will be hidden.} -\item{rowColHeaders}{A logical. If \code{FALSE}, the worksheet colname and rowname will be +\item{row_col_headers}{A logical. If \code{FALSE}, the worksheet colname and rowname will be hidden.} -\item{tabColor}{Color of the worksheet tab. A valid color (belonging to +\item{tab_color}{Color of the worksheet tab. A valid color (belonging to colors()) or a valid hex color beginning with "#"} \item{zoom}{A numeric between 10 and 400. Worksheet zoom level as a percentage.} -\item{header, oddHeader, evenHeader, firstHeader, footer, oddFooter, evenFooter, firstFooter}{Character vector of length 3 corresponding to positions left, center, +\item{header, odd_header, even_header, first_header, footer, odd_footer, even_footer, first_footer}{Character vector of length 3 corresponding to positions left, center, right. \code{header} and \code{footer} are used to default additional arguments. Setting \code{even}, \code{odd}, or \code{first}, overrides \code{header}/\code{footer}. Use \code{NA} to skip a position.} \item{visible}{If FALSE, sheet is hidden else visible.} -\item{hasDrawing}{If TRUE prepare a drawing output (TODO does this work?)} +\item{has_drawing}{If TRUE prepare a drawing output (TODO does this work?)} -\item{paperSize}{An integer corresponding to a paper size. See ?ws_page_setup for +\item{paper_size}{An integer corresponding to a paper size. See ?ws_page_setup for details.} \item{orientation}{One of "portrait" or "landscape"}