diff --git a/NAMESPACE b/NAMESPACE index 436df3453..7b0eda434 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -30,9 +30,6 @@ export(delete_data) export(dims_to_dataframe) export(dims_to_rowcol) export(fmt_txt) -export(get_cell_refs) -export(get_date_origin) -export(guess_col_type) export(int2col) export(na_strings) export(next_sheet) @@ -41,15 +38,10 @@ export(read_xlsx) export(read_xml) export(remove_comment) export(rowcol_to_dims) -export(style_mgr) export(styles_on_sheet) export(temp_xlsx) export(wbChartSheet) -export(wbComment) -export(wbHyperlink) -export(wbSheetData) export(wbWorkbook) -export(wbWorksheet) export(wb_add_border) export(wb_add_cell_style) export(wb_add_chart_xml) @@ -130,7 +122,6 @@ export(wb_set_selected) export(wb_set_sheet_names) export(wb_set_sheet_visibility) export(wb_set_sheetview) -export(wb_sheet_data) export(wb_to_df) export(wb_ungroup_cols) export(wb_ungroup_rows) @@ -141,7 +132,6 @@ export(wb_ws) export(write_comment) export(write_data) export(write_datatable) -export(write_file) export(write_formula) export(write_xlsx) export(xl_open) diff --git a/NEWS.md b/NEWS.md index eaf520be2..3dabf968b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,18 +1,27 @@ # openxlsx2 (development version) +## New features + +* Function arguments are now defaulting to `snake_case`. For the time being, both arguments are accepted and `camelCase` will be switched to `snake_case` under the hood. Documentation like vignettes and examples are currently still displaying `camelCase` and maybe some `camelCase` function slipped through. [678](https://github.com/JanMarvin/openxlsx2/pull/678) + ## Breaking changes * Order of arguments in `wb_add_named_region()` changed, because previously overlooked `dims` argument was added. +* In various functions the order of `dims` was changed, to highlight it's importance * Cleanups * remove deprecated functions * remove deprecated arguments * `xy` argument + * arguments `col`, `row`, `cols`, `rows`. `start_col`, `start_row` and `gridExpand` were deprecated in favor of `dims`. Numeric vectors can be converted to `dims` using `rowcol_to_dims()` * deprecating function * `convertToExcelDate()` for `convert_to_excel_date()` - + + * make `get_cell_refs()`, `get_date_origin()`, `guess_col_type()`, and `write_file()` internal functions + * make classes `styles_mgr()`, `wbSheetData`, `wbWorksheet`, `wbChartsheet`, `wbComment`, `wbHyperlink` internal + *************************************************************************** diff --git a/R/class-chart-sheet.R b/R/class-chart-sheet.R index d7b52f602..1ea58ae66 100644 --- a/R/class-chart-sheet.R +++ b/R/class-chart-sheet.R @@ -101,48 +101,49 @@ wbChartSheet <- R6::R6Class( #' @description add sheetview - #' @param colorId colorId - #' @param defaultGridColor defaultGridColor - #' @param rightToLeft rightToLeft - #' @param showFormulas showFormulas - #' @param showGridLines showGridLines - #' @param showOutlineSymbols showOutlineSymbols - #' @param showRowColHeaders showRowColHeaders - #' @param showRuler showRuler - #' @param showWhiteSpace showWhiteSpace - #' @param showZeros showZeros - #' @param tabSelected tabSelected - #' @param topLeftCell topLeftCell - #' @param view view - #' @param windowProtection windowProtection - #' @param workbookViewId workbookViewId - #' @param zoomScale zoomScale - #' @param zoomScaleNormal zoomScaleNormal - #' @param zoomScalePageLayoutView zoomScalePageLayoutView - #' @param zoomScaleSheetLayoutView zoomScaleSheetLayoutView + #' @param sheet sheet + #' @param color_id,default_grid_color Integer: A color, default is 64 + #' @param right_to_left Logical: if TRUE column ordering is right to left + #' @param show_formulas Logical: if TRUE cell formulas are shown + #' @param show_grid_lines Logical: if TRUE the worksheet grid is shown + #' @param show_outline_symbols Logical: if TRUE outline symbols are shown + #' @param show_row_col_headers Logical: if TRUE row and column headers are shown + #' @param show_ruler Logical: if TRUE a ruler is shown in page layout view + #' @param show_white_space Logical: if TRUE margins are shown in page layout view + #' @param show_zeros Logical: if FALSE cells containing zero are shown blank if !showFormulas + #' @param tab_selected Integer: zero vector indicating the selected tab + #' @param top_left_cell Cell: the cell shown in the top left corner / or top right with rightToLeft + #' @param view View: "normal", "pageBreakPreview" or "pageLayout" + #' @param window_protection Logical: if TRUE the panes are protected + #' @param workbook_view_id integer: Pointing to some other view inside the workbook + #' @param zoom_scale,zoom_scale_normal,zoom_scale_page_layout_view,zoom_scale_sheet_layout_view Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc. + #' @param ... additional arguments #' @return The `wbWorksheetObject`, invisibly set_sheetview = function( - colorId = NULL, - defaultGridColor = NULL, - rightToLeft = NULL, - showFormulas = NULL, - showGridLines = NULL, - showOutlineSymbols = NULL, - showRowColHeaders = NULL, - showRuler = NULL, - showWhiteSpace = NULL, - showZeros = NULL, - tabSelected = NULL, - topLeftCell = NULL, - view = NULL, - windowProtection = NULL, - workbookViewId = NULL, - zoomScale = NULL, - zoomScaleNormal = NULL, - zoomScalePageLayoutView = NULL, - zoomScaleSheetLayoutView = NULL + color_id = NULL, + default_grid_color = NULL, + right_to_left = NULL, + show_formulas = NULL, + show_grid_lines = NULL, + show_outline_symbols = NULL, + show_row_col_headers = NULL, + show_ruler = NULL, + show_white_space = NULL, + show_zeros = NULL, + tab_selected = NULL, + top_left_cell = NULL, + view = NULL, + window_protection = NULL, + workbook_view_id = NULL, + zoom_scale = NULL, + zoom_scale_normal = NULL, + zoom_scale_page_layout_view = NULL, + zoom_scale_sheet_layout_view = NULL, + ... ) { + standardize(...) + # all zoom scales must be in the range of 10 - 400 # get existing sheetView @@ -154,27 +155,27 @@ wbChartSheet <- R6::R6Class( sheetView <- xml_attr_mod( sheetView, xml_attributes = c( - # order according to Ecma Office Open XML Part 1. p3929 - windowProtection = as_xml_attr(windowProtection), - showFormulas = as_xml_attr(showFormulas), - showGridLines = as_xml_attr(showGridLines), - showZeros = as_xml_attr(showZeros), - rightToLeft = as_xml_attr(rightToLeft), - tabSelected = as_xml_attr(tabSelected), - showRuler = as_xml_attr(showRuler), - showOutlineSymbols = as_xml_attr(showOutlineSymbols), - defaultGridColor = as_xml_attr(defaultGridColor), - showWhiteSpace = as_xml_attr(showWhiteSpace), + colorId = as_xml_attr(color_id), + defaultGridColor = as_xml_attr(default_grid_color), + rightToLeft = as_xml_attr(right_to_left), + showFormulas = as_xml_attr(show_formulas), + showGridLines = as_xml_attr(show_grid_lines), + showOutlineSymbols = as_xml_attr(show_outline_symbols), + showRowColHeaders = as_xml_attr(show_row_col_headers), + showRuler = as_xml_attr(show_ruler), + showWhiteSpace = as_xml_attr(show_white_space), + showZeros = as_xml_attr(show_zeros), + tabSelected = as_xml_attr(tab_selected), + topLeftCell = as_xml_attr(top_left_cell), view = as_xml_attr(view), - topLeftCell = as_xml_attr(topLeftCell), - colorId = as_xml_attr(colorId), - zoomScale = as_xml_attr(zoomScale), - showRowColHeaders = as_xml_attr(showRowColHeaders), - zoomScaleNormal = as_xml_attr(zoomScaleNormal), - zoomScalePageLayoutView = as_xml_attr(zoomScalePageLayoutView), - zoomScaleSheetLayoutView = as_xml_attr(zoomScaleSheetLayoutView), - workbookViewId = as_xml_attr(workbookViewId) - ) + windowProtection = as_xml_attr(window_protection), + workbookViewId = as_xml_attr(workbook_view_id), + zoomScale = as_xml_attr(zoom_scale), + zoomScaleNormal = as_xml_attr(zoom_scale_normal), + zoomScalePageLayoutView = as_xml_attr(zoom_scale_page_layout_view), + zoomScaleSheetLayoutView = as_xml_attr(zoom_scale_sheet_layout_view) + ), + remove_empty_attr = FALSE ) self$sheetViews <- xml_node_create( diff --git a/R/class-color.R b/R/class-color.R index 951931844..444764a20 100644 --- a/R/class-color.R +++ b/R/class-color.R @@ -43,27 +43,3 @@ wb_color <- function( wb_colour <- wb_color is_wbColour <- function(x) inherits(x, "wbColour") - -#' takes colour and returns color -#' @param ... ... -#' @returns void. assigns an object in the parent frame -#' @keywords internal -#' @noRd -standardize_color_names <- function(...) { - - # since R 4.1.0: ...names() - args <- list(...) - got <- names(args) - # can be Color or color - got_color <- which(grepl("colour", tolower(got))) - - if (length(got_color)) { - for (got_col in got_color) { - color <- got[got_col] - name_color <- stringi::stri_replace_all_fixed(color, "olour", "olor", ) - # since R 3.5.0: ...elt(got_col) - value_color <- args[[got_col]] - assign(name_color, value_color, parent.frame()) - } - } -} diff --git a/R/class-comment.R b/R/class-comment.R index cfd4f49e5..08313b586 100644 --- a/R/class-comment.R +++ b/R/class-comment.R @@ -2,7 +2,8 @@ #' #' A comment #' -#' @export +#' @keywords internal +#' @noRd wbComment <- R6::R6Class( "wbComment", @@ -179,6 +180,7 @@ create_comment <- function(text, #' @param comment A Comment object. See [create_comment()]. #' @param dims worksheet cell "A1" #' @rdname comment +#' @keywords internal #' @export write_comment <- function( wb, @@ -339,6 +341,7 @@ write_comment <- function( #' @param gridExpand If `TRUE`, all data in rectangle min(rows):max(rows) X min(cols):max(cols) #' will be removed. #' @rdname comment +#' @keywords internal #' @export remove_comment <- function( wb, @@ -378,7 +381,9 @@ remove_comment <- function( toKeep <- !sapply(wb$comments[[sheet]], "[[", "ref") %in% comb + # FIXME: if all comments are removed we should drop to wb$comments <- list() wb$comments[[sheet]] <- wb$comments[[sheet]][toKeep] + } wb_comment <- function(text = character(), author = character(), style = character()) { diff --git a/R/class-hyperlink.R b/R/class-hyperlink.R index f04784d5d..74f533a4f 100644 --- a/R/class-hyperlink.R +++ b/R/class-hyperlink.R @@ -2,7 +2,8 @@ #' #' A hyperlink #' -#' @export +#' @keywords internal +#' @noRd wbHyperlink <- R6::R6Class( "wbHyperlink", diff --git a/R/class-sheet-data.R b/R/class-sheet-data.R index 1c446e07d..44b561cbf 100644 --- a/R/class-sheet-data.R +++ b/R/class-sheet-data.R @@ -3,7 +3,8 @@ #' #' A hyperlink #' -#' @export +#' @keywords internal +#' @noRd wbSheetData <- R6::R6Class( "wbSheetData", public = list( @@ -27,8 +28,10 @@ wbSheetData <- R6::R6Class( ) ) +## TODO is this even used? #' @rdname wbSheetData -#' @export +#' @keywords internal +#' @noRd wb_sheet_data <- function() { wbSheetData$new() } diff --git a/R/class-style_mgr.R b/R/class-style_mgr.R index 33c2a35c6..b03b781f4 100644 --- a/R/class-style_mgr.R +++ b/R/class-style_mgr.R @@ -65,7 +65,8 @@ #' wb$set_cell_style("SUM", "C7:C16", wb$styles_mgr$get_xf_id("new_xf")) #' # wb_open(wb) #' -#' @export +#' @keywords internal +#' @noRd style_mgr <- R6::R6Class("wbStylesMgr", { public <- list( @@ -603,7 +604,6 @@ style_mgr <- R6::R6Class("wbStylesMgr", { #' "Title" #' "Total" #' "Warning Text" - #' @export init_named_style = function(name, font_name = "Arial", font_size = 11) { # we probably should only have unique named styles. check if style is found. @@ -973,7 +973,7 @@ style_mgr <- R6::R6Class("wbStylesMgr", { border_id <- self$get_border_id(border_xml) } - cell_style_xml <- create_cell_style(numFmtId = numFmtId, fontId = font_id, fillId = fill_id, borderId = border_id, is_cell_style_xf = TRUE) + cell_style_xml <- create_cell_style(num_fmt_id = numFmtId, font_id = font_id, fill_id = fill_id, border_id = border_id, is_cell_style_xf = TRUE) attr(cell_style_xml, "cellStyleXf") <- TRUE self$add(cell_style_xml, name) xf_fr_id <- self$get_cellStyleXf_id(name) diff --git a/R/class-workbook-wrappers.R b/R/class-workbook-wrappers.R index cb12da40e..ca40a5ee6 100644 --- a/R/class-workbook-wrappers.R +++ b/R/class-workbook-wrappers.R @@ -7,8 +7,9 @@ #' @param title Workbook properties title #' @param subject Workbook properties subject #' @param category Workbook properties category -#' @param datetimeCreated The time of the workbook is created +#' @param datetime_created The time of the workbook is created #' @param theme Optional theme identified by string or number +#' @param ... additional arguments #' @return A [wbWorkbook] object #' #' @export @@ -33,20 +34,22 @@ #' category = "sales" #' ) wb_workbook <- function( - creator = NULL, - title = NULL, - subject = NULL, - category = NULL, - datetimeCreated = Sys.time(), - theme = NULL + creator = NULL, + title = NULL, + subject = NULL, + category = NULL, + datetime_created = Sys.time(), + theme = NULL, + ... ) { wbWorkbook$new( - creator = creator, - title = title, - subject = subject, - category = category, - datetimeCreated = datetimeCreated, - theme = theme + creator = creator, + title = title, + subject = subject, + category = category, + datetime_created = datetime_created, + theme = theme, + ... = ... ) } @@ -86,20 +89,21 @@ wb_save <- function(wb, path = NULL, overwrite = TRUE) { #' @param wb A Workbook object containing a worksheet. #' @param sheet The worksheet to write to. Can be the worksheet index or name. #' @param x Object to be written. For classes supported look at the examples. -#' @param startCol A vector specifying the starting column to write to. -#' @param startRow A vector specifying the starting row to write to. #' @param dims Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B" +#' @param start_col A vector specifying the starting column to write to. +#' @param start_row A vector specifying the starting row to write to. #' @param array A bool if the function written is of type array -#' @param colNames If `TRUE`, column names of x are written. -#' @param rowNames If `TRUE`, data.frame row names of x are written. -#' @param withFilter If `TRUE`, add filters to the column name row. NOTE can only have one filter per worksheet. +#' @param col_names If `TRUE`, column names of x are written. +#' @param row_names If `TRUE`, data.frame row names of x are written. +#' @param with_filter If `TRUE`, add filters to the column name row. NOTE can only have one filter per worksheet. #' @param name If not NULL, a named region is defined. #' @param sep Only applies to list columns. The separator used to collapse list columns to a character vector e.g. sapply(x$list_column, paste, collapse = sep). -#' @param applyCellStyle Should we write cell styles to the workbook -#' @param removeCellStyle keep the cell style? +#' @param apply_cell_style Should we write cell styles to the workbook +#' @param remove_cell_style keep the cell style? #' @param na.strings Value used for replacing `NA` values from `x`. Default #' `na_strings()` uses the special `#N/A` value within the workbook. #' @param inline_strings write characters as inline strings +#' @param ... additional arguments #' @export #' @details Formulae written using write_formula to a Workbook object will not get picked up by read_xlsx(). #' This is because only the formula is written and left to Excel to evaluate the formula when the file is opened in Excel. @@ -110,39 +114,41 @@ wb_save <- function(wb, path = NULL, overwrite = TRUE) { #' @return A clone of `wb`` wb_add_data <- function( wb, - sheet = current_sheet(), + sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - array = FALSE, - colNames = TRUE, - rowNames = FALSE, - withFilter = FALSE, - name = NULL, - sep = ", ", - applyCellStyle = TRUE, - removeCellStyle = FALSE, - na.strings = na_strings(), - inline_strings = TRUE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + array = FALSE, + col_names = TRUE, + row_names = FALSE, + with_filter = FALSE, + name = NULL, + sep = ", ", + apply_cell_style = TRUE, + remove_cell_style = FALSE, + na.strings = na_strings(), + inline_strings = TRUE, + ... ) { assert_workbook(wb) wb$clone(deep = TRUE)$add_data( - sheet = sheet, - x = x, - startCol = startCol, - startRow = startRow, - dims = dims, - array = array, - colNames = colNames, - rowNames = rowNames, - withFilter = withFilter, - name = name, - sep = sep, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle, - na.strings = na.strings, - inline_strings = inline_strings + sheet = sheet, + x = x, + dims = dims, + start_col = start_col, + start_row = start_row, + array = array, + col_names = col_names, + row_names = row_names, + with_filter = with_filter, + name = name, + sep = sep, + apply_cell_style = apply_cell_style, + remove_cell_style = remove_cell_style, + na.strings = na.strings, + inline_strings = inline_strings, + ... = ... ) } @@ -153,15 +159,15 @@ wb_add_data <- function( #' @param wb A Workbook object containing a #' worksheet. #' @param sheet The worksheet to write to. Can be the worksheet index or name. #' @param x A dataframe. -#' @param startCol A vector specifying the starting column to write df -#' @param startRow A vector specifying the starting row to write df +#' @param start_col A vector specifying the starting column to write df +#' @param start_row A vector specifying the starting row to write df #' @param dims Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B" -#' @param colNames If `TRUE`, column names of x are written. -#' @param rowNames If `TRUE`, row names of x are written. -#' @param tableStyle Any excel table style name or "none" (see "formatting" +#' @param col_names If `TRUE`, column names of x are written. +#' @param row_names If `TRUE`, row names of x are written. +#' @param table_style Any excel table style name or "none" (see "formatting" #' vignette). -#' @param tableName name of table in workbook. The table name must be unique. -#' @param withFilter If `TRUE`, columns with have filters in the first row. +#' @param table_name name of table in workbook. The table name must be unique. +#' @param with_filter If `TRUE`, columns with have filters in the first row. #' @param sep Only applies to list columns. The separator used to collapse list #' columns to a character vector e.g. sapply(x$list_column, paste, collapse = #' sep). @@ -171,15 +177,16 @@ wb_add_data <- function( #' \if{html}{\figure{tableoptions.png}{options: width="40\%" alt="Figure: table_options.png"}} #' \if{latex}{\figure{tableoptions.pdf}{options: width=7cm}} #' -#' @param firstColumn logical. If TRUE, the first column is bold -#' @param lastColumn logical. If TRUE, the last column is bold -#' @param bandedRows logical. If TRUE, rows are color banded -#' @param bandedCols logical. If TRUE, the columns are color banded -#' @param applyCellStyle Should we write cell styles to the workbook -#' @param removeCellStyle keep the cell style? +#' @param first_column logical. If TRUE, the first column is bold +#' @param last_column logical. If TRUE, the last column is bold +#' @param banded_rows logical. If TRUE, rows are color banded +#' @param banded_cols logical. If TRUE, the columns are color banded +#' @param apply_cell_style Should we write cell styles to the workbook +#' @param remove_cell_style keep the cell style? #' @param na.strings Value used for replacing `NA` values from `x`. Default #' `na_strings()` uses the special `#N/A` value within the workbook. #' @param inline_strings write characters as inline strings +#' @param ... additional arguments #' #' @details columns of x with class Date/POSIXt, currency, accounting, #' hyperlink, percentage are automatically styled as dates, currency, @@ -190,47 +197,49 @@ wb_add_data <- function( #' @export wb_add_data_table <- function( wb, - sheet = current_sheet(), + sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - colNames = TRUE, - rowNames = FALSE, - tableStyle = "TableStyleLight9", - tableName = NULL, - withFilter = TRUE, - sep = ", ", - firstColumn = FALSE, - lastColumn = FALSE, - bandedRows = TRUE, - bandedCols = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE, - na.strings = na_strings(), - inline_strings = TRUE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + col_names = TRUE, + row_names = FALSE, + table_style = "TableStyleLight9", + table_name = NULL, + with_filter = TRUE, + sep = ", ", + first_column = FALSE, + last_column = FALSE, + banded_rows = TRUE, + banded_cols = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, + na.strings = na_strings(), + inline_strings = TRUE, + ... ) { assert_workbook(wb) wb$clone()$add_data_table( - sheet = sheet, - x = x, - startCol = startCol, - startRow = startRow, - dims = dims, - colNames = colNames, - rowNames = rowNames, - tableStyle = tableStyle, - tableName = tableName, - withFilter = withFilter, - sep = sep, - firstColumn = firstColumn, - lastColumn = lastColumn, - bandedRows = bandedRows, - bandedCols = bandedCols, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle, - na.strings = na.strings, - inline_strings = inline_strings + sheet = sheet, + x = x, + dims = dims, + start_col = start_col, + start_row = start_row, + col_names = col_names, + row_names = row_names, + table_style = table_style, + table_name = table_name, + with_filter = with_filter, + sep = sep, + first_column = first_column, + last_column = last_column, + banded_rows = banded_rows, + banded_cols = banded_cols, + apply_cell_style = apply_cell_style, + remove_cell_style = remove_cell_style, + na.strings = na.strings, + inline_strings = inline_strings, + ... = ... ) } @@ -314,38 +323,41 @@ wb_add_pivot_table <- function( #' @param wb A Workbook object containing a worksheet. #' @param sheet The worksheet to write to. Can be the worksheet index or name. #' @param x A character vector. -#' @param startCol A vector specifying the starting column to write to. -#' @param startRow A vector specifying the starting row to write to. #' @param dims Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B" +#' @param start_col A vector specifying the starting column to write to. +#' @param start_row A vector specifying the starting row to write to. #' @param array A bool if the function written is of type array #' @param cm A special kind of array function that hides the curly braces in the cell. Add this, if you see "@" inserted into your formulas -#' @param applyCellStyle Should we write cell styles to the workbook -#' @param removeCellStyle keep the cell style? +#' @param apply_cell_style Should we write cell styles to the workbook +#' @param remove_cell_style keep the cell style?, +#' @param ... additional arguments #' @family workbook wrappers #' @export wb_add_formula <- function( wb, - sheet = current_sheet(), + sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - array = FALSE, - cm = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + array = FALSE, + cm = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, + ... ) { assert_workbook(wb) wb$clone()$add_formula( - sheet = sheet, - x = x, - startCol = startCol, - startRow = startRow, - dims = dims, - array = array, - cm = cm, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle + sheet = sheet, + x = x, + dims = dims, + start_col = start_col, + start_row = start_row, + array = array, + cm = cm, + apply_cell_style = apply_cell_style, + remove_cell_style = remove_cell_style, + ... = ... ) } @@ -475,7 +487,7 @@ wb_unmerge_cells <- function(wb, sheet = current_sheet(), rows = NULL, cols = NU #' #' @param wb A Workbook object to attach the new worksheet #' @param sheet A name for the new worksheet -#' @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. @@ -488,16 +500,16 @@ wb_unmerge_cells <- function(wb, sheet = current_sheet(), rows = NULL, cols = NU #' @export wb_add_chartsheet <- function( wb, - sheet = next_sheet(), - tabColor = NULL, - zoom = 100, - visible = c("true", "false", "hidden", "visible", "veryhidden"), + sheet = next_sheet(), + tab_color = NULL, + zoom = 100, + visible = c("true", "false", "hidden", "visible", "veryhidden"), ... ) { assert_workbook(wb) wb$clone()$add_chartsheet( sheet = sheet, - tabColor = tabColor, + tab_color = tab_color, zoom = zoom, visible = visible, ... = ... @@ -508,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 @@ -585,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, + ... = ... ) } @@ -846,17 +858,15 @@ wb_remove_row_heights <- function(wb, sheet = current_sheet(), rows) { #' #' @param wb A workbook object #' @param sheet A name or index of a worksheet -#' @param startRow Row coordinate of upper left corner of figure. -#' @param startCol Column coordinate of upper left corner of figure. -#' @param rowOffset offset within cell (row) -#' @param colOffset offset within cell (column) +#' @param dims Worksheet dimension, single cell ("A1") or cell range ("A1:D4") +#' @param row_offset,col_offset offset for column and row #' @param width Width of figure. Defaults to `6`in. #' @param height Height of figure . Defaults to `4`in. -#' @param fileType File type of image +#' @param file_type File type of image #' @param units Units of width and height. Can be `"in"`, `"cm"` or `"px"` #' @param dpi Image resolution -#' @param dims Worksheet dimension, single cell ("A1") or cell range ("A1:D4") -#' @seealso [wb_add_image()] +#' @param ... additional arguments +#' @seealso [wb_add_chart_xml()] [wb_add_drawing()] [wb_add_image()] [wb_add_mschart()] #' @export #' @examples #' if (requireNamespace("ggplot2") && interactive()) { @@ -885,40 +895,39 @@ wb_remove_row_heights <- function(wb, sheet = current_sheet(), rows) { #' } wb_add_plot <- function( wb, - sheet = current_sheet(), - width = 6, - height = 4, - startRow = 1, - startCol = 1, - rowOffset = 0, - colOffset = 0, - fileType = "png", - units = "in", - dpi = 300, - dims = rowcol_to_dim(startRow, startCol) + sheet = current_sheet(), + dims = "A1", + width = 6, + height = 4, + row_offset = 0, + col_offset = 0, + file_type = "png", + units = "in", + dpi = 300, + ... ) { assert_workbook(wb) wb$clone()$add_plot( - sheet = sheet, - width = width, - height = height, - startRow = startRow, - startCol = startCol, - rowOffset = rowOffset, - colOffset = colOffset, - fileType = fileType, - units = units, - dpi = dpi, - dims = dims + sheet = sheet, + dims = dims, + width = width, + height = height, + row_offset = row_offset, + col_offset = col_offset, + file_type = file_type, + units = units, + dpi = dpi, + ... = ... ) } #' add drawings to workbook #' @param wb a wbWorkbook #' @param sheet a sheet in the workbook -#' @param xml the drawing xml as character or file #' @param dims the dimension where the drawing is added. Can be NULL -#' @param colOffset,rowOffset offsets for column and row +#' @param xml the drawing xml as character or file +#' @param col_offset,row_offset offsets for column and row +#' @param ... additional arguments #' @examples #' if (requireNamespace("rvg") && interactive()) { #' @@ -934,22 +943,86 @@ wb_add_plot <- function( #' add_drawing(xml = tmp)$ #' add_drawing(xml = tmp, dims = NULL) #' } +#' @seealso [wb_add_chart_xml()] [wb_add_image()] [wb_add_mschart()] [wb_add_plot()] #‘ @export wb_add_drawing <- function( wb, - sheet = current_sheet(), + sheet = current_sheet(), + dims = "A1", xml, - dims = NULL, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... ) { assert_workbook(wb) wb$clone()$add_drawing( - sheet = sheet, - xml = xml, - dims = dims, - colOffset = colOffset, - rowOffset = rowOffset + sheet = sheet, + dims = dims, + xml = xml, + col_offset = col_offset, + row_offset = row_offset, + ... = ... + ) +} + +#' Add mschart object to an existing workbook +#' @param wb a workbook +#' @param sheet the sheet on which the graph will appear +#' @param dims the dimensions where the sheet will appear +#' @param graph mschart object +#' @param col_offset,row_offset offsets for column and row +#' @param ... additional arguments +#' @examples +#' if (requireNamespace("mschart")) { +#' require(mschart) +#' +#' ## Add mschart to worksheet (adds data and chart) +#' scatter <- ms_scatterchart(data = iris, x = "Sepal.Length", y = "Sepal.Width", group = "Species") +#' scatter <- chart_settings(scatter, scatterstyle = "marker") +#' +#' wb <- wb_workbook() %>% +#' wb_add_worksheet() %>% +#' wb_add_mschart(dims = "F4:L20", graph = scatter) +#' +#' ## Add mschart to worksheet and use available data +#' wb <- wb_workbook() %>% +#' wb_add_worksheet() %>% +#' wb_add_data(x = mtcars, dims = "B2") +#' +#' # create wb_data object +#' dat <- wb_data(wb, 1, dims = "B2:E6") +#' +#' # call ms_scatterplot +#' data_plot <- ms_scatterchart( +#' data = dat, +#' x = "mpg", +#' y = c("disp", "hp"), +#' labels = c("disp", "hp") +#' ) +#' +#' # add the scatterplot to the data +#' wb <- wb %>% +#' wb_add_mschart(dims = "F4:L20", graph = data_plot) +#' } +#' @seealso [wb_data()] [wb_add_chart_xml()] [wb_add_image] [wb_add_mschart()] [wb_add_plot] +#' @export +wb_add_mschart <- function( + wb, + sheet = current_sheet(), + dims = NULL, + graph, + col_offset = 0, + row_offset = 0, + ... +) { + assert_workbook(wb) + wb$clone()$add_mschart( + sheet = sheet, + dims = dims, + graph = graph, + col_offset = col_offset, + row_offset = row_offset, + ... = ... ) } @@ -977,9 +1050,9 @@ wb_remove_worksheet <- function(wb, sheet = current_sheet()) { #' @title Modify the default font #' @description Modify the default font for this workbook #' @param wb A workbook object -#' @param fontSize font size -#' @param fontColor font color -#' @param fontName Name of a font +#' @param font_size font size +#' @param font_color font color +#' @param font_name Name of a font #' @param ... ... #' @details The font name is not validated in anyway. Excel replaces unknown font names #' with Arial. Base font is black, size 11, Calibri. @@ -995,17 +1068,17 @@ wb_remove_worksheet <- function(wb, sheet = current_sheet()) { #' wb$add_data_table("S1", x = iris, startCol = 10) ## font color does not affect tables wb_set_base_font <- function( wb, - fontSize = 11, - fontColor = wb_color(theme = "1"), - fontName = "Calibri", + font_size = 11, + font_color = wb_color(theme = "1"), + font_name = "Calibri", ... ) { assert_workbook(wb) wb$clone()$set_base_font( - fontSize = fontSize, - fontColor = fontColor, - fontName = fontName, - ... = ... + font_size = font_size, + font_color = font_color, + font_name = font_name, + ... = ... ) } @@ -1038,52 +1111,55 @@ wb_get_base_font <- function(wb) { #' #' Get the base font used in the workbook. #' @param wb A [wbWorkbook] object -#' @param activeTab activeTab -#' @param autoFilterDateGrouping autoFilterDateGrouping -#' @param firstSheet firstSheet +#' @param active_tab activeTab +#' @param auto_filter_date_grouping autoFilterDateGrouping +#' @param first_sheet firstSheet #' @param minimized minimized -#' @param showHorizontalScroll showHorizontalScroll -#' @param showSheetTabs showSheetTabs -#' @param showVerticalScroll showVerticalScroll -#' @param tabRatio tabRatio +#' @param show_horizontal_scroll showHorizontalScroll +#' @param show_sheet_tabs showSheetTabs +#' @param show_vertical_scroll showVerticalScroll +#' @param tab_ratio tabRatio #' @param visibility visibility -#' @param windowHeight windowHeight -#' @param windowWidth windowWidth -#' @param xWindow xWindow -#' @param yWindow yWindow +#' @param window_height windowHeight +#' @param window_width windowWidth +#' @param x_window xWindow +#' @param y_window yWindow +#' @param ... additional arguments #' @return The `wbWorkbook` object #' @export wb_set_bookview <- function( wb, - activeTab = NULL, - autoFilterDateGrouping = NULL, - firstSheet = NULL, - minimized = NULL, - showHorizontalScroll = NULL, - showSheetTabs = NULL, - showVerticalScroll = NULL, - tabRatio = NULL, - visibility = NULL, - windowHeight = NULL, - windowWidth = NULL, - xWindow = NULL, - yWindow = NULL + active_tab = NULL, + auto_filter_date_grouping = NULL, + first_sheet = NULL, + minimized = NULL, + show_horizontal_scroll = NULL, + show_sheet_tabs = NULL, + show_vertical_scroll = NULL, + tab_ratio = NULL, + visibility = NULL, + window_height = NULL, + window_width = NULL, + x_window = NULL, + y_window = NULL, + ... ) { assert_workbook(wb) wb$clone()$set_bookview( - activeTab = activeTab, - autoFilterDateGrouping = autoFilterDateGrouping, - firstSheet = firstSheet, - minimized = minimized, - showHorizontalScroll = showHorizontalScroll, - showSheetTabs = showSheetTabs, - showVerticalScroll = showVerticalScroll, - tabRatio = tabRatio, - visibility = visibility, - windowHeight = windowHeight, - windowWidth = windowWidth, - xWindow = xWindow, - yWindow = yWindow + active_tab = active_tab, + auto_filter_date_grouping = auto_filter_date_grouping, + first_sheet = first_sheet, + minimized = minimized, + show_horizontal_scroll = show_horizontal_scroll, + show_sheet_tabs = show_sheet_tabs, + show_vertical_scroll = show_vertical_scroll, + tab_ratio = tab_ratio, + visibility = visibility, + window_height = window_height, + window_width = window_width, + x_window = x_window, + y_window = y_window, + ... = ... ) } @@ -1095,10 +1171,11 @@ wb_set_bookview <- function( #' @param sheet A name or index of a worksheet #' @param header document header. Character vector of length 3 corresponding to positions left, center, right. Use NA to skip a position. #' @param footer document footer. Character vector of length 3 corresponding to positions left, center, right. Use NA to skip a position. -#' @param evenHeader document header for even pages. -#' @param evenFooter document footer for even pages. -#' @param firstHeader document header for first page only. -#' @param firstFooter document footer for first page only. +#' @param even_header document header for even pages. +#' @param even_footer document footer for even pages. +#' @param first_header document header for first page only. +#' @param first_footer document footer for first page only. +#' @param ... additional arguments #' @details Headers and footers can contain special tags #' \itemize{ #' \item{**&\[Page\]**}{ Page number} @@ -1155,23 +1232,25 @@ wb_set_bookview <- function( #' ) wb_set_header_footer <- function( wb, - sheet = current_sheet(), - header = NULL, - footer = NULL, - evenHeader = NULL, - evenFooter = NULL, - firstHeader = NULL, - firstFooter = NULL + sheet = current_sheet(), + header = NULL, + footer = NULL, + even_header = NULL, + even_footer = NULL, + first_header = NULL, + first_footer = NULL, + ... ) { assert_workbook(wb) wb$clone()$set_header_footer( - sheet = sheet, - header = header, - footer = footer, - evenHeader = evenHeader, - evenFooter = evenFooter, - firstHeader = firstHeader, - firstFooter = firstFooter + sheet = sheet, + header = header, + footer = footer, + even_header = even_header, + even_footer = even_footer, + first_header = first_header, + first_footer = first_footer, + ... = ... ) } @@ -1539,24 +1618,23 @@ wb_set_order <- function(wb, sheets) { #' @param wb A workbook object #' @param sheet A name or index of a worksheet #' @param dims Worksheet dimension, single cell ("A1") or cell range ("A1:D4") -#' @param rows Numeric vector specifying rows to include in region -#' @param cols Numeric vector specifying columns to include in region #' @param name Name for region. A character vector of length 1. Note region names musts be case-insensitive unique. #' @param overwrite Boolean. Overwrite if exists? Default to FALSE -#' @param localSheet If `TRUE` the named region will be local for this sheet +#' @param local_sheet If `TRUE` the named region will be local for this sheet #' @param comment description text for named region -#' @param customMenu customMenu (unknown xml feature) +#' @param custom_menu customMenu (unknown xml feature) #' @param description description (unknown xml feature) #' @param is_function function (unknown xml feature) -#' @param functionGroupId function group id (unknown xml feature) +#' @param function_group_id function group id (unknown xml feature) #' @param help help (unknown xml feature) #' @param hidden hidden if the named region should be hidden -#' @param localName localName (unknown xml feature) -#' @param publishToServer publish to server (unknown xml feature) -#' @param statusBar status bar (unknown xml feature) -#' @param vbProcedure wbProcedure (unknown xml feature) -#' @param workbookParameter workbookParameter (unknown xml feature) +#' @param local_name localName (unknown xml feature) +#' @param publish_to_server publish to server (unknown xml feature) +#' @param status_bar status bar (unknown xml feature) +#' @param vb_procedure wbProcedure (unknown xml feature) +#' @param workbook_parameter workbookParameter (unknown xml feature) #' @param xml xml (unknown xml feature) +#' @param ... additional arguments #' @details Region is given by: min(cols):max(cols) X min(rows):max(rows) #' @examples #' ## create named regions @@ -1568,8 +1646,10 @@ wb_set_order <- function(wb, sheets) { #' wb$add_named_region( #' sheet = 1, #' name = "iris", -#' rows = seq_len(nrow(iris) + 1), -#' cols = seq_along(iris) +#' dims = rowcol_to_dims( +#' row = seq_len(nrow(iris) + 1), +#' col = seq_along(iris) +#' ) #' ) #' #' @@ -1602,47 +1682,45 @@ wb_add_named_region <- function( wb, sheet = current_sheet(), dims = "A1", - cols, - rows, name, - localSheet = FALSE, - overwrite = FALSE, - comment = NULL, - customMenu = NULL, - description = NULL, - is_function = NULL, - functionGroupId = NULL, - help = NULL, - hidden = NULL, - localName = NULL, - publishToServer = NULL, - statusBar = NULL, - vbProcedure = NULL, - workbookParameter = NULL, - xml = NULL + local_sheet = FALSE, + overwrite = FALSE, + comment = NULL, + custom_menu = NULL, + description = NULL, + is_function = NULL, + function_group_id = NULL, + help = NULL, + hidden = NULL, + local_name = NULL, + publish_to_server = NULL, + status_bar = NULL, + vb_procedure = NULL, + workbook_parameter = NULL, + xml = NULL, + ... ) { assert_workbook(wb) wb$clone()$add_named_region( - sheet = sheet, - dims = dims, - cols = cols, - rows = rows, - name = name, - localSheet = localSheet, - overwrite = overwrite, - comment = comment, - customMenu = customMenu, - description = description, - is_function = is_function, - functionGroupId = functionGroupId, - help = help, - hidden = hidden, - localName = localName, - publishToServer = publishToServer, - statusBar = statusBar, - vbProcedure = vbProcedure, - workbookParameter = workbookParameter, - xml = xml + sheet = sheet, + dims = dims, + name = name, + local_sheet = local_sheet, + overwrite = overwrite, + comment = comment, + custom_menu = custom_menu, + description = description, + is_function = is_function, + function_group_id = function_group_id, + help = help, + hidden = hidden, + local_name = local_name, + publish_to_server = publish_to_server, + status_bar = status_bar, + vb_procedure = vb_procedure, + workbook_parameter = workbook_parameter, + xml = xml, + ... = ... ) } @@ -1726,20 +1804,20 @@ wb_remove_filter <- function(wb, sheet = current_sheet()) { #' #' @param wb A workbook object #' @param sheet A name or index of a worksheet -#' @param cols Contiguous columns to apply conditional formatting to -#' @param rows Contiguous rows to apply conditional formatting to +#' @param dims A cell dimension ("A1" or "A1:B2") #' @param type One of 'whole', 'decimal', 'date', 'time', 'textLength', 'list' (see examples) #' @param operator One of 'between', 'notBetween', 'equal', #' 'notEqual', 'greaterThan', 'lessThan', 'greaterThanOrEqual', 'lessThanOrEqual' #' @param value a vector of length 1 or 2 depending on operator (see examples) -#' @param allowBlank logical -#' @param showInputMsg logical -#' @param showErrorMsg logical -#' @param errorStyle The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input) -#' @param errorTitle The error title +#' @param allow_blank logical +#' @param show_input_msg logical +#' @param show_error_msg logical +#' @param error_style The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input) +#' @param error_title The error title #' @param error The error text -#' @param promptTitle The prompt title +#' @param prompt_title The prompt title #' @param prompt The prompt text +#' @param ... additional arguments #' @export #' @examples #' wb <- wb_workbook() @@ -1748,11 +1826,11 @@ wb_remove_filter <- function(wb, sheet = current_sheet()) { #' #' wb$add_data_table(1, x = iris[1:30, ]) #' wb$add_data_validation(1, -#' col = 1:3, rows = 2:31, type = "whole", +#' dims = "A2:C31", type = "whole", #' operator = "between", value = c(1, 9) #' ) #' wb$add_data_validation(1, -#' col = 5, rows = 2:31, type = "textLength", +#' dims = "E2:E31", type = "textLength", #' operator = "between", value = c(4, 6) #' ) #' @@ -1767,7 +1845,7 @@ wb_remove_filter <- function(wb, sheet = current_sheet()) { #' operator = "greaterThanOrEqual", value = as.Date("2016-01-01") #' ) #' wb$add_data_validation(2, -#' col = 2, rows = 2:12, type = "time", +#' dims = "B2:B12", type = "time", #' operator = "between", value = df$t[c(4, 8)] #' ) #' @@ -1783,40 +1861,39 @@ wb_remove_filter <- function(wb, sheet = current_sheet()) { #' wb$add_data_table(sheet = 1, x = iris[1:30, ]) #' wb$add_data(sheet = 2, x = sample(iris$Sepal.Length, 10)) #' -#' wb$add_data_validation(1, col = 1, rows = 2:31, type = "list", value = "'Sheet 2'!$A$1:$A$10") +#' wb$add_data_validation(1, dims = "A2:A31", type = "list", value = "'Sheet 2'!$A$1:$A$10") wb_add_data_validation <- function( wb, - sheet = current_sheet(), - cols, - rows, + sheet = current_sheet(), + dims = "A1", type, operator, value, - allowBlank = TRUE, - showInputMsg = TRUE, - showErrorMsg = TRUE, - errorStyle = NULL, - errorTitle = NULL, - error = NULL, - promptTitle = NULL, - prompt = NULL + allow_blank = TRUE, + show_input_msg = TRUE, + show_error_msg = TRUE, + error_style = NULL, + error_title = NULL, + error = NULL, + prompt_title = NULL, + prompt = NULL, + ... ) { assert_workbook(wb) wb$clone(deep = TRUE)$add_data_validation( - sheet = sheet, - cols = cols, - rows = rows, - type = type, - operator = operator, - value = value, - allowBlank = allowBlank, - showInputMsg = showInputMsg, - showErrorMsg = showErrorMsg, - errorStyle = errorStyle, - errorTitle = errorTitle, - error = error, - promptTitle = promptTitle, - prompt = prompt + sheet = sheet, + type = type, + operator = operator, + value = value, + allowBlank = allow_blank, + show_input_msg = show_input_msg, + show_error_msg = show_error_msg, + error_style = error_style, + error_title = error_title, + error = error, + prompt_title = prompt_title, + prompt = prompt, + ... = ... ) } @@ -2171,59 +2248,52 @@ wb_set_last_modified_by <- function(wb, LastModifiedBy) { #' #' @param wb A workbook object #' @param sheet A name or index of a worksheet +#' @param dims Dimensions where to plot. Default absolute anchor, single cell (eg. "A1") oneCellAnchor, cell range (eg. "A1:D4") twoCellAnchor #' @param file An image file. Valid file types are:` "jpeg"`, `"png"`, `"bmp"` #' @param width Width of figure. #' @param height Height of figure. -#' @param startRow Row coordinate of upper left corner of the image -#' @param startCol Column coordinate of upper left corner of the image -#' @param rowOffset offset vector for one or two cell anchor within cell (row) -#' @param colOffset offset vector for one or two cell anchor within cell (column) +#' @param row_offset offset vector for one or two cell anchor within cell (row) +#' @param col_offset offset vector for one or two cell anchor within cell (column) #' @param units Units of width and height. Can be `"in"`, `"cm"` or `"px"` #' @param dpi Image resolution used for conversion between units. -#' @param dims Dimensions where to plot. Default absolute anchor, single cell (eg. "A1") oneCellAnchor, cell range (eg. "A1:D4") twoCellAnchor -#' @seealso [wb_add_plot()] +#' @param ... additional arguments +#' @seealso [wb_add_chart_xml()] [wb_add_drawing()] [wb_add_mschart()] [wb_add_plot()] #' @export #' @examples -#' ## Create a new workbook -#' wb <- wb_workbook("Ayanami") -#' -#' ## Add some worksheets -#' wb$add_worksheet("Sheet 1") -#' wb$add_worksheet("Sheet 2") -#' wb$add_worksheet("Sheet 3") -#' -#' ## Insert images #' img <- system.file("extdata", "einstein.jpg", package = "openxlsx2") -#' wb$add_image("Sheet 1", img, startRow = 5, startCol = 3, width = 6, height = 5) -#' wb$add_image(2, img, startRow = 2, startCol = 2) -#' wb$add_image(3, img, width = 15, height = 12, startRow = 3, startCol = "G", units = "cm") +#' +#' wb <- wb_workbook()$ +#' add_worksheet()$ +#' add_image("Sheet 1", dims = "C5", file = img, width = 6, height = 5)$ +#' add_worksheet()$ +#' add_image(dims = "B2", file = img)$ +#' add_worksheet()$ +#' add_image(dims = "G3", file = img, width = 15, height = 12, units = "cm") wb_add_image <- function( wb, - sheet = current_sheet(), + sheet = current_sheet(), + dims = "A1", file, - width = 6, - height = 3, - startRow = 1, - startCol = 1, - rowOffset = 0, - colOffset = 0, - units = "in", - dpi = 300, - dims = rowcol_to_dim(startRow, startCol) + width = 6, + height = 3, + row_offset = 0, + col_offset = 0, + units = "in", + dpi = 300, + ... ) { assert_workbook(wb) wb$clone()$add_image( - sheet = sheet, - file = file, - startRow = startRow, - startCol = startCol, - width = width, - height = height, - rowOffset = rowOffset, - colOffset = colOffset, - units = units, - dpi = dpi, - dims = dims + sheet = sheet, + dims = dims, + file = file, + width = width, + height = height, + row_offset = row_offset, + col_offset = col_offset, + units = units, + dpi = dpi, + ... ) } @@ -2231,20 +2301,30 @@ wb_add_image <- function( #' add a chart xml to a workbook #' @param wb a workbook #' @param sheet the sheet on which the graph will appear -#' @param xml chart xml #' @param dims the dimensions where the sheet will appear -#' @param colOffset,rowOffset startCol and startRow +#' @param xml chart xml +#' @param col_offset,row_offset positioning +#' @param ... additional arguments +#' @seealso [wb_add_drawing()] [wb_add_image()] [wb_add_mschart()] [wb_add_plot()] #' @export wb_add_chart_xml <- function( wb, - sheet = current_sheet(), + sheet = current_sheet(), + dims = NULL, xml, - dims = NULL, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... ) { assert_workbook(wb) - wb$clone()$add_chart_xml(sheet, xml, dims, colOffset, rowOffset) + wb$clone()$add_chart_xml( + sheet = sheet, + xml = xml, + dims = dims, + col_offset = col_offset, + row_offset = row_offset, + ... = ... + ) } @@ -2489,7 +2569,7 @@ wb_add_fill <- function( #' @param scheme font scheme #' @param shadow shadow #' @param extend extend -#' @param vertAlign vertical alignment +#' @param vert_align vertical alignment #' @param ... ... #' @examples #' wb <- wb_workbook() %>% wb_add_worksheet("S1") %>% wb_add_data("S1", mtcars) @@ -2499,47 +2579,47 @@ wb_add_fill <- function( #' @export wb_add_font <- function( wb, - sheet = current_sheet(), - dims = "A1", - name = "Calibri", - color = wb_color(hex = "FF000000"), - size = "11", - bold = "", - italic = "", - outline = "", - strike = "", - underline = "", + sheet = current_sheet(), + dims = "A1", + name = "Calibri", + color = wb_color(hex = "FF000000"), + size = "11", + bold = "", + italic = "", + outline = "", + strike = "", + underline = "", # fine tuning - charset = "", - condense = "", - extend = "", - family = "", - scheme = "", - shadow = "", - vertAlign = "", + charset = "", + condense = "", + extend = "", + family = "", + scheme = "", + shadow = "", + vert_align = "", ... ) { assert_workbook(wb) wb$clone()$add_font( - sheet = sheet, - dims = dims, - name = name, - color = color, - size = size, - bold = bold, - italic = italic, - outline = outline, - strike = strike, - underline = underline, + sheet = sheet, + dims = dims, + name = name, + color = color, + size = size, + bold = bold, + italic = italic, + outline = outline, + strike = strike, + underline = underline, # fine tuning - charset = charset, - condense = condense, - extend = extend, - family = family, - scheme = scheme, - shadow = shadow, - vertAlign = vertAlign, - ... = ... + charset = charset, + condense = condense, + extend = extend, + family = family, + scheme = scheme, + shadow = shadow, + vert_align = vert_align, + ... = ... ) } @@ -2572,33 +2652,34 @@ wb_add_numfmt <- function( #' @param wb a workbook #' @param sheet the worksheet #' @param dims the cell range -#' @param extLst extension list something like `...` +#' @param ext_lst extension list something like `...` #' @param hidden logical cell is hidden #' @param horizontal align content horizontal ('left', 'center', 'right') #' @param indent logical indent content -#' @param justifyLastLine logical justify last line +#' @param justify_last_line logical justify last line #' @param locked logical cell is locked -#' @param pivotButton unknown -#' @param quotePrefix unknown -#' @param readingOrder reading order left to right -#' @param relativeIndent relative indentation -#' @param shrinkToFit logical shrink to fit -#' @param textRotation degrees of text rotation +#' @param pivot_button unknown +#' @param quote_prefix unknown +#' @param reading_order reading order left to right +#' @param relative_indent relative indentation +#' @param shrink_to_fit logical shrink to fit +#' @param text_rotation degrees of text rotation #' @param vertical vertical alignment of content ('top', 'center', 'bottom') -#' @param wrapText wrap text in cell +#' @param wrap_text wrap text in cell # alignments -#' @param applyAlignment logical apply alignment -#' @param applyBorder logical apply border -#' @param applyFill logical apply fill -#' @param applyFont logical apply font -#' @param applyNumberFormat logical apply number format -#' @param applyProtection logical apply protection +#' @param apply_alignment logical apply alignment +#' @param apply_border logical apply border +#' @param apply_fill logical apply fill +#' @param apply_font logical apply font +#' @param apply_number_format logical apply number format +#' @param apply_protection logical apply protection # ids -#' @param borderId border ID to apply -#' @param fillId fill ID to apply -#' @param fontId font ID to apply -#' @param numFmtId number format ID to apply -#' @param xfId xf ID to apply +#' @param border_id border ID to apply +#' @param fill_id fill ID to apply +#' @param font_id font ID to apply +#' @param num_fmt_id number format ID to apply +#' @param xf_id xf ID to apply +#' @param ... additional arguments #' @examples #' wb <- #' wb_workbook() %>% @@ -2619,63 +2700,65 @@ wb_add_numfmt <- function( #' @export wb_add_cell_style <- function( wb, - sheet = current_sheet(), - dims = "A1", - applyAlignment = NULL, - applyBorder = NULL, - applyFill = NULL, - applyFont = NULL, - applyNumberFormat = NULL, - applyProtection = NULL, - borderId = NULL, - extLst = NULL, - fillId = NULL, - fontId = NULL, - hidden = NULL, - horizontal = NULL, - indent = NULL, - justifyLastLine = NULL, - locked = NULL, - numFmtId = NULL, - pivotButton = NULL, - quotePrefix = NULL, - readingOrder = NULL, - relativeIndent = NULL, - shrinkToFit = NULL, - textRotation = NULL, - vertical = NULL, - wrapText = NULL, - xfId = NULL + sheet = current_sheet(), + dims = "A1", + apply_alignment = NULL, + apply_border = NULL, + apply_fill = NULL, + apply_font = NULL, + apply_number_format = NULL, + apply_protection = NULL, + border_id = NULL, + ext_lst = NULL, + fill_id = NULL, + font_id = NULL, + hidden = NULL, + horizontal = NULL, + indent = NULL, + justify_last_line = NULL, + locked = NULL, + num_fmt_id = NULL, + pivot_button = NULL, + quote_prefix = NULL, + reading_order = NULL, + relative_indent = NULL, + shrink_to_fit = NULL, + text_rotation = NULL, + vertical = NULL, + wrap_text = NULL, + xf_id = NULL, + ... ) { assert_workbook(wb) wb$clone()$add_cell_style( - sheet = sheet, - dims = dims, - applyAlignment = applyAlignment, - applyBorder = applyBorder, - applyFill = applyFill, - applyFont = applyFont, - applyNumberFormat = applyNumberFormat, - applyProtection = applyProtection, - borderId = borderId, - extLst = extLst, - fillId = fillId, - fontId = fontId, - hidden = hidden, - horizontal = horizontal, - indent = indent, - justifyLastLine = justifyLastLine, - locked = locked, - numFmtId = numFmtId, - pivotButton = pivotButton, - quotePrefix = quotePrefix, - readingOrder = readingOrder, - relativeIndent = relativeIndent, - shrinkToFit = shrinkToFit, - textRotation = textRotation, - vertical = vertical, - wrapText = wrapText, - xfId = xfId + sheet = sheet, + dims = dims, + apply_alignment = apply_alignment, + apply_border = apply_border, + apply_fill = apply_fill, + apply_font = apply_font, + apply_number_format = apply_number_format, + apply_protection = apply_protection, + border_id = border_id, + ext_lst = ext_lst, + fill_id = fill_id, + font_id = font_id, + hidden = hidden, + horizontal = horizontal, + indent = indent, + justify_last_line = justify_last_line, + locked = locked, + num_fmt_id = num_fmt_id, + pivot_button = pivot_button, + quote_prefix = quote_prefix, + reading_order = reading_order, + relative_indent = relative_indent, + shrink_to_fit = shrink_to_fit, + text_rotation = text_rotation, + vertical = vertical, + wrap_text = wrap_text, + xfId = xf_id, + ... = ... ) } @@ -2713,12 +2796,12 @@ wb_add_named_style <- function( #' @param font_name the font name #' @param font_size the font size #' @param font_color the font color (a `wb_color()` object) -#' @param numFmt the number format +#' @param num_fmt the number format #' @param border logical if borders are applied #' @param border_color the border color #' @param border_style the border style -#' @param bgFill any background fill -#' @param gradientFill any gradient fill +#' @param bg_fill any background fill +#' @param gradient_fill any gradient fill #' @param text_bold logical if text is bold #' @param text_italic logical if text is italic #' @param text_underline logical if text is underlined @@ -2739,12 +2822,12 @@ wb_add_dxfs_style <- function( font_name = NULL, font_size = NULL, font_color = NULL, - numFmt = NULL, + num_fmt = NULL, border = NULL, border_color = wb_color(getOption("openxlsx2.borderColor", "black")), border_style = getOption("openxlsx2.borderStyle", "thin"), - bgFill = NULL, - gradientFill = NULL, + bg_fill = NULL, + gradient_fill = NULL, text_bold = NULL, text_italic = NULL, text_underline = NULL, @@ -2757,12 +2840,12 @@ wb_add_dxfs_style <- function( font_name = font_name, font_size = font_size, font_color = font_color, - numFmt = numFmt, + num_fmt = num_fmt, border = border, border_color = border_color, border_style = border_style, - bgFill = bgFill, - gradientFill = gradientFill, + bg_fill = bg_fill, + gradient_fill = gradient_fill, text_bold = text_bold, text_italic = text_italic, text_underline = text_underline, @@ -2778,16 +2861,16 @@ wb_add_dxfs_style <- function( #' @param row A row to apply the comment #' @param dims Optional row and column as spreadsheet dimension, e.g. "A1" #' @param comment A comment to apply to the worksheet +#' @param ... additional arguments #' @returns The `wbWorkbook` object #' @rdname comment #' @export wb_add_comment <- function( wb, sheet = current_sheet(), - col = NULL, - row = NULL, - dims = rowcol_to_dim(row, col), - comment + dims = "A1", + comment, + ... ) { assert_workbook(wb) @@ -2795,40 +2878,33 @@ wb_add_comment <- function( wb$clone()$add_comment( sheet = sheet, - col = col, - row = row, dims = dims, - comment = comment + comment = comment, + ... = ... ) } #' Remove comment from worksheet #' @param wb A workbook object #' @param sheet A worksheet of the workbook -#' @param col A column to apply the comment -#' @param row A row to apply the comment #' @param dims Optional row and column as spreadsheet dimension, e.g. "A1" -#' @param gridExpand Remove all comments inside the grid. Similar to dims "A1:B2" +#' @param ... additional arguments #' @returns The `wbWorkbook` object #' @rdname comment #' @export wb_remove_comment <- function( wb, sheet = current_sheet(), - col = NULL, - row = NULL, - dims = rowcol_to_dims(row, col), - gridExpand = TRUE + dims = "A1", + ... ) { assert_workbook(wb) - wb$clone()$remove_comment( - sheet = sheet, - col = col, - row = row, - dims = dims, - gridExpand = gridExpand + wb$clone(deep = TRUE)$remove_comment( + sheet = sheet, + dims = dims, + ... = ... ) } @@ -3016,63 +3092,67 @@ wb_add_sparklines <- function(wb, sheet = current_sheet(), sparklines) { #' @param wb workbook #' @param sheet sheet #' @param dims dims -#' @param calculatedColumn calculatedColumn -#' @param emptyCellReference emptyCellReference -#' @param evalError evalError +#' @param calculated_column calculatedColumn +#' @param empty_cell_reference emptyCellReference +#' @param eval_error evalError #' @param formula formula -#' @param formulaRange formulaRange -#' @param listDataValidation listDataValidation -#' @param numberStoredAsText numberStoredAsText -#' @param twoDigitTextYear twoDigitTextYear -#' @param unlockedFormula unlockedFormula +#' @param formula_range formulaRange +#' @param list_data_validation listDataValidation +#' @param number_stored_as_text numberStoredAsText +#' @param two_digit_text_year twoDigitTextYear +#' @param unlocked_formula unlockedFormula +#' @param ... additional arguments wb_add_ignore_error <- function( wb, - sheet = current_sheet(), - dims = "A1", - calculatedColumn = FALSE, - emptyCellReference = FALSE, - evalError = FALSE, - formula = FALSE, - formulaRange = FALSE, - listDataValidation = FALSE, - numberStoredAsText = FALSE, - twoDigitTextYear = FALSE, - unlockedFormula = FALSE + sheet = current_sheet(), + dims = "A1", + calculated_column = FALSE, + empty_cell_reference = FALSE, + eval_error = FALSE, + formula = FALSE, + formula_range = FALSE, + list_data_validation = FALSE, + number_stored_as_text = FALSE, + two_digit_text_year = FALSE, + unlocked_formula = FALSE, + ... ) { assert_workbook(wb) wb$clone()$add_ignore_error( - sheet = sheet, - dims = dims, - calculatedColumn = calculatedColumn, - emptyCellReference = emptyCellReference, - evalError = evalError, - formula = formula, - formulaRange = formulaRange, - listDataValidation = listDataValidation, - numberStoredAsText = numberStoredAsText, - twoDigitTextYear = twoDigitTextYear, - unlockedFormula = unlockedFormula + sheet = sheet, + dims = dims, + calculated_column = calculated_column, + empty_cell_reference = empty_cell_reference, + eval_error = eval_error, + formula = formula, + formula_range = formula_range, + list_data_validation = list_data_validation, + number_stored_as_text = number_stored_as_text, + two_digit_text_year = two_digit_text_year, + unlocked_formula = unlocked_formula, + ... = ... ) } #' add sheetview #' @param wb workbook #' @param sheet sheet -#' @param colorId,defaultGridColor Integer: A color, default is 64 -#' @param rightToLeft Logical: if TRUE column ordering is right to left -#' @param showFormulas Logical: if TRUE cell formulas are shown -#' @param showGridLines Logical: if TRUE the worksheet grid is shown -#' @param showOutlineSymbols Logical: if TRUE outline symbols are shown -#' @param showRowColHeaders Logical: if TRUE row and column headers are shown -#' @param showRuler Logical: if TRUE a ruler is shown in page layout view -#' @param showWhiteSpace Logical: if TRUE margins are shown in page layout view -#' @param showZeros Logical: if FALSE cells containing zero are shown blank if !showFormulas -#' @param tabSelected Integer: zero vector indicating the selected tab -#' @param topLeftCell Cell: the cell shown in the top left corner / or top right with rightToLeft +#' @param color_id,default_grid_color Integer: A color, default is 64 +#' @param right_to_left Logical: if TRUE column ordering is right to left +#' @param show_formulas Logical: if TRUE cell formulas are shown +#' @param show_grid_lines Logical: if TRUE the worksheet grid is shown +#' @param show_outline_symbols Logical: if TRUE outline symbols are shown +#' @param show_row_col_headers Logical: if TRUE row and column headers are shown +#' @param show_ruler Logical: if TRUE a ruler is shown in page layout view +#' @param show_white_space Logical: if TRUE margins are shown in page layout view +#' @param show_zeros Logical: if FALSE cells containing zero are shown blank if !showFormulas +#' @param tab_selected Integer: zero vector indicating the selected tab +#' @param top_left_cell Cell: the cell shown in the top left corner / or top right with rightToLeft #' @param view View: "normal", "pageBreakPreview" or "pageLayout" -#' @param windowProtection Logical: if TRUE the panes are protected -#' @param workbookViewId integer: Pointing to some other view inside the workbook -#' @param zoomScale,zoomScaleNormal,zoomScalePageLayoutView,zoomScaleSheetLayoutView Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc. +#' @param window_protection Logical: if TRUE the panes are protected +#' @param workbook_view_id integer: Pointing to some other view inside the workbook +#' @param zoom_scale,zoom_scale_normal,zoom_scale_page_layout_view,zoom_scale_sheet_layout_view Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc. +#' @param ... additional arguments #' @examples #' wb <- wb_workbook()$add_worksheet() #' @@ -3094,48 +3174,50 @@ wb_add_ignore_error <- function( #' @export wb_set_sheetview <- function( wb, - sheet = current_sheet(), - colorId = NULL, - defaultGridColor = NULL, - rightToLeft = NULL, - showFormulas = NULL, - showGridLines = NULL, - showOutlineSymbols = NULL, - showRowColHeaders = NULL, - showRuler = NULL, - showWhiteSpace = NULL, - showZeros = NULL, - tabSelected = NULL, - topLeftCell = NULL, - view = NULL, - windowProtection = NULL, - workbookViewId = NULL, - zoomScale = NULL, - zoomScaleNormal = NULL, - zoomScalePageLayoutView = NULL, - zoomScaleSheetLayoutView = NULL + sheet = current_sheet(), + color_id = NULL, + default_grid_color = NULL, + right_to_left = NULL, + show_formulas = NULL, + show_grid_lines = NULL, + show_outline_symbols = NULL, + show_row_col_headers = NULL, + show_ruler = NULL, + show_white_space = NULL, + show_zeros = NULL, + tab_selected = NULL, + top_left_cell = NULL, + view = NULL, + window_protection = NULL, + workbook_view_id = NULL, + zoom_scale = NULL, + zoom_scale_normal = NULL, + zoom_scale_page_layout_view = NULL, + zoom_scale_sheet_layout_view = NULL, + ... ) { assert_workbook(wb) wb$clone()$set_sheetview( - sheet = sheet, - colorId = colorId, - defaultGridColor = defaultGridColor, - rightToLeft = rightToLeft, - showFormulas = showFormulas, - showGridLines = showGridLines, - showOutlineSymbols = showOutlineSymbols, - showRowColHeaders = showRowColHeaders, - showRuler = showRuler, - showWhiteSpace = showWhiteSpace, - showZeros = showZeros, - tabSelected = tabSelected, - topLeftCell = topLeftCell, - view = view, - windowProtection = windowProtection, - workbookViewId = workbookViewId, - zoomScale = zoomScale, - zoomScaleNormal = zoomScaleNormal, - zoomScalePageLayoutView = zoomScalePageLayoutView, - zoomScaleSheetLayoutView = zoomScaleSheetLayoutView + sheet = sheet, + color_id = color_id, + default_grid_color = default_grid_color, + right_to_left = right_to_left, + show_formulas = show_formulas, + show_grid_lines = show_grid_lines, + show_outline_symbols = show_outline_symbols, + show_row_col_headers = show_row_col_headers, + show_ruler = show_ruler, + show_white_space = show_white_space, + show_zeros = show_zeros, + tab_selected = tab_selected, + top_left_cell = top_left_cell, + view = view, + window_protection = window_protection, + workbook_view_id = workbook_view_id, + zoom_scale = zoom_scale, + zoom_scale_normal = zoom_scale_normal, + zoom_scale_page_layout_view = zoom_scale_page_layout_view, + zoom_scale_sheet_layout_view = zoom_scale_sheet_layout_view, + ... = ... ) } diff --git a/R/class-workbook.R b/R/class-workbook.R index fdeb8cf1e..45c30d5cf 100644 --- a/R/class-workbook.R +++ b/R/class-workbook.R @@ -174,19 +174,24 @@ wbWorkbook <- R6::R6Class( #' @param title title #' @param subject subject #' @param category category - #' @param datetimeCreated The datetime (as `POSIXt`) the workbook is + #' @param datetime_created The datetime (as `POSIXt`) the workbook is #' created. Defaults to the current `Sys.time()` when the workbook object #' is created, not when the Excel files are saved. #' @param theme Optional theme identified by string or number + #' @param ... additional arguments #' @return a `wbWorkbook` object initialize = function( creator = NULL, title = NULL, subject = NULL, category = NULL, - datetimeCreated = Sys.time(), - theme = NULL + datetime_created = Sys.time(), + theme = NULL, + ... ) { + + standardize_case_names(...) + self$app <- genBaseApp() self$charts <- list() self$is_chartsheet <- logical() @@ -286,22 +291,22 @@ wbWorkbook <- R6::R6Class( # USERNAME may only be present for windows Sys.getenv("USERNAME", Sys.getenv("USER")) - assert_class(self$creator, "character") - assert_class(title, "character", or_null = TRUE) - assert_class(subject, "character", or_null = TRUE) - assert_class(category, "character", or_null = TRUE) - assert_class(datetimeCreated, "POSIXt") + assert_class(self$creator, "character") + assert_class(title, "character", or_null = TRUE) + assert_class(subject, "character", or_null = TRUE) + assert_class(category, "character", or_null = TRUE) + assert_class(datetime_created, "POSIXt") stopifnot( length(title) <= 1L, length(category) <= 1L, - length(datetimeCreated) == 1L + length(datetime_created) == 1L ) self$title <- title self$subject <- subject self$category <- category - self$datetimeCreated <- datetimeCreated + self$datetimeCreated <- datetime_created private$generate_base_core() private$current_sheet <- 0L invisible(self) @@ -356,14 +361,14 @@ wbWorkbook <- R6::R6Class( #' @description #' Add a chart sheet to the workbook #' @param sheet sheet - #' @param tabColor tabColor + #' @param tab_color tab_color #' @param zoom zoom #' @param visible visible #' @param ... ... #' @return The `wbWorkbook` object, invisibly add_chartsheet = function( sheet = next_sheet(), - tabColor = NULL, + tab_color = NULL, zoom = 100, visible = c("true", "false", "hidden", "visible", "veryhidden"), ... @@ -415,12 +420,13 @@ wbWorkbook <- R6::R6Class( ) ) - standardize_color_names(...) - if (!is.null(tabColor)) { - if (is_wbColour(tabColor)) { - tabColor <- as.character(tabColor) + standardize(...) + + if (!is.null(tab_color)) { + if (is_wbColour(tab_color)) { + tab_color <- as.character(tab_color) } else { - tabColor <- validateColor(tabColor, "Invalid tabColor in add_chartsheet.") + tab_color <- validateColor(tab_color, "Invalid tab_color in add_chartsheet.") } } @@ -439,14 +445,14 @@ wbWorkbook <- R6::R6Class( self$append("worksheets", wbChartSheet$new( - tabColor = tabColor + tabColor = tab_color ) ) self$worksheets[[newSheetIndex]]$set_sheetview( - workbookViewId = 0, - zoomScale = zoom, - tabSelected = newSheetIndex == 1 + workbook_view_id = 0, + zoom_scale = zoom, + tab_selected = newSheetIndex == 1 ) self$append("sheet_names", sheet) @@ -486,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")) @@ -561,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.") } } @@ -588,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")) } @@ -671,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 + tab_color = tab_color, + odd_header = odd_header, + odd_footer = odd_footer, + even_header = even_header, + even_footer = even_footer, + first_header = first_header, + first_footer = first_footer, + paper_size = paper_size, + orientation = orientation, + hdpi = hdpi, + vdpi = vdpi, + grid_lines = grid_lines ) ) @@ -691,18 +699,18 @@ wbWorkbook <- R6::R6Class( # set preselected set for sheetview self$worksheets[[newSheetIndex]]$set_sheetview( - workbookViewId = 0, - zoomScale = zoom, - showGridLines = gridLines, - showRowColHeaders = rowColHeaders, - tabSelected = newSheetIndex == 1, - rightToLeft = rightToLeft + workbook_view_id = 0, + zoom_scale = zoom, + show_grid_lines = grid_lines, + show_row_col_headers = row_col_headers, + tab_selected = newSheetIndex == 1, + right_to_left = rightToLeft ) ## update content_tyes ## add a drawing.xml for the worksheet - if (hasDrawing) { + if (has_drawing) { self$append("Content_Types", c( sprintf('', newSheetIndex), sprintf('', newSheetIndex) @@ -1051,56 +1059,60 @@ wbWorkbook <- R6::R6Class( #' @description add data #' @param sheet sheet #' @param x x - #' @param startCol startCol - #' @param startRow startRow #' @param dims dims + #' @param start_col startCol + #' @param start_row startRow #' @param array array - #' @param colNames colNames - #' @param rowNames rowNames - #' @param withFilter withFilter + #' @param col_names colNames + #' @param row_names rowNames + #' @param with_filter withFilter #' @param name name #' @param sep sep - #' @param applyCellStyle applyCellStyle - #' @param removeCellStyle if writing into existing cells, should the cell style be removed? + #' @param apply_cell_style applyCellStyle + #' @param remove_cell_style if writing into existing cells, should the cell style be removed? #' @param na.strings Value used for replacing `NA` values from `x`. Default #' `na_strings()` uses the special `#N/A` value within the workbook. #' @param inline_strings write characters as inline strings + #' @param ... additional arguments #' @param return The `wbWorkbook` object add_data = function( - sheet = current_sheet(), + sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - array = FALSE, - colNames = TRUE, - rowNames = FALSE, - withFilter = FALSE, - name = NULL, - sep = ", ", - applyCellStyle = TRUE, - removeCellStyle = FALSE, - na.strings = na_strings(), - inline_strings = TRUE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + array = FALSE, + col_names = TRUE, + row_names = FALSE, + with_filter = FALSE, + name = NULL, + sep = ", ", + apply_cell_style = TRUE, + remove_cell_style = FALSE, + na.strings = na_strings(), + inline_strings = TRUE, + ... ) { + standardize(...) + write_data( - wb = self, - sheet = sheet, - x = x, - startCol = startCol, - startRow = startRow, - dims = dims, - array = array, - colNames = colNames, - rowNames = rowNames, - withFilter = withFilter, - name = name, - sep = sep, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle, - na.strings = na.strings, - inline_strings = inline_strings + wb = self, + sheet = sheet, + x = x, + dims = dims, + start_col = start_col, + start_row = start_row, + array = array, + col_names = col_names, + row_names = row_names, + with_filter = with_filter, + name = name, + sep = sep, + apply_cell_style = apply_cell_style, + remove_cell_style = remove_cell_style, + na.strings = na.strings, + inline_strings = inline_strings ) invisible(self) }, @@ -1108,66 +1120,70 @@ wbWorkbook <- R6::R6Class( #' @description add a data table #' @param sheet sheet #' @param x x - #' @param startCol startCol - #' @param startRow startRow #' @param dims dims - #' @param colNames colNames - #' @param rowNames rowNames - #' @param tableStyle tableStyle - #' @param tableName tableName - #' @param withFilter withFilter + #' @param start_col startCol + #' @param start_row startRow + #' @param col_names colNames + #' @param row_names rowNames + #' @param table_style tableStyle + #' @param table_name tableName + #' @param with_filter withFilter #' @param sep sep - #' @param firstColumn firstColumn - #' @param lastColumn lastColumn - #' @param bandedRows bandedRows - #' @param bandedCols bandedCols - #' @param applyCellStyle applyCellStyle - #' @param removeCellStyle if writing into existing cells, should the cell style be removed? + #' @param first_column firstColumn + #' @param last_column lastColumn + #' @param banded_rows bandedRows + #' @param banded_cols bandedCols + #' @param apply_cell_style applyCellStyle + #' @param remove_cell_style if writing into existing cells, should the cell style be removed? #' @param na.strings Value used for replacing `NA` values from `x`. Default #' `na_strings()` uses the special `#N/A` value within the workbook. #' @param inline_strings write characters as inline strings + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_data_table = function( - sheet = current_sheet(), + sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - colNames = TRUE, - rowNames = FALSE, - tableStyle = "TableStyleLight9", - tableName = NULL, - withFilter = TRUE, - sep = ", ", - firstColumn = FALSE, - lastColumn = FALSE, - bandedRows = TRUE, - bandedCols = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE, - na.strings = na_strings(), - inline_strings = TRUE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + col_names = TRUE, + row_names = FALSE, + table_style = "TableStyleLight9", + table_name = NULL, + with_filter = TRUE, + sep = ", ", + first_column = FALSE, + last_column = FALSE, + banded_rows = TRUE, + banded_cols = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, + na.strings = na_strings(), + inline_strings = TRUE, + ... ) { + standardize(...) + write_datatable( wb = self, - sheet = sheet, x = x, + sheet = sheet, dims = dims, - startCol = startCol, - startRow = startRow, - colNames = colNames, - rowNames = rowNames, - tableStyle = tableStyle, - tableName = tableName, - withFilter = withFilter, + startCol = start_col, + startRow = start_row, + colNames = col_names, + rowNames = row_names, + tableStyle = table_style, + tableName = table_name, + withFilter = with_filter, sep = sep, - firstColumn = firstColumn, - lastColumn = lastColumn, - bandedRows = bandedRows, - bandedCols = bandedCols, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle, + firstColumn = first_column, + lastColumn = last_column, + bandedRows = banded_rows, + bandedCols = banded_cols, + applyCellStyle = apply_cell_style, + removeCellStyle = remove_cell_style, na.strings = na.strings, inline_strings = inline_strings ) @@ -1324,37 +1340,41 @@ wbWorkbook <- R6::R6Class( #' @description add formula #' @param sheet sheet - #' @param x x - #' @param startCol startCol - #' @param startRow startRow #' @param dims dims + #' @param x x + #' @param start_col startCol + #' @param start_row startRow #' @param array array #' @param cm cm - #' @param applyCellStyle applyCellStyle - #' @param removeCellStyle if writing into existing cells, should the cell style be removed? + #' @param apply_cell_style applyCellStyle + #' @param remove_cell_style if writing into existing cells, should the cell style be removed? + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_formula = function( - sheet = current_sheet(), + sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - array = FALSE, - cm = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + array = FALSE, + cm = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, + ... ) { + + standardize_case_names(...) write_formula( wb = self, sheet = sheet, x = x, - startCol = startCol, - startRow = startRow, + startCol = start_col, + startRow = start_row, dims = dims, array = array, cm = cm, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle + applyCellStyle = apply_cell_style, + removeCellStyle = remove_cell_style ) invisible(self) }, @@ -1385,103 +1405,110 @@ wbWorkbook <- R6::R6Class( ### to dataframe ---- #' @description to_df #' @param sheet Either sheet name or index. When missing the first sheet in the workbook is selected. - #' @param colNames If TRUE, the first row of data will be used as column names. - #' @param rowNames If TRUE, the first col of data will be used as row names. + #' @param col_names If TRUE, the first row of data will be used as column names. + #' @param row_names If TRUE, the first col of data will be used as row names. #' @param dims Character string of type "A1:B2" as optional dimensions to be imported. - #' @param detectDates If TRUE, attempt to recognize dates and perform conversion. - #' @param showFormula If TRUE, the underlying Excel formulas are shown. + #' @param detect_dates If TRUE, attempt to recognize dates and perform conversion. + #' @param show_formula If TRUE, the underlying Excel formulas are shown. #' @param convert If TRUE, a conversion to dates and numerics is attempted. - #' @param skipEmptyCols If TRUE, empty columns are skipped. - #' @param skipEmptyRows If TRUE, empty rows are skipped. - #' @param skipHiddenCols If TRUE, hidden columns are skipped. - #' @param skipHiddenRows If TRUE, hidden rows are skipped. - #' @param startRow first row to begin looking for data. - #' @param startCol first column to begin looking for data. + #' @param skip_empty_cols If TRUE, empty columns are skipped. + #' @param skip_empty_rows If TRUE, empty rows are skipped. + #' @param skip_hidden_cols If TRUE, hidden columns are skipped. + #' @param skip_hidden_rows If TRUE, hidden rows are skipped. + #' @param start_row first row to begin looking for data. + #' @param start_col first column to begin looking for data. #' @param rows A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read. #' @param cols A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read. #' @param named_region Character string with a named_region (defined name or table). If no sheet is selected, the first appearance will be selected. #' @param types A named numeric indicating, the type of the data. 0: character, 1: numeric, 2: date, 3: posixt, 4:logical. Names must match the returned data #' @param na.strings A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA. #' @param na.numbers A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA. - #' @param fillMergedCells If TRUE, the value in a merged cell is given to all cells within the merge. + #' @param fill_merged_cells If TRUE, the value in a merged cell is given to all cells within the merge. #' @param keep_attributes If TRUE additional attributes are returned. (These are used internally to define a cell type.) + #' @param ... additional arguments #' @return a data frame to_df = function( sheet, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, - skipHiddenRows = FALSE, - skipHiddenCols = FALSE, - rows = NULL, - cols = NULL, - detectDates = TRUE, - na.strings = "#N/A", - na.numbers = NA, - fillMergedCells = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, + skip_hidden_rows = FALSE, + skip_hidden_cols = FALSE, + rows = NULL, + cols = NULL, + detect_dates = TRUE, + na.strings = "#N/A", + na.numbers = NA, + fill_merged_cells = FALSE, dims, - showFormula = FALSE, - convert = TRUE, + show_formula = FALSE, + convert = TRUE, types, named_region, - keep_attributes = FALSE + keep_attributes = FALSE, + ... ) { if (missing(sheet)) sheet <- substitute() if (missing(dims)) dims <- substitute() if (missing(named_region)) named_region <- substitute() + standardize_case_names(...) + wb_to_df( - xlsxFile = self, - sheet = sheet, - startRow = startRow, - startCol = startCol, - rowNames = rowNames, - colNames = colNames, - skipEmptyRows = skipEmptyRows, - skipEmptyCols = skipEmptyCols, - skipHiddenRows = skipHiddenRows, - skipHiddenCols = skipHiddenCols, - rows = rows, - cols = cols, - detectDates = detectDates, - na.strings = na.strings, - na.numbers = na.numbers, - fillMergedCells = fillMergedCells, - dims = dims, - showFormula = showFormula, - convert = convert, - types = types, - named_region = named_region + xlsx_file = self, + sheet = sheet, + start_row = start_row, + start_col = start_col, + row_names = row_names, + col_names = col_names, + skip_empty_rows = skip_empty_rows, + skip_empty_cols = skip_empty_cols, + skip_hidden_rows = skip_hidden_rows, + skip_hidden_cols = skip_hidden_cols, + rows = rows, + cols = cols, + detect_dates = detect_dates, + na.strings = na.strings, + na.numbers = na.numbers, + fill_merged_cells = fill_merged_cells, + dims = dims, + show_formula = show_formula, + convert = convert, + types = types, + named_region = named_region ) }, ### load workbook ---- #' @description load workbook #' @param file file - #' @param xlsxFile xlsxFile + #' @param xlsx_file xlsx_file #' @param sheet sheet #' @param data_only data_only #' @param calc_chain calc_chain + #' @param ... additional arguments #' @return The `wbWorkbook` object invisibly load = function( file, - xlsxFile = NULL, + xlsx_file = NULL, sheet, data_only = FALSE, - calc_chain = FALSE + calc_chain = FALSE, + ... ) { if (missing(file)) file <- substitute() if (missing(sheet)) sheet <- substitute() self <- wb_load( file = file, - xlsxFile = xlsxFile, + xlsx_file = xlsx_file, sheet = sheet, data_only = data_only, - calc_chain = calc_chain + calc_chain = calc_chain, + ... = ... ) invisible(self) }, @@ -2536,52 +2563,61 @@ wbWorkbook <- R6::R6Class( #' @description #' Get the base font - #' @param fontSize fontSize - #' @param fontColor fontColor - #' @param fontName fontName + #' @param font_size fontSize + #' @param font_color font_color + #' @param font_name font_name #' @param ... ... #' @return The `wbWorkbook` object - set_base_font = function(fontSize = 11, fontColor = wb_color(theme = "1"), fontName = "Calibri", ...) { - if (fontSize < 0) stop("Invalid fontSize") - standardize_color_names(...) - if (is.character(fontColor) && is.null(names(fontColor))) fontColor <- wb_color(fontColor) - self$styles_mgr$styles$fonts[[1]] <- create_font(sz = as.character(fontSize), color = fontColor, name = fontName) + set_base_font = function( + font_size = 11, + font_color = wb_color(theme = "1"), + font_name = "Calibri", + ... + ) { + standardize(...) + if (font_size < 0) stop("Invalid font_size") + if (!is_wbColour(font_color)) font_color <- wb_color(font_color) + self$styles_mgr$styles$fonts[[1]] <- create_font(sz = font_size, color = font_color, name = font_name) }, ### book views ---- #' @description #' Set the book views - #' @param activeTab activeTab - #' @param autoFilterDateGrouping autoFilterDateGrouping - #' @param firstSheet firstSheet + #' @param active_tab activeTab + #' @param auto_filter_date_grouping autoFilterDateGrouping + #' @param first_sheet firstSheet #' @param minimized minimized - #' @param showHorizontalScroll showHorizontalScroll - #' @param showSheetTabs showSheetTabs - #' @param showVerticalScroll showVerticalScroll - #' @param tabRatio tabRatio + #' @param show_horizontal_scroll showHorizontalScroll + #' @param show_sheet_tabs showSheetTabs + #' @param show_vertical_scroll showVerticalScroll + #' @param tab_ratio tabRatio #' @param visibility visibility - #' @param windowHeight windowHeight - #' @param windowWidth windowWidth - #' @param xWindow xWindow - #' @param yWindow yWindow + #' @param window_height windowHeight + #' @param window_width windowWidth + #' @param x_window xWindow + #' @param y_window yWindow + #' @param ... additional arguments #' @return The `wbWorkbook` object set_bookview = function( - activeTab = NULL, - autoFilterDateGrouping = NULL, - firstSheet = NULL, - minimized = NULL, - showHorizontalScroll = NULL, - showSheetTabs = NULL, - showVerticalScroll = NULL, - tabRatio = NULL, - visibility = NULL, - windowHeight = NULL, - windowWidth = NULL, - xWindow = NULL, - yWindow = NULL + active_tab = NULL, + auto_filter_date_grouping = NULL, + first_sheet = NULL, + minimized = NULL, + show_horizontal_scroll = NULL, + show_sheet_tabs = NULL, + show_vertical_scroll = NULL, + tab_ratio = NULL, + visibility = NULL, + window_height = NULL, + window_width = NULL, + x_window = NULL, + y_window = NULL, + ... ) { + standardize_case_names(...) + wbv <- self$workbook$bookViews if (is.null(wbv)) { @@ -2593,19 +2629,19 @@ wbWorkbook <- R6::R6Class( wbv <- xml_attr_mod( wbv, xml_attributes = c( - activeTab = as_xml_attr(activeTab), - autoFilterDateGrouping = as_xml_attr(autoFilterDateGrouping), - firstSheet = as_xml_attr(firstSheet), + activeTab = as_xml_attr(active_tab), + autoFilterDateGrouping = as_xml_attr(auto_filter_date_grouping), + firstSheet = as_xml_attr(first_sheet), minimized = as_xml_attr(minimized), - showHorizontalScroll = as_xml_attr(showHorizontalScroll), - showSheetTabs = as_xml_attr(showSheetTabs), - showVerticalScroll = as_xml_attr(showVerticalScroll), - tabRatio = as_xml_attr(tabRatio), + showHorizontalScroll = as_xml_attr(show_horizontal_scroll), + showSheetTabs = as_xml_attr(show_sheet_tabs), + showVerticalScroll = as_xml_attr(show_vertical_scroll), + tabRatio = as_xml_attr(tab_ratio), visibility = as_xml_attr(visibility), - windowHeight = as_xml_attr(windowHeight), - windowWidth = as_xml_attr(windowWidth), - xWindow = as_xml_attr(xWindow), - yWindow = as_xml_attr(yWindow) + windowHeight = as_xml_attr(window_height), + windowWidth = as_xml_attr(window_width), + xWindow = as_xml_attr(x_window), + yWindow = as_xml_attr(y_window) ), remove_empty_attr = FALSE ) @@ -3365,48 +3401,52 @@ wbWorkbook <- R6::R6Class( #' @description Adds data validation #' @param sheet sheet - #' @param cols cols - #' @param rows rows + #' @param dims cell dimension #' @param type type #' @param operator operator #' @param value value - #' @param allowBlank allowBlank - #' @param showInputMsg showInputMsg - #' @param showErrorMsg showErrorMsg - #' @param errorStyle The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input) - #' @param errorTitle The error title + #' @param allow_blank allowBlank + #' @param show_input_msg showInputMsg + #' @param show_error_msg showErrorMsg + #' @param error_style The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input) + #' @param error_title The error title #' @param error The error text - #' @param promptTitle The prompt title + #' @param prompt_title The prompt title #' @param prompt The prompt text + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_data_validation = function( - sheet = current_sheet(), - cols, - rows, + sheet = current_sheet(), + dims = "A1", type, operator, value, - allowBlank = TRUE, - showInputMsg = TRUE, - showErrorMsg = TRUE, - errorStyle = NULL, - errorTitle = NULL, - error = NULL, - promptTitle = NULL, - prompt = NULL + allow_blank = TRUE, + show_input_msg = TRUE, + show_error_msg = TRUE, + error_style = NULL, + error_title = NULL, + error = NULL, + prompt_title = NULL, + prompt = NULL, + ... ) { sheet <- private$get_sheet_index(sheet) - ## rows and cols - if (!is.numeric(cols)) { - cols <- col2int(cols) + cols <- list(...)[["cols"]] + rows <- list(...)[["rows"]] + + if (!is.null(rows) && !is.null(cols)) { + .Deprecated(old = "cols/rows", new = "dims", package = "openxlsx2") + dims <- rowcol_to_dims(rows, cols) } - rows <- as.integer(rows) - assert_class(allowBlank, "logical") - assert_class(showInputMsg, "logical") - assert_class(showErrorMsg, "logical") + standardize(...) + + assert_class(allow_blank, "logical") + assert_class(show_input_msg, "logical") + assert_class(show_error_msg, "logical") ## check length of value if (length(value) > 2) { @@ -3464,24 +3504,11 @@ wbWorkbook <- R6::R6Class( stop("If type == 'time' value argument must be a POSIXct or POSIXlt vector.") } - value <- head(value, 2) - allowBlank <- as.character(as.integer(allowBlank[1])) - showInputMsg <- as.character(as.integer(showInputMsg[1])) - showErrorMsg <- as.character(as.integer(showErrorMsg[1])) # prepare for worksheet origin <- get_date_origin(self, origin = TRUE) - sqref <- stri_join( - get_cell_refs(data.frame( - "x" = c(min(rows), max(rows)), - "y" = c(min(cols), max(cols)) - )), - sep = " ", - collapse = ":" - ) - if (type == "list") { operator <- NULL } @@ -3490,16 +3517,16 @@ wbWorkbook <- R6::R6Class( type = type, operator = operator, value = value, - allowBlank = allowBlank, - showInputMsg = showInputMsg, - showErrorMsg = showErrorMsg, - errorStyle = errorStyle, - errorTitle = errorTitle, + allowBlank = as_xml_attr(allow_blank), + showInputMsg = as_xml_attr(show_input_msg), + showErrorMsg = as_xml_attr(show_error_msg), + errorStyle = error_style, + errorTitle = error_title, error = error, - promptTitle = promptTitle, + promptTitle = prompt_title, prompt = prompt, origin = origin, - sqref = sqref + sqref = dims ) invisible(self) @@ -3633,24 +3660,28 @@ wbWorkbook <- R6::R6Class( #' @description Add comment #' @param sheet sheet - #' @param col column to apply the comment - #' @param row row to apply the comment #' @param dims row and column as spreadsheet dimension, e.g. "A1" #' @param comment a comment to apply to the worksheet + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_comment = function( sheet = current_sheet(), - col = NULL, - row = NULL, - dims = rowcol_to_dim(row, col), - comment + dims = "A1", + comment, + ... ) { + col <- list(...)[["col"]] + row <- list(...)[["row"]] + + if (!is.null(row) && !is.null(col)) { + .Deprecated(old = "col/row", new = "dims", package = "openxlsx2") + dims <- rowcol_to_dim(row, col) + } + write_comment( wb = self, sheet = sheet, - col = col, - row = row, comment = comment, dims = dims ) # has no use: xy @@ -3660,19 +3691,30 @@ wbWorkbook <- R6::R6Class( #' @description Remove comment #' @param sheet sheet - #' @param col column to apply the comment - #' @param row row to apply the comment #' @param dims row and column as spreadsheet dimension, e.g. "A1" - #' @param gridExpand Remove all comments inside the grid. Similar to dims "A1:B2" + #' @param ... additional arguments #' @returns The `wbWorkbook` object remove_comment = function( sheet = current_sheet(), - col = NULL, - row = NULL, - dims = rowcol_to_dims(row, col), - gridExpand = TRUE + dims = "A1", + ... ) { + col <- list(...)[["col"]] + row <- list(...)[["row"]] + gridExpand <- list(...)[["gridExpand"]] + + if ((!is.null(row) && !is.null(col))) { + .Deprecated(old = "col/row/gridExpand", new = "dims", package = "openxlsx2") + dims <- rowcol_to_dims(row, col) + } + + # TODO: remove with deprication + if (is.null(gridExpand)) { + # default until deprecating + gridExpand <- TRUE + } + remove_comment( wb = self, sheet = sheet, @@ -4005,36 +4047,39 @@ wbWorkbook <- R6::R6Class( #' @description #' Insert an image into a sheet #' @param sheet sheet + #' @param dims dims #' @param file file - #' @param startRow startRow - #' @param startCol startCol #' @param width width #' @param height height - #' @param rowOffset rowOffset - #' @param colOffset colOffset + #' @param row_offset,col_offset offsets #' @param units units #' @param dpi dpi - #' @param dims dims + #' @param ... additional arguments #' @return The `wbWorkbook` object, invisibly add_image = function( sheet = current_sheet(), + dims = "A1", file, width = 6, height = 3, - startRow = 1, - startCol = 1, - rowOffset = 0, - colOffset = 0, + row_offset = 0, + col_offset = 0, units = "in", dpi = 300, - dims = rowcol_to_dim(startRow, startCol) + ... ) { - if (!file.exists(file)) { - stop("File ", file, " does not exist.") + + standardize_case_names(...) + + if (exists("start_row") && !is.null(start_row) && + exists("start_col") && !is.null(start_col)) { + .Deprecated(old = "start_col/start_row", new = "dims", package = "openxlsx2") + start_col <- col2int(start_col) + start_row <- as.integer(start_row) } - if (is.null(dims) && (startRow > 1 || startCol > 1)) { - warning("dims is NULL, startRow/startCol will have no impact") + if (!file.exists(file)) { + stop("File ", file, " does not exist.") } # TODO require user to pass a valid path @@ -4049,9 +4094,6 @@ wbWorkbook <- R6::R6Class( stop("Invalid units.\nunits must be one of: cm, in, px") } - startCol <- col2int(startCol) - startRow <- as.integer(startRow) - ## convert to inches if (units == "px") { width <- width / dpi @@ -4072,8 +4114,6 @@ wbWorkbook <- R6::R6Class( imageType <- gsub("^\\.", "", imageType) mediaNo <- length(self$media) + 1L - startCol <- col2int(startCol) - ## update Content_Types if (!any(grepl(stri_join("image/", imageType), self$Content_Types))) { self$Content_Types <- @@ -4125,8 +4165,13 @@ wbWorkbook <- R6::R6Class( xml_attributes = xml_attr ) - self$add_drawing(sheet, drawing, dims, colOffset, rowOffset) - + self$add_drawing( + sheet = sheet, + dims = dims, + xml = drawing, + col_offset = col_offset, + row_offset = row_offset + ) # add image to drawings_rels old_drawings_rels <- unlist(self$drawings_rels[[sheet_drawing]]) @@ -4149,36 +4194,42 @@ wbWorkbook <- R6::R6Class( #' @description Add plot. A wrapper for add_image() #' @param sheet sheet + #' @param dims dims #' @param width width #' @param height height - #' @param startRow startRow - #' @param startCol startCol - #' @param rowOffset rowOffset - #' @param colOffset colOffset - #' @param fileType fileType + #' @param row_offset,col_offset offsets + #' @param file_type fileType #' @param units units #' @param dpi dpi - #' @param dims dims + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_plot = function( - sheet = current_sheet(), - width = 6, - height = 4, - startRow = 1, - startCol = 1, - rowOffset = 0, - colOffset = 0, - fileType = "png", - units = "in", - dpi = 300, - dims = rowcol_to_dim(startRow, startCol) + sheet = current_sheet(), + dims = "A1", + width = 6, + height = 4, + row_offset = 0, + col_offset = 0, + file_type = "png", + units = "in", + dpi = 300, + ... ) { + + standardize_case_names(...) + + if (exists("start_row") && !is.null(start_row) && + exists("start_col") && !is.null(start_col)) { + .Deprecated(old = "start_row/start_col", new = "dims", package = "openxlsx2") + dims <- rowcol_to_dims(start_row, start_col) + } + if (is.null(dev.list()[[1]])) { warning("No plot to insert.") return(invisible(self)) } - fileType <- tolower(fileType) + fileType <- tolower(file_type) units <- tolower(units) # TODO just don't allow jpg @@ -4195,7 +4246,7 @@ wbWorkbook <- R6::R6Class( stop("Invalid units.\nunits must be one of: cm, in, px") } - fileName <- tempfile(pattern = "figureImage", fileext = paste0(".", fileType)) + fileName <- tempfile(pattern = "figureImage", fileext = paste0(".", file_type)) # Workaround for wrapper test. Otherwise tempfile names differ if (requireNamespace("testthat")) { @@ -4218,17 +4269,15 @@ wbWorkbook <- R6::R6Class( stopifnot(file.exists(fileName)) self$add_image( - sheet = sheet, - file = fileName, - width = width, - height = height, - startRow = startRow, - startCol = startCol, - rowOffset = rowOffset, - colOffset = colOffset, - units = units, - dpi = dpi, - dims = dims + sheet = sheet, + dims = dims, + file = fileName, + width = width, + height = height, + row_offset = row_offset, + col_offset = col_offset, + units = units, + dpi = dpi ) }, @@ -4236,15 +4285,20 @@ wbWorkbook <- R6::R6Class( #' @param sheet sheet #' @param dims dims #' @param xml xml - #' @param colOffset,rowOffset offsets for column and row + #' @param col_offset,row_offset offsets for column and row + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_drawing = function( - sheet = current_sheet(), + sheet = current_sheet(), + dims = "A1", xml, - dims = NULL, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... ) { + + standardize_case_names(...) + sheet <- private$get_sheet_index(sheet) is_chartsheet <- self$is_chartsheet[sheet] @@ -4295,8 +4349,8 @@ wbWorkbook <- R6::R6Class( dims_list <- strsplit(dims, ":")[[1]] cols <- col2int(dims_list) rows <- as.numeric(gsub("\\D+", "", dims_list)) - if (length(colOffset) != 2) colOffset <- rep(colOffset, 2) - if (length(rowOffset) != 2) rowOffset <- rep(rowOffset, 2) + if (length(col_offset) != 2) col_offset <- rep(col_offset, 2) + if (length(row_offset) != 2) row_offset <- rep(row_offset, 2) anchor <- paste0( "", @@ -4310,10 +4364,10 @@ wbWorkbook <- R6::R6Class( ) anchor <- sprintf( anchor, - cols[1] - 1L, colOffset[1], - rows[1] - 1L, rowOffset[1], - cols[2], colOffset[2], - rows[2], rowOffset[2] + cols[1] - 1L, col_offset[1], + rows[1] - 1L, row_offset[1], + cols[2], col_offset[2], + rows[2], row_offset[2] ) } else { @@ -4331,8 +4385,8 @@ wbWorkbook <- R6::R6Class( ) anchor <- sprintf( anchor, - cols[1] - 1L, colOffset[1], - rows[1] - 1L, rowOffset[1] + cols[1] - 1L, col_offset[1], + rows[1] - 1L, row_offset[1] ) } @@ -4401,16 +4455,28 @@ wbWorkbook <- R6::R6Class( #' @param sheet sheet #' @param dims dims #' @param xml xml - #' @param colOffset,rowOffset startCol and startRow + #' @param col_offset,row_offset positioning parameters + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_chart_xml = function( - sheet = current_sheet(), + sheet = current_sheet(), + dims = NULL, xml, - dims = NULL, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... ) { + args <- list(...) + + standardize_case_names(...) + + if (exists("start_row") && !is.null(start_row) && + exists("start_col") && !is.null(start_col)) { + .Deprecated(old = "start_col/start_row", new = "dims", package = "openxlsx2") + dims <- rowcol_to_dims(args$start_row, args$start_col) + } + sheet <- private$get_sheet_index(sheet) if (length(self$worksheets[[sheet]]$relships$drawing)) { # if one is found: we have to select this drawing @@ -4423,12 +4489,12 @@ wbWorkbook <- R6::R6Class( next_chart <- NROW(self$charts) + 1 chart <- data.frame( - chart = xml, - colors = colors1_xml, - style = styleplot_xml, - rels = chart1_rels_xml(next_chart), + chart = xml, + colors = colors1_xml, + style = styleplot_xml, + rels = chart1_rels_xml(next_chart), chartEx = "", - relsEx = "" + relsEx = "" ) self$charts <- rbind(self$charts, chart) @@ -4437,11 +4503,11 @@ wbWorkbook <- R6::R6Class( # create drawing. add it to self$drawings, the worksheet and rels self$add_drawing( - sheet = sheet, - xml = next_chart, - dims = dims, - colOffset = colOffset, - rowOffset = rowOffset + sheet = sheet, + dims = dims, + xml = next_chart, + col_offset = col_offset, + row_offset = row_offset ) sheet_drawing <- self$worksheets[[sheet]]$relships$drawing @@ -4458,16 +4524,20 @@ wbWorkbook <- R6::R6Class( #' @param sheet the sheet on which the graph will appear #' @param dims the dimensions where the sheet will appear #' @param graph mschart graph - #' @param colOffset,rowOffset startCol and startRow + #' @param col_offset,row_offset offsets for column and row + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_mschart = function( - sheet = current_sheet(), - dims = NULL, + sheet = current_sheet(), + dims = NULL, graph, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... ) { + standardize_case_names(...) + requireNamespace("mschart") assert_class(graph, "ms_chart") @@ -4488,11 +4558,23 @@ wbWorkbook <- R6::R6Class( # write the chart data to the workbook if (inherits(graph$data_series, "wb_data")) { self$ - add_chart_xml(sheet = sheet, xml = out_xml, dims = dims, colOffset = colOffset, rowOffset = rowOffset) + add_chart_xml( + sheet = sheet, + dims = dims, + xml = out_xml, + col_offset = col_offset, + row_offset = row_offset + ) } else { self$ add_data(sheet = sheet, x = graph$data_series)$ - add_chart_xml(sheet = sheet, xml = out_xml, dims = dims, colOffset = colOffset, rowOffset = rowOffset) + add_chart_xml( + sheet = sheet, + dims = dims, + xml = out_xml, + col_offset = col_offset, + row_offset = row_offset + ) } }, @@ -5067,20 +5149,25 @@ wbWorkbook <- R6::R6Class( #' @param sheet sheet #' @param header header #' @param footer footer - #' @param evenHeader evenHeader - #' @param evenFooter evenFooter - #' @param firstHeader firstHeader - #' @param firstFooter firstFooter + #' @param even_header evenHeader + #' @param even_footer evenFooter + #' @param first_header firstHeader + #' @param first_footer firstFooter + #' @param ... additional arguments #' @return The `wbWorkbook` object, invisibly set_header_footer = function( sheet = current_sheet(), - header = NULL, - footer = NULL, - evenHeader = NULL, - evenFooter = NULL, - firstHeader = NULL, - firstFooter = NULL + header = NULL, + footer = NULL, + even_header = NULL, + even_footer = NULL, + first_header = NULL, + first_footer = NULL, + ... ) { + + standardize_case_names(...) + sheet <- private$get_sheet_index(sheet) if (!is.null(header) && length(header) != 3) { @@ -5091,29 +5178,29 @@ wbWorkbook <- R6::R6Class( stop("footer must have length 3 where elements correspond to positions: left, center, right.") } - if (!is.null(evenHeader) && length(evenHeader) != 3) { + if (!is.null(even_header) && length(even_header) != 3) { stop("evenHeader must have length 3 where elements correspond to positions: left, center, right.") } - if (!is.null(evenFooter) && length(evenFooter) != 3) { + if (!is.null(even_footer) && length(even_footer) != 3) { stop("evenFooter must have length 3 where elements correspond to positions: left, center, right.") } - if (!is.null(firstHeader) && length(firstHeader) != 3) { + if (!is.null(first_header) && length(first_header) != 3) { stop("firstHeader must have length 3 where elements correspond to positions: left, center, right.") } - if (!is.null(firstFooter) && length(firstFooter) != 3) { + if (!is.null(first_footer) && length(first_footer) != 3) { stop("firstFooter must have length 3 where elements correspond to positions: left, center, right.") } # TODO this could probably be moved to the hf assignment oddHeader <- headerFooterSub(header) oddFooter <- headerFooterSub(footer) - evenHeader <- headerFooterSub(evenHeader) - evenFooter <- headerFooterSub(evenFooter) - firstHeader <- headerFooterSub(firstHeader) - firstFooter <- headerFooterSub(firstFooter) + evenHeader <- headerFooterSub(even_header) + evenFooter <- headerFooterSub(even_footer) + firstHeader <- headerFooterSub(first_header) + firstFooter <- headerFooterSub(first_footer) hf <- list( oddHeader = naToNULLList(oddHeader), @@ -5264,68 +5351,60 @@ wbWorkbook <- R6::R6Class( #' @description add a named region #' @param sheet sheet #' @param dims dims - #' @param cols cols - #' @param rows rows #' @param name name - #' @param localSheet localSheet + #' @param local_sheet local_sheet #' @param overwrite overwrite #' @param comment comment - #' @param customMenu customMenu + #' @param custom_menu custom_menu #' @param description description #' @param is_function function - #' @param functionGroupId function group id + #' @param function_group_id function group id #' @param help help #' @param hidden hidden - #' @param localName localName - #' @param publishToServer publish to server - #' @param statusBar status bar - #' @param vbProcedure wbProcedure - #' @param workbookParameter workbookParameter + #' @param local_name localName + #' @param publish_to_server publish to server + #' @param status_bar status bar + #' @param vb_procedure vb procedure + #' @param workbook_parameter workbookParameter #' @param xml xml + #' @param ... additional arguments #' @returns The `wbWorkbook` object add_named_region = function( sheet = current_sheet(), dims = "A1", - cols, - rows, name, - localSheet = FALSE, - overwrite = FALSE, - comment = NULL, - customMenu = NULL, - description = NULL, - is_function = NULL, - functionGroupId = NULL, - help = NULL, - hidden = NULL, - localName = NULL, - publishToServer = NULL, - statusBar = NULL, - vbProcedure = NULL, - workbookParameter = NULL, - xml = NULL + local_sheet = FALSE, + overwrite = FALSE, + comment = NULL, + custom_menu = NULL, + description = NULL, + is_function = NULL, + function_group_id = NULL, + help = NULL, + hidden = NULL, + local_name = NULL, + publish_to_server = NULL, + status_bar = NULL, + vb_procedure = NULL, + workbook_parameter = NULL, + xml = NULL, + ... ) { - sheet <- private$get_sheet_index(sheet) - if (!missing(cols) && !missing(rows)) { + standardize_case_names(...) - if (!is.numeric(rows)) { - stop("rows argument must be a numeric/integer vector") - } - - if (!is.numeric(cols) && !is.character(cols)) { - stop("cols argument must be a character or numeric/integer vector") - } + sheet <- private$get_sheet_index(sheet) - # TODO not sure why this is here - cols <- round(cols) - rows <- round(rows) + cols <- list(...)[["cols"]] + rows <- list(...)[["rows"]] + if (!is.null(rows) && !is.null(cols)) { + .Deprecated(old = "cols/rows", new = "dims", package = "openxlsx2") dims <- rowcol_to_dims(rows, cols) } localSheetId <- "" - if (localSheet) localSheetId <- as.character(sheet) + if (local_sheet) localSheetId <- as.character(sheet) ## check name doesn't already exist ## named region @@ -5371,17 +5450,17 @@ wbWorkbook <- R6::R6Class( sheet = self$sheet_names[sheet], localSheetId = localSheetId, comment = comment, - customMenu = customMenu, + customMenu = custom_menu, description = description, is_function = is_function, - functionGroupId = functionGroupId, + functionGroupId = function_group_id, help = help, hidden = hidden, - localName = localName, - publishToServer = publishToServer, - statusBar = statusBar, - vbProcedure = vbProcedure, - workbookParameter = workbookParameter, + localName = local_name, + publishToServer = publish_to_server, + statusBar = status_bar, + vbProcedure = vb_procedure, + workbookParameter = workbook_parameter, xml = xml ) @@ -6048,31 +6127,31 @@ wbWorkbook <- R6::R6Class( #' @param scheme font scheme #' @param shadow shadow #' @param extend extend - #' @param vertAlign vertical alignment + #' @param vert_align vertical alignment #' @param ... ... #' @examples #' wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars) #' wb$add_font("S1", "A1:K1", name = "Arial", color = wb_color(theme = "4")) #' @return The `wbWorksheetObject`, invisibly add_font = function( - sheet = current_sheet(), - dims = "A1", - name = "Calibri", - color = wb_color(hex = "FF000000"), - size = "11", - bold = "", - italic = "", - outline = "", - strike = "", - underline = "", + sheet = current_sheet(), + dims = "A1", + name = "Calibri", + color = wb_color(hex = "FF000000"), + size = "11", + bold = "", + italic = "", + outline = "", + strike = "", + underline = "", # fine tuning - charset = "", - condense = "", - extend = "", - family = "", - scheme = "", - shadow = "", - vertAlign = "", + charset = "", + condense = "", + extend = "", + family = "", + scheme = "", + shadow = "", + vert_align = "", ... ) { sheet <- private$get_sheet_index(sheet) @@ -6085,7 +6164,7 @@ wbWorkbook <- R6::R6Class( cc <- cc[cc$r %in% dims, ] styles <- unique(cc[["c_s"]]) - standardize_color_names(...) + standardize(...) for (style in styles) { dim <- cc[cc$c_s == style, "r"] @@ -6105,7 +6184,7 @@ wbWorkbook <- R6::R6Class( strike = strike, sz = size, u = underline, - vertAlign = vertAlign + vertAlign = vert_align ) self$styles_mgr$add(new_font, new_font) @@ -6179,33 +6258,34 @@ wbWorkbook <- R6::R6Class( #' @description provide simple cell style format function #' @param sheet the worksheet #' @param dims the cell range - #' @param extLst extension list something like `...` + #' @param ext_lst extension list something like `...` #' @param hidden logical cell is hidden #' @param horizontal align content horizontal ('left', 'center', 'right') #' @param indent logical indent content - #' @param justifyLastLine logical justify last line + #' @param justify_last_line logical justify last line #' @param locked logical cell is locked - #' @param pivotButton unknown - #' @param quotePrefix unknown - #' @param readingOrder reading order left to right - #' @param relativeIndent relative indentation - #' @param shrinkToFit logical shrink to fit - #' @param textRotation degrees of text rotation + #' @param pivot_button unknown + #' @param quote_prefix unknown + #' @param reading_order reading order left to right + #' @param relative_indent relative indentation + #' @param shrink_to_fit logical shrink to fit + #' @param text_rotation degrees of text rotation #' @param vertical vertical alignment of content ('top', 'center', 'bottom') - #' @param wrapText wrap text in cell + #' @param wrap_text wrap text in cell # alignments - #' @param applyAlignment logical apply alignment - #' @param applyBorder logical apply border - #' @param applyFill logical apply fill - #' @param applyFont logical apply font - #' @param applyNumberFormat logical apply number format - #' @param applyProtection logical apply protection + #' @param apply_alignment logical apply alignment + #' @param apply_border logical apply border + #' @param apply_fill logical apply fill + #' @param apply_font logical apply font + #' @param apply_number_format logical apply number format + #' @param apply_protection logical apply protection # ids - #' @param borderId border ID to apply - #' @param fillId fill ID to apply - #' @param fontId font ID to apply - #' @param numFmtId number format ID to apply - #' @param xfId xf ID to apply + #' @param border_id border ID to apply + #' @param fill_id fill ID to apply + #' @param font_id font ID to apply + #' @param num_fmt_id number format ID to apply + #' @param xf_id xf ID to apply + #' @param ... additional arguments #' @examples #' wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars) #' wb$add_cell_style("S1", "A1:K1", @@ -6215,34 +6295,38 @@ wbWorkbook <- R6::R6Class( #' wrapText = "1") #' @return The `wbWorksheetObject`, invisibly add_cell_style = function( - sheet = current_sheet(), - dims = "A1", - applyAlignment = NULL, - applyBorder = NULL, - applyFill = NULL, - applyFont = NULL, - applyNumberFormat = NULL, - applyProtection = NULL, - borderId = NULL, - extLst = NULL, - fillId = NULL, - fontId = NULL, - hidden = NULL, - horizontal = NULL, - indent = NULL, - justifyLastLine = NULL, - locked = NULL, - numFmtId = NULL, - pivotButton = NULL, - quotePrefix = NULL, - readingOrder = NULL, - relativeIndent = NULL, - shrinkToFit = NULL, - textRotation = NULL, - vertical = NULL, - wrapText = NULL, - xfId = NULL + sheet = current_sheet(), + dims = "A1", + apply_alignment = NULL, + apply_border = NULL, + apply_fill = NULL, + apply_font = NULL, + apply_number_format = NULL, + apply_protection = NULL, + border_id = NULL, + ext_lst = NULL, + fill_id = NULL, + font_id = NULL, + hidden = NULL, + horizontal = NULL, + indent = NULL, + justify_last_line = NULL, + locked = NULL, + num_fmt_id = NULL, + pivot_button = NULL, + quote_prefix = NULL, + reading_order = NULL, + relative_indent = NULL, + shrink_to_fit = NULL, + text_rotation = NULL, + vertical = NULL, + wrap_text = NULL, + xf_id = NULL, + ... ) { + + standardize_case_names(...) + sheet <- private$get_sheet_index(sheet) private$do_cell_init(sheet, dims) @@ -6258,31 +6342,31 @@ wbWorkbook <- R6::R6Class( xf_prev <- get_cell_styles(self, sheet, dim[[1]]) xf_new_cellstyle <- set_cellstyle( xf_node = xf_prev, - applyAlignment = applyAlignment, - applyBorder = applyBorder, - applyFill = applyFill, - applyFont = applyFont, - applyNumberFormat = applyNumberFormat, - applyProtection = applyProtection, - borderId = borderId, - extLst = extLst, - fillId = fillId, - fontId = fontId, + applyAlignment = apply_alignment, + applyBorder = apply_border, + applyFill = apply_fill, + applyFont = apply_font, + applyNumberFormat = apply_number_format, + applyProtection = apply_protection, + borderId = border_id, + extLst = ext_lst, + fillId = fill_id, + fontId = font_id, hidden = hidden, horizontal = horizontal, indent = indent, - justifyLastLine = justifyLastLine, + justifyLastLine = justify_last_line, locked = locked, - numFmtId = numFmtId, - pivotButton = pivotButton, - quotePrefix = quotePrefix, - readingOrder = readingOrder, - relativeIndent = relativeIndent, - shrinkToFit = shrinkToFit, - textRotation = textRotation, + numFmtId = num_fmt_id, + pivotButton = pivot_button, + quotePrefix = quote_prefix, + readingOrder = reading_order, + relativeIndent = relative_indent, + shrinkToFit = shrink_to_fit, + textRotation = text_rotation, vertical = vertical, - wrapText = wrapText, - xfId = xfId + wrapText = wrap_text, + xfId = xf_id ) self$styles_mgr$add(xf_new_cellstyle, xf_new_cellstyle) s_id <- self$styles_mgr$get_xf_id(xf_new_cellstyle) @@ -6381,12 +6465,12 @@ wbWorkbook <- R6::R6Class( #' @param font_name the font name #' @param font_size the font size #' @param font_color the font color (a `wb_color()` object) - #' @param numFmt the number format + #' @param num_fmt the number format #' @param border logical if borders are applied #' @param border_color the border color #' @param border_style the border style - #' @param bgFill any background fill - #' @param gradientFill any gradient fill + #' @param bg_fill any background fill + #' @param gradient_fill any gradient fill #' @param text_bold logical if text is bold #' @param text_italic logical if text is italic #' @param text_underline logical if text is underlined @@ -6398,28 +6482,30 @@ wbWorkbook <- R6::R6Class( font_name = NULL, font_size = NULL, font_color = NULL, - numFmt = NULL, + num_fmt = NULL, border = NULL, border_color = wb_color(getOption("openxlsx2.borderColor", "black")), border_style = getOption("openxlsx2.borderStyle", "thin"), - bgFill = NULL, - gradientFill = NULL, + bg_fill = NULL, + gradient_fill = NULL, text_bold = NULL, text_italic = NULL, text_underline = NULL, ... ) { + standardize(...) + xml_style <- create_dxfs_style( font_name = font_name, font_size = font_size, font_color = font_color, - numFmt = numFmt, + num_fmt = num_fmt, border = border, border_color = border_color, border_style = border_style, - bgFill = bgFill, - gradientFill = gradientFill, + bg_fill = bg_fill, + gradient_fill = gradient_fill, text_bold = text_bold, text_italic = text_italic, text_underline = text_underline, @@ -6521,108 +6607,110 @@ wbWorkbook <- R6::R6Class( #' @description Ignore error on worksheet #' @param sheet sheet #' @param dims dims - #' @param calculatedColumn calculatedColumn - #' @param emptyCellReference emptyCellReference - #' @param evalError evalError + #' @param calculated_column calculatedColumn + #' @param empty_cell_reference emptyCellReference + #' @param eval_error evalError #' @param formula formula - #' @param formulaRange formulaRange - #' @param listDataValidation listDataValidation - #' @param numberStoredAsText numberStoredAsText - #' @param twoDigitTextYear twoDigitTextYear - #' @param unlockedFormula unlockedFormula + #' @param formula_range formulaRange + #' @param list_data_validation listDataValidation + #' @param number_stored_as_text numberStoredAsText + #' @param two_digit_text_year twoDigitTextYear + #' @param unlocked_formula unlockedFormula + #' @param ... additional arguments add_ignore_error = function( - sheet = current_sheet(), - dims = "A1", - calculatedColumn = FALSE, - emptyCellReference = FALSE, - evalError = FALSE, - formula = FALSE, - formulaRange = FALSE, - listDataValidation = FALSE, - numberStoredAsText = FALSE, - twoDigitTextYear = FALSE, - unlockedFormula = FALSE + sheet = current_sheet(), + dims = "A1", + calculated_column = FALSE, + empty_cell_reference = FALSE, + eval_error = FALSE, + formula = FALSE, + formula_range = FALSE, + list_data_validation = FALSE, + number_stored_as_text = FALSE, + two_digit_text_year = FALSE, + unlocked_formula = FALSE, + ... ) { + standardize_case_names(...) sheet <- private$get_sheet_index(sheet) self$worksheets[[sheet]]$ignore_error( dims = dims, - calculatedColumn = calculatedColumn, - emptyCellReference = emptyCellReference, - evalError = evalError, + calculatedColumn = calculated_column, + emptyCellReference = empty_cell_reference, + evalError = eval_error, formula = formula, - formulaRange = formulaRange, - listDataValidation = listDataValidation, - numberStoredAsText = numberStoredAsText, - twoDigitTextYear = twoDigitTextYear, - unlockedFormula = unlockedFormula + formulaRange = formula_range, + listDataValidation = list_data_validation, + numberStoredAsText = number_stored_as_text, + twoDigitTextYear = two_digit_text_year, + unlockedFormula = unlocked_formula ) }, #' @description add sheetview #' @param sheet sheet - #' @param colorId colorId - #' @param defaultGridColor defaultGridColor - #' @param rightToLeft rightToLeft - #' @param showFormulas showFormulas - #' @param showGridLines showGridLines - #' @param showOutlineSymbols showOutlineSymbols - #' @param showRowColHeaders showRowColHeaders - #' @param showRuler showRuler - #' @param showWhiteSpace showWhiteSpace - #' @param showZeros showZeros - #' @param tabSelected tabSelected - #' @param topLeftCell topLeftCell - #' @param view view - #' @param windowProtection windowProtection - #' @param workbookViewId workbookViewId - #' @param zoomScale zoomScale - #' @param zoomScaleNormal zoomScaleNormal - #' @param zoomScalePageLayoutView zoomScalePageLayoutView - #' @param zoomScaleSheetLayoutView zoomScaleSheetLayoutView + #' @param color_id,default_grid_color Integer: A color, default is 64 + #' @param right_to_left Logical: if TRUE column ordering is right to left + #' @param show_formulas Logical: if TRUE cell formulas are shown + #' @param show_grid_lines Logical: if TRUE the worksheet grid is shown + #' @param show_outline_symbols Logical: if TRUE outline symbols are shown + #' @param show_row_col_headers Logical: if TRUE row and column headers are shown + #' @param show_ruler Logical: if TRUE a ruler is shown in page layout view + #' @param show_white_space Logical: if TRUE margins are shown in page layout view + #' @param show_zeros Logical: if FALSE cells containing zero are shown blank if !showFormulas + #' @param tab_selected Integer: zero vector indicating the selected tab + #' @param top_left_cell Cell: the cell shown in the top left corner / or top right with rightToLeft + #' @param view View: "normal", "pageBreakPreview" or "pageLayout" + #' @param window_protection Logical: if TRUE the panes are protected + #' @param workbook_view_id integer: Pointing to some other view inside the workbook + #' @param zoom_scale,zoom_scale_normal,zoom_scale_page_layout_view,zoom_scale_sheet_layout_view Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc. + #' @param ... additional arguments #' @return The `wbWorksheetObject`, invisibly set_sheetview = function( sheet = current_sheet(), - colorId = NULL, - defaultGridColor = NULL, - rightToLeft = NULL, - showFormulas = NULL, - showGridLines = NULL, - showOutlineSymbols = NULL, - showRowColHeaders = NULL, - showRuler = NULL, - showWhiteSpace = NULL, - showZeros = NULL, - tabSelected = NULL, - topLeftCell = NULL, - view = NULL, - windowProtection = NULL, - workbookViewId = NULL, - zoomScale = NULL, - zoomScaleNormal = NULL, - zoomScalePageLayoutView = NULL, - zoomScaleSheetLayoutView = NULL + color_id = NULL, + default_grid_color = NULL, + right_to_left = NULL, + show_formulas = NULL, + show_grid_lines = NULL, + show_outline_symbols = NULL, + show_row_col_headers = NULL, + show_ruler = NULL, + show_white_space = NULL, + show_zeros = NULL, + tab_selected = NULL, + top_left_cell = NULL, + view = NULL, + window_protection = NULL, + workbook_view_id = NULL, + zoom_scale = NULL, + zoom_scale_normal = NULL, + zoom_scale_page_layout_view = NULL, + zoom_scale_sheet_layout_view = NULL, + ... ) { sheet <- private$get_sheet_index(sheet) self$worksheets[[sheet]]$set_sheetview( - colorId = colorId, - defaultGridColor = defaultGridColor, - rightToLeft = rightToLeft, - showFormulas = showFormulas, - showGridLines = showGridLines, - showOutlineSymbols = showOutlineSymbols, - showRowColHeaders = showRowColHeaders, - showRuler = showRuler, - showWhiteSpace = showWhiteSpace, - showZeros = showZeros, - tabSelected = tabSelected, - topLeftCell = topLeftCell, - view = view, - windowProtection = windowProtection, - workbookViewId = workbookViewId, - zoomScale = zoomScale, - zoomScaleNormal = zoomScaleNormal, - zoomScalePageLayoutView = zoomScalePageLayoutView, - zoomScaleSheetLayoutView = zoomScaleSheetLayoutView + color_id = color_id, + default_grid_color = default_grid_color, + right_to_left = right_to_left, + show_formulas = show_formulas, + show_grid_lines = show_grid_lines, + show_outline_symbols = show_outline_symbols, + show_row_col_headers = show_row_col_headers, + show_ruler = show_ruler, + show_white_space = show_white_space, + show_zeros = show_zeros, + tab_selected = tab_selected, + top_left_cell = top_left_cell, + view = view, + window_protection = window_protection, + workbook_view_id = workbook_view_id, + zoom_scale = zoom_scale, + zoom_scale_normal = zoom_scale_normal, + zoom_scale_page_layout_view = zoom_scale_page_layout_view, + zoom_scale_sheet_layout_view = zoom_scale_sheet_layout_view, + ... = ... ) invisible(self) } @@ -7425,12 +7513,12 @@ wbWorkbook <- R6::R6Class( if (is.null(self$workbook$bookViews)) self$set_bookview( - xWindow = 0, - yWindow = 0, - windowWidth = 13125, - windowHeight = 13125, - firstSheet = visible_sheet_index - 1L, - activeTab = visible_sheet_index - 1L + x_window = 0, + y_window = 0, + window_width = 13125, + window_height = 13125, + first_sheet = visible_sheet_index - 1L, + active_tab = visible_sheet_index - 1L ) # Failsafe: hidden sheet can not be selected. diff --git a/R/class-worksheet.R b/R/class-worksheet.R index 71b35c4ae..ffd29150f 100644 --- a/R/class-worksheet.R +++ b/R/class-worksheet.R @@ -5,7 +5,8 @@ #' #' A Worksheet #' -#' @export +#' @keywords internal +#' @noRd wbWorksheet <- R6::R6Class( "wbWorksheet", @@ -140,46 +141,51 @@ 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 grid_lines printGridLines + #' @param ... additional arguments #' @return a `wbWorksheet` object initialize = function( - tabColor = NULL, - oddHeader = NULL, - oddFooter = NULL, - evenHeader = NULL, - evenFooter = NULL, - firstHeader = NULL, - firstFooter = NULL, - paperSize = 9, - orientation = "portrait", - hdpi = 300, - vdpi = 300, - printGridLines = FALSE + tab_color = NULL, + odd_header = NULL, + odd_footer = NULL, + even_header = NULL, + even_footer = NULL, + first_header = NULL, + first_footer = NULL, + paper_size = 9, + orientation = "portrait", + hdpi = 300, + vdpi = 300, + grid_lines = FALSE, + ... ) { - if (!is.null(tabColor)) { - tabColor <- sprintf('', tabColor) + + standardize_case_names(...) + + if (!is.null(tab_color)) { + tabColor <- sprintf('', tab_color) } else { tabColor <- character() } hf <- list( - oddHeader = na_to_null(oddHeader), - oddFooter = na_to_null(oddFooter), - evenHeader = na_to_null(evenHeader), - evenFooter = na_to_null(evenFooter), - firstHeader = na_to_null(firstHeader), - firstFooter = na_to_null(firstFooter) + oddHeader = na_to_null(odd_header), + oddFooter = na_to_null(odd_footer), + evenHeader = na_to_null(even_header), + evenFooter = na_to_null(even_footer), + firstHeader = na_to_null(first_header), + firstFooter = na_to_null(first_footer) ) if (all(lengths(hf) == 0)) { @@ -187,8 +193,8 @@ wbWorksheet <- R6::R6Class( } # only add if printGridLines not TRUE. The openxml default is TRUE - if (printGridLines) { - self$set_print_options(gridLines = printGridLines, gridLinesSet = printGridLines) + if (grid_lines) { + self$set_print_options(gridLines = grid_lines, gridLinesSet = grid_lines) } ## list of all possible children @@ -203,7 +209,7 @@ wbWorksheet <- R6::R6Class( self$dataValidations <- NULL self$hyperlinks <- list() self$pageMargins <- '' - self$pageSetup <- sprintf('', paperSize, orientation, hdpi, vdpi) + self$pageSetup <- sprintf('', paper_size, orientation, hdpi, vdpi) self$headerFooter <- hf self$rowBreaks <- character() self$colBreaks <- character() @@ -674,48 +680,49 @@ wbWorksheet <- R6::R6Class( }, #' @description add sheetview - #' @param colorId colorId - #' @param defaultGridColor defaultGridColor - #' @param rightToLeft rightToLeft - #' @param showFormulas showFormulas - #' @param showGridLines showGridLines - #' @param showOutlineSymbols showOutlineSymbols - #' @param showRowColHeaders showRowColHeaders - #' @param showRuler showRuler - #' @param showWhiteSpace showWhiteSpace - #' @param showZeros showZeros - #' @param tabSelected tabSelected - #' @param topLeftCell topLeftCell - #' @param view view - #' @param windowProtection windowProtection - #' @param workbookViewId workbookViewId - #' @param zoomScale zoomScale - #' @param zoomScaleNormal zoomScaleNormal - #' @param zoomScalePageLayoutView zoomScalePageLayoutView - #' @param zoomScaleSheetLayoutView zoomScaleSheetLayoutView + #' @param sheet sheet + #' @param color_id,default_grid_color Integer: A color, default is 64 + #' @param right_to_left Logical: if TRUE column ordering is right to left + #' @param show_formulas Logical: if TRUE cell formulas are shown + #' @param show_grid_lines Logical: if TRUE the worksheet grid is shown + #' @param show_outline_symbols Logical: if TRUE outline symbols are shown + #' @param show_row_col_headers Logical: if TRUE row and column headers are shown + #' @param show_ruler Logical: if TRUE a ruler is shown in page layout view + #' @param show_white_space Logical: if TRUE margins are shown in page layout view + #' @param show_zeros Logical: if FALSE cells containing zero are shown blank if !showFormulas + #' @param tab_selected Integer: zero vector indicating the selected tab + #' @param top_left_cell Cell: the cell shown in the top left corner / or top right with rightToLeft + #' @param view View: "normal", "pageBreakPreview" or "pageLayout" + #' @param window_protection Logical: if TRUE the panes are protected + #' @param workbook_view_id integer: Pointing to some other view inside the workbook + #' @param zoom_scale,zoom_scale_normal,zoom_scale_page_layout_view,zoom_scale_sheet_layout_view Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc. + #' @param ... additional arguments #' @return The `wbWorksheetObject`, invisibly set_sheetview = function( - colorId = NULL, - defaultGridColor = NULL, - rightToLeft = NULL, - showFormulas = NULL, - showGridLines = NULL, - showOutlineSymbols = NULL, - showRowColHeaders = NULL, - showRuler = NULL, - showWhiteSpace = NULL, - showZeros = NULL, - tabSelected = NULL, - topLeftCell = NULL, - view = NULL, - windowProtection = NULL, - workbookViewId = NULL, - zoomScale = NULL, - zoomScaleNormal = NULL, - zoomScalePageLayoutView = NULL, - zoomScaleSheetLayoutView = NULL + color_id = NULL, + default_grid_color = NULL, + right_to_left = NULL, + show_formulas = NULL, + show_grid_lines = NULL, + show_outline_symbols = NULL, + show_row_col_headers = NULL, + show_ruler = NULL, + show_white_space = NULL, + show_zeros = NULL, + tab_selected = NULL, + top_left_cell = NULL, + view = NULL, + window_protection = NULL, + workbook_view_id = NULL, + zoom_scale = NULL, + zoom_scale_normal = NULL, + zoom_scale_page_layout_view = NULL, + zoom_scale_sheet_layout_view = NULL, + ... ) { + standardize(...) + # all zoom scales must be in the range of 10 - 400 # get existing sheetView @@ -727,25 +734,25 @@ wbWorksheet <- R6::R6Class( sheetView <- xml_attr_mod( sheetView, xml_attributes = c( - colorId = as_xml_attr(colorId), - defaultGridColor = as_xml_attr(defaultGridColor), - rightToLeft = as_xml_attr(rightToLeft), - showFormulas = as_xml_attr(showFormulas), - showGridLines = as_xml_attr(showGridLines), - showOutlineSymbols = as_xml_attr(showOutlineSymbols), - showRowColHeaders = as_xml_attr(showRowColHeaders), - showRuler = as_xml_attr(showRuler), - showWhiteSpace = as_xml_attr(showWhiteSpace), - showZeros = as_xml_attr(showZeros), - tabSelected = as_xml_attr(tabSelected), - topLeftCell = as_xml_attr(topLeftCell), + colorId = as_xml_attr(color_id), + defaultGridColor = as_xml_attr(default_grid_color), + rightToLeft = as_xml_attr(right_to_left), + showFormulas = as_xml_attr(show_formulas), + showGridLines = as_xml_attr(show_grid_lines), + showOutlineSymbols = as_xml_attr(show_outline_symbols), + showRowColHeaders = as_xml_attr(show_row_col_headers), + showRuler = as_xml_attr(show_ruler), + showWhiteSpace = as_xml_attr(show_white_space), + showZeros = as_xml_attr(show_zeros), + tabSelected = as_xml_attr(tab_selected), + topLeftCell = as_xml_attr(top_left_cell), view = as_xml_attr(view), - windowProtection = as_xml_attr(windowProtection), - workbookViewId = as_xml_attr(workbookViewId), - zoomScale = as_xml_attr(zoomScale), - zoomScaleNormal = as_xml_attr(zoomScaleNormal), - zoomScalePageLayoutView = as_xml_attr(zoomScalePageLayoutView), - zoomScaleSheetLayoutView = as_xml_attr(zoomScaleSheetLayoutView) + windowProtection = as_xml_attr(window_protection), + workbookViewId = as_xml_attr(workbook_view_id), + zoomScale = as_xml_attr(zoom_scale), + zoomScaleNormal = as_xml_attr(zoom_scale_normal), + zoomScalePageLayoutView = as_xml_attr(zoom_scale_page_layout_view), + zoomScaleSheetLayoutView = as_xml_attr(zoom_scale_sheet_layout_view) ), remove_empty_attr = FALSE ) diff --git a/R/converters.R b/R/converters.R index fb746757d..0ca7e2acc 100644 --- a/R/converters.R +++ b/R/converters.R @@ -59,7 +59,8 @@ col2int <- function(x) { #' # "B1" #' get_cell_refs(data.frame(1:3, 2:4)) #' # "B1" "C2" "D3" -#' @export +#' @keywords internal +#' @noRd get_cell_refs <- function(cellCoords) { assert_class(cellCoords, "data.frame") stopifnot(ncol(cellCoords) == 2L) diff --git a/R/dates.R b/R/dates.R index 84f77c7f3..36126b5e8 100644 --- a/R/dates.R +++ b/R/dates.R @@ -106,7 +106,8 @@ convert_hms <- function(x) { #' #' get_date_origin(wb_workbook()) #' get_date_origin(wb_workbook(), origin = TRUE) -#' @export +#' @keywords internal +#' @noRd get_date_origin <- function(xlsxFile, origin = FALSE) { # TODO: allow using a workbook? diff --git a/R/expect-wrapper.R b/R/expect-wrapper.R index 5621e78dd..58080c525 100644 --- a/R/expect-wrapper.R +++ b/R/expect-wrapper.R @@ -199,7 +199,7 @@ expect_pseudo_wrapper <- function( method_args <- names(method_forms) fun_args <- names(fun_forms) - ignore <- "xlsxFile" + ignore <- "xlsx_file" # remove ignores from fun m <- match(ignore, fun_args, 0L) diff --git a/R/get-named-regions.R b/R/get-named-regions.R index 21fdb9521..dd2289b97 100644 --- a/R/get-named-regions.R +++ b/R/get-named-regions.R @@ -59,38 +59,6 @@ wb_get_named_regions_tab <- function(wb) { #' Workbook object #' @param x An xlsx file or Workbook object #' @param tables add tables too -#' @seealso [wb_add_named_region()] [wb_remove_named_region()] -#' @examples -#' ## create named regions -#' wb <- wb_workbook() -#' wb$add_worksheet("Sheet 1") -#' -#' ## specify region -#' wb$add_data(sheet = 1, x = iris, startCol = 1, startRow = 1) -#' wb$add_named_region( -#' sheet = 1, -#' name = "iris", -#' rows = seq_len(nrow(iris) + 1), -#' cols = seq_along(iris) -#' ) -#' -#' -#' ## using write_data 'name' argument to create a named region -#' wb$add_data(sheet = 1, x = iris, name = "iris2", startCol = 10) -#' -#' out_file <- temp_xlsx() -#' wb$save(out_file, overwrite = TRUE) -#' -#' ## see named regions -#' wb_get_named_regions(wb) ## From Workbook object -#' wb_get_named_regions(out_file) ## From xlsx file -#' -#' ## read named regions -#' df <- read_xlsx(wb, namedRegion = "iris") -#' head(df) -#' -#' df <- read_xlsx(out_file, namedRegion = "iris2") -#' head(df) #' @name named_region NULL diff --git a/R/pugixml.R b/R/pugixml.R index 560b01f15..6df63a053 100644 --- a/R/pugixml.R +++ b/R/pugixml.R @@ -265,7 +265,8 @@ as_xml <- function(x, ...) { #' @param fl file name with full path #' @param escapes bool if characters like "&" should be escaped. The default is #' no escape, assuming that xml to export is already valid. -#' @export +#' @keywords internal +#' @noRd # TODO needs a unit test write_file <- function(head = "", body = "", tail = "", fl = "", escapes = FALSE) { if (getOption("openxlsx2.force_utf8_encoding", default = FALSE)) { diff --git a/R/readWorkbook.R b/R/readWorkbook.R index 2c85a91b4..e87e4d88f 100644 --- a/R/readWorkbook.R +++ b/R/readWorkbook.R @@ -1,15 +1,15 @@ #' @name read_xlsx #' @title Read from an Excel file or Workbook object #' @description Read data from an Excel file or Workbook object into a data.frame -#' @param xlsxFile An xlsx file, Workbook object or URL to xlsx file. +#' @param xlsx_file An xlsx file, Workbook object or URL to xlsx file. #' @param sheet The name or index of the sheet to read data from. -#' @param startRow first row to begin looking for data. -#' @param startCol first column to begin looking for data. -#' @param colNames If `TRUE`, the first row of data will be used as column names. -#' @param skipEmptyRows If `TRUE`, empty rows are skipped else empty rows after the first row containing data +#' @param start_row first row to begin looking for data. +#' @param start_col first column to begin looking for data. +#' @param col_names If `TRUE`, the first row of data will be used as column names. +#' @param skip_empty_rows If `TRUE`, empty rows are skipped else empty rows after the first row containing data #' will return a row of NAs. -#' @param rowNames If `TRUE`, first column of data will be used as row names. -#' @param detectDates If `TRUE`, attempt to recognize dates and perform conversion. +#' @param row_names If `TRUE`, first column of data will be used as row names. +#' @param detect_dates If `TRUE`, attempt to recognize dates and perform conversion. #' @param cols A numeric vector specifying which columns in the Excel file to read. #' If NULL, all columns are read. #' @param rows A numeric vector specifying which rows in the Excel file to read. @@ -17,11 +17,11 @@ #' @param check.names logical. If TRUE then the names of the variables in the data frame #' are checked to ensure that they are syntactically valid variable names #' @param sep.names (unimplemented) One character which substitutes blanks in column names. By default, "." -#' @param namedRegion A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored. +#' @param named_region A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored. #' @param na.strings A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA. #' @param na.numbers A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA. -#' @param fillMergedCells If TRUE, the value in a merged cell is given to all cells within the merge. -#' @param skipEmptyCols If `TRUE`, empty columns are skipped. +#' @param fill_merged_cells If TRUE, the value in a merged cell is given to all cells within the merge. +#' @param skip_empty_cols If `TRUE`, empty columns are skipped. #' @param ... additional arguments passed to `wb_to_df()` #' @seealso [wb_get_named_regions()] [wb_to_df()] #' @details Formulae written using write_formula to a Workbook object will not get picked up by read_xlsx(). @@ -34,23 +34,23 @@ #' read_xlsx(xlsxFile = xlsxFile) #' @export read_xlsx <- function( - xlsxFile, + xlsx_file, sheet, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, - rows = NULL, - cols = NULL, - detectDates = TRUE, - namedRegion, - na.strings = "#N/A", - na.numbers = NA, - check.names = FALSE, - sep.names = ".", - fillMergedCells = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, + rows = NULL, + cols = NULL, + detect_dates = TRUE, + named_region, + na.strings = "#N/A", + na.numbers = NA, + check.names = FALSE, + sep.names = ".", + fill_merged_cells = FALSE, ... ) { @@ -60,21 +60,21 @@ read_xlsx <- function( sheet <- substitute() wb_to_df( - xlsxFile, - sheet = sheet, - startRow = startRow, - startCol = startCol, - rowNames = rowNames, - colNames = colNames, - skipEmptyRows = skipEmptyRows, - skipEmptyCols = skipEmptyCols, - rows = rows, - cols = cols, - detectDates = detectDates, - named_region = namedRegion, - na.strings = na.strings, - na.numbers = na.numbers, - fillMergedCells = fillMergedCells, + xlsx_file, + sheet = sheet, + start_row = start_row, + start_col = start_col, + row_names = row_names, + col_names = col_names, + skip_empty_rows = skip_empty_rows, + skip_empty_cols = skip_empty_cols, + rows = rows, + cols = cols, + detect_dates = detect_dates, + named_region = named_region, + na.strings = na.strings, + na.numbers = na.numbers, + fill_merged_cells = fill_merged_cells, ... ) } @@ -96,20 +96,20 @@ read_xlsx <- function( #' xlsxFile <- system.file("extdata", "openxlsx2_example.xlsx", package = "openxlsx2") #' df1 <- wb_read(xlsxFile = xlsxFile, sheet = 1, rows = c(1, 3, 5), cols = 1:3) wb_read <- function( - xlsxFile, - sheet = 1, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, - rows = NULL, - cols = NULL, - detectDates = TRUE, - namedRegion, - na.strings = "NA", - na.numbers = NA, + xlsx_file, + sheet = 1, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, + rows = NULL, + cols = NULL, + detect_dates = TRUE, + named_region, + na.strings = "NA", + na.numbers = NA, ... ) { @@ -119,20 +119,20 @@ wb_read <- function( sheet <- substitute() wb_to_df( - xlsxFile = xlsxFile, - sheet = sheet, - startRow = startRow, - startCol = startCol, - rowNames = rowNames, - colNames = colNames, - skipEmptyRows = skipEmptyRows, - skipEmptyCols = skipEmptyCols, - rows = rows, - cols = cols, - detectDates = detectDates, - named_region = namedRegion, - na.strings = na.strings, - na.numbers = na.numbers, + xlsx_file = xlsx_file, + sheet = sheet, + start_row = start_row, + start_col = start_col, + row_names = row_names, + col_names = col_names, + skip_empty_rows = skip_empty_rows, + skip_empty_cols = skip_empty_cols, + rows = rows, + cols = cols, + detect_dates = detect_dates, + named_region = named_region, + na.strings = na.strings, + na.numbers = na.numbers, ... ) diff --git a/R/standardize.R b/R/standardize.R new file mode 100644 index 000000000..ebb39379f --- /dev/null +++ b/R/standardize.R @@ -0,0 +1,93 @@ + +#' takes colour and returns color +#' @param ... ... +#' @returns void. assigns an object in the parent frame +#' @keywords internal +#' @noRd +standardize_color_names <- function(..., return = FALSE) { + + # since R 4.1.0: ...names() + args <- list(...) + if (return) { + args <- args[[1]] + } + got <- names(args) + # can be Color or color + got_color <- which(grepl("colour", tolower(got))) + + if (length(got_color)) { + for (got_col in got_color) { + color <- got[got_col] + name_color <- stringi::stri_replace_all_fixed(color, "olour", "olor") + + if (return) { + names(args)[got_col] <- name_color + } else { + # since R 3.5.0: ...elt(got_col) + value_color <- args[[got_col]] + assign(name_color, value_color, parent.frame()) + } + } + } + + if (return) args +} + +#' takes camelCase and returns camel_case +#' @param ... ... +#' @returns void. assigns an object in the parent frame +#' @keywords internal +#' @noRd +standardize_case_names <- function(..., return = FALSE) { + + # since R 4.1.0: ...names() + args <- list(...) + if (return) { + args <- args[[1]] + } + got <- names(args) + + regex <- "(\\G(?!^)|\\b[a-zA-Z][a-z]*)([A-Z][a-z]*|\\d+)" + + got_camel_cases <- which(grepl(regex, got, perl = TRUE)) + + if (length(got_camel_cases)) { + for (got_camel_case in got_camel_cases) { + camel_case <- got[got_camel_case] + name_camel_case <- gsub( + pattern = regex, + replacement = "\\L\\1_\\2", + x = camel_case, + perl = TRUE + ) + # since R 3.5.0: ...elt(got_col) + if (return) { + names(args)[got_camel_case] <- name_camel_case + } else { + value_camel_calse <- args[[got_camel_case]] + assign(name_camel_case, value_camel_calse, parent.frame()) + } + } + } + + if (return) args + +} + +#' takes camelCase and colour returns camel_case and color +#' @param ... ... +#' @returns void. assigns an object in the parent frame +#' @keywords internal +#' @noRd +standardize <- function(...) { + + nms <- list(...) + + rtns <- standardize_color_names(nms, return = TRUE) + rtns <- standardize_case_names(rtns, return = TRUE) + + nms <- names(rtns) + for (i in seq_along(nms)) { + assign(nms[[i]], rtns[[i]], parent.frame()) + } +} diff --git a/R/wb_functions.R b/R/wb_functions.R index 97fc9833a..4099fc96a 100644 --- a/R/wb_functions.R +++ b/R/wb_functions.R @@ -83,7 +83,8 @@ dataframe_to_dims <- function(df) { #' function to estimate the column type. #' 0 = character, 1 = numeric, 2 = date. #' @param tt dataframe produced by wb_to_df() -#' @export +#' @keywords internal +#' @noRd guess_col_type <- function(tt) { # all columns are character @@ -269,28 +270,29 @@ style_is_hms <- function(cellXfs, numfmt_date) { #' Simple function to create a dataframe from a workbook. Simple as in simply #' written down. #' -#' @param xlsxFile An xlsx file, Workbook object or URL to xlsx file. +#' @param xlsx_file An xlsx file, Workbook object or URL to xlsx file. #' @param sheet Either sheet name or index. When missing the first sheet in the workbook is selected. -#' @param colNames If TRUE, the first row of data will be used as column names. -#' @param rowNames If TRUE, the first col of data will be used as row names. +#' @param col_names If TRUE, the first row of data will be used as column names. +#' @param row_names If TRUE, the first col of data will be used as row names. #' @param dims Character string of type "A1:B2" as optional dimensions to be imported. -#' @param detectDates If TRUE, attempt to recognize dates and perform conversion. -#' @param showFormula If TRUE, the underlying Excel formulas are shown. +#' @param detect_dates If TRUE, attempt to recognize dates and perform conversion. +#' @param show_formula If TRUE, the underlying Excel formulas are shown. #' @param convert If TRUE, a conversion to dates and numerics is attempted. -#' @param skipEmptyCols If TRUE, empty columns are skipped. -#' @param skipEmptyRows If TRUE, empty rows are skipped. -#' @param skipHiddenCols If TRUE, hidden columns are skipped. -#' @param skipHiddenRows If TRUE, hidden rows are skipped. -#' @param startRow first row to begin looking for data. -#' @param startCol first column to begin looking for data. +#' @param skip_empty_cols If TRUE, empty columns are skipped. +#' @param skip_empty_rows If TRUE, empty rows are skipped. +#' @param skip_hidden_cols If TRUE, hidden columns are skipped. +#' @param skip_hidden_rows If TRUE, hidden rows are skipped. +#' @param start_row first row to begin looking for data. +#' @param start_col first column to begin looking for data. #' @param rows A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read. #' @param cols A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read. #' @param named_region Character string with a named_region (defined name or table). If no sheet is selected, the first appearance will be selected. #' @param types A named numeric indicating, the type of the data. 0: character, 1: numeric, 2: date, 3: posixt, 4:logical. Names must match the returned data #' @param na.strings A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA. #' @param na.numbers A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA. -#' @param fillMergedCells If TRUE, the value in a merged cell is given to all cells within the merge. +#' @param fill_merged_cells If TRUE, the value in a merged cell is given to all cells within the merge. #' @param keep_attributes If TRUE additional attributes are returned. (These are used internally to define a cell type.) +#' @param ... additional arguments #' @details #' Depending if the R package `hms` is loaded, `wb_to_df()` returns `hms` variables or string variables in the `hh:mm:ss` format. #' @examples @@ -355,43 +357,44 @@ style_is_hms <- function(cellXfs, numfmt_date) { #' #' @export wb_to_df <- function( - xlsxFile, + xlsx_file, sheet, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, - skipHiddenRows = FALSE, - skipHiddenCols = FALSE, - rows = NULL, - cols = NULL, - detectDates = TRUE, - na.strings = "#N/A", - na.numbers = NA, - fillMergedCells = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, + skip_hidden_rows = FALSE, + skip_hidden_cols = FALSE, + rows = NULL, + cols = NULL, + detect_dates = TRUE, + na.strings = "#N/A", + na.numbers = NA, + fill_merged_cells = FALSE, dims, - showFormula = FALSE, - convert = TRUE, + show_formula = FALSE, + convert = TRUE, types, named_region, - keep_attributes = FALSE + keep_attributes = FALSE, + ... ) { - # .mc <- match.call() # not (yet) used? + standardize_case_names(...) if (!is.null(cols)) cols <- col2int(cols) - if (inherits(xlsxFile, "wbWorkbook")) { - wb <- xlsxFile + if (inherits(xlsx_file, "wbWorkbook")) { + wb <- xlsx_file } else { # passes missing further on if (missing(sheet)) sheet <- substitute() # possible false positive on current lintr runs - wb <- wb_load(xlsxFile, sheet = sheet, data_only = TRUE) # nolint + wb <- wb_load(xlsx_file, sheet = sheet, data_only = TRUE) # nolint } if (!missing(named_region)) { @@ -478,13 +481,13 @@ wb_to_df <- function( maxRow <- max(as.numeric(keep_rows)) maxCol <- max(col2int(keep_cols)) - if (startRow > 1) { - keep_rows <- as.character(seq(startRow, maxRow)) - if (startRow <= maxRow) { + if (start_row > 1) { + keep_rows <- as.character(seq(start_row, maxRow)) + if (start_row <= maxRow) { z <- z[rownames(z) %in% keep_rows, , drop = FALSE] tt <- tt[rownames(tt) %in% keep_rows, , drop = FALSE] } else { - keep_rows <- as.character(startRow) + keep_rows <- as.character(start_row) z <- z[keep_rows, , drop = FALSE] tt <- tt[keep_rows, , drop = FALSE] @@ -508,8 +511,8 @@ wb_to_df <- function( } } - if (!is.null(startCol)) { - keep_cols <- int2col(seq(col2int(startCol), maxCol)) + if (!is.null(start_col)) { + keep_cols <- int2col(seq(col2int(start_col), maxCol)) if (!all(keep_cols %in% colnames(z))) { keep_col <- keep_cols[!keep_cols %in% colnames(z)] @@ -562,7 +565,7 @@ wb_to_df <- function( cc$val[sel] <- replaceXMLEntities(cc$v[sel]) cc$typ[sel] <- "s" } - if (showFormula) { + if (show_formula) { sel <- cc$f != "" cc$val[sel] <- replaceXMLEntities(cc$f[sel]) cc$typ[sel] <- "s" @@ -607,7 +610,7 @@ wb_to_df <- function( # dates if (!is.null(cc$c_s)) { # if a cell is t="s" the content is a sst and not da date - if (detectDates && missing(types)) { + if (detect_dates && missing(types)) { cc$is_string <- FALSE if (!is.null(cc$c_t)) cc$is_string <- cc$c_t %in% c("s", "str", "b", "inlineStr") @@ -663,7 +666,7 @@ wb_to_df <- function( # backward compatible option. get the mergedCells dimension and fill it with # the value of the first cell in the range. do the same for tt. - if (fillMergedCells) { + if (fill_merged_cells) { mc <- wb$worksheets[[sheet]]$mergeCells if (length(mc)) { @@ -681,14 +684,14 @@ wb_to_df <- function( # TODO there probably is a better way in not reducing cc above, so # that we do not have to go through large xlsx files multiple times z_fill <- wb_to_df( - xlsxFile = wb, - sheet = sheet, - dims = filler, - na.strings = na.strings, - convert = FALSE, - colNames = FALSE, - detectDates = detectDates, - showFormula = showFormula, + xlsx_file = wb, + sheet = sheet, + dims = filler, + na.strings = na.strings, + convert = FALSE, + col_names = FALSE, + detect_dates = detect_dates, + show_formula = show_formula, keep_attributes = TRUE ) @@ -704,7 +707,7 @@ wb_to_df <- function( # the following two skip hidden columns and row and need a valid keep_rows and # keep_cols length. - if (skipHiddenRows) { + if (skip_hidden_rows) { sel <- row_attr$hidden == "1" | row_attr$hidden == "true" if (any(sel)) { hide <- !keep_rows %in% row_attr$r[sel] @@ -714,7 +717,7 @@ wb_to_df <- function( } } - if (skipHiddenCols) { + if (skip_hidden_cols) { col_attr <- wb$worksheets[[sheet]]$unfold_cols() sel <- col_attr$hidden == "1" | col_attr$hidden == "true" if (any(sel)) { @@ -726,14 +729,14 @@ wb_to_df <- function( } # is.na needs convert - if (skipEmptyRows) { + if (skip_empty_rows) { empty <- vapply(seq_len(nrow(z)), function(x) all(is.na(z[x, ])), NA) z <- z[!empty, , drop = FALSE] tt <- tt[!empty, , drop = FALSE] } - if (skipEmptyCols) { + if (skip_empty_cols) { empty <- vapply(z, function(x) all(is.na(x)), NA) @@ -750,7 +753,7 @@ wb_to_df <- function( names(xlsx_cols_names) <- xlsx_cols_names # if colNames, then change tt too - if (colNames) { + if (col_names) { # select first row as colnames, but do not yet assign. it might contain # missing values and if assigned, convert below might break with unambiguous # names. @@ -762,7 +765,7 @@ wb_to_df <- function( tt <- tt[-1, , drop = FALSE] } - if (rowNames) { + if (row_names) { rownames(z) <- z[, 1] rownames(tt) <- z[, 1] xlsx_cols_names <- xlsx_cols_names[-1] @@ -811,7 +814,7 @@ wb_to_df <- function( } } - if (colNames) { + if (col_names) { names(z) <- xlsx_cols_names names(tt) <- xlsx_cols_names } @@ -900,7 +903,7 @@ wb_set_active_sheet <- function(wb, sheet) { # active tab requires a c index assert_workbook(wb) sheet <- wb_validate_sheet(wb, sheet) - wb$clone()$set_bookview(activeTab = sheet - 1L) + wb$clone()$set_bookview(active_tab = sheet - 1L) } #' @name select_active_sheet @@ -937,58 +940,6 @@ wb_set_selected <- function(wb, sheet) { wb } -#' Add mschart object to an existing workbook -#' @param wb a workbook -#' @param sheet the sheet on which the graph will appear -#' @param dims the dimensions where the sheet will appear -#' @param graph mschart object -#' @param colOffset,rowOffset startCol and startRow -#' @examples -#' if (requireNamespace("mschart")) { -#' require(mschart) -#' -#' ## Add mschart to worksheet (adds data and chart) -#' scatter <- ms_scatterchart(data = iris, x = "Sepal.Length", y = "Sepal.Width", group = "Species") -#' scatter <- chart_settings(scatter, scatterstyle = "marker") -#' -#' wb <- wb_workbook() %>% -#' wb_add_worksheet() %>% -#' wb_add_mschart(dims = "F4:L20", graph = scatter) -#' -#' ## Add mschart to worksheet and use available data -#' wb <- wb_workbook() %>% -#' wb_add_worksheet() %>% -#' wb_add_data(x = mtcars, dims = "B2") -#' -#' # create wb_data object -#' dat <- wb_data(wb, 1, dims = "B2:E6") -#' -#' # call ms_scatterplot -#' data_plot <- ms_scatterchart( -#' data = dat, -#' x = "mpg", -#' y = c("disp", "hp"), -#' labels = c("disp", "hp") -#' ) -#' -#' # add the scatterplot to the data -#' wb <- wb %>% -#' wb_add_mschart(dims = "F4:L20", graph = data_plot) -#' } -#' @seealso [wb_data()] -#' @export -wb_add_mschart <- function( - wb, - sheet = current_sheet(), - dims = NULL, - graph, - colOffset = 0, - rowOffset = 0 -) { - assert_workbook(wb) - wb$clone()$add_mschart(sheet = sheet, dims = dims, graph = graph, colOffset = colOffset, rowOffset = rowOffset) -} - #' provide wb_data object as mschart input #' @param wb a workbook #' @param sheet a sheet in the workbook either name or index diff --git a/R/wb_load.R b/R/wb_load.R index a81289e0c..3ac4019a0 100644 --- a/R/wb_load.R +++ b/R/wb_load.R @@ -1,7 +1,7 @@ #' @name wb_load #' @title Load an existing .xlsx file #' @param file A path to an existing .xlsx or .xlsm file -#' @param xlsxFile alias for file +#' @param xlsx_file alias for file #' @param sheet optional sheet parameter. if this is applied, only the selected #' sheet will be loaded. #' @param data_only mode to import if only a data frame should be returned. This @@ -12,6 +12,7 @@ #' chain will be created upon the next time the worksheet is loaded in #' spreadsheet software. Keeping it, might only speed loading time in said #' software. +#' @param ... additional arguments #' @description wb_load returns a workbook object conserving styles and #' formatting of the original .xlsx file. #' @details A warning is displayed if an xml namespace for main is found in the @@ -32,13 +33,16 @@ #' wb$add_worksheet("A new worksheet") wb_load <- function( file, - xlsxFile = NULL, + xlsx_file = NULL, sheet, data_only = FALSE, - calc_chain = FALSE + calc_chain = FALSE, + ... ) { - file <- xlsxFile %||% file + standardize_case_names(...) + + file <- xlsx_file %||% file file <- getFile(file) if (!file.exists(file)) { diff --git a/R/wb_styles.R b/R/wb_styles.R index 0e9d2d63a..22e54a82e 100644 --- a/R/wb_styles.R +++ b/R/wb_styles.R @@ -79,8 +79,8 @@ import_styles <- function(x) { #' @description #' Border styles can any of the following: "thin", "thick", "slantDashDot", "none", "mediumDashed", "mediumDashDot", "medium", "hair", "double", "dotted", "dashed", "dashedDotDot", "dashDot" #' Border colors are of the following type: c(rgb="FF000000") -#' @param diagonalDown x -#' @param diagonalUp x +#' @param diagonal_down x +#' @param diagonal_up x #' @param outline x #' @param bottom X #' @param bottom_color X @@ -100,8 +100,8 @@ import_styles <- function(x) { #' #' @export create_border <- function( - diagonalDown = "", - diagonalUp = "", + diagonal_down = "", + diagonal_up = "", outline = "", bottom = NULL, bottom_color = NULL, @@ -120,7 +120,7 @@ create_border <- function( ... ) { - standardize_color_names(...) + standardize(...) if (!is.null(left_color)) left_color <- xml_node_create("color", xml_attributes = left_color) if (!is.null(right_color)) right_color <- xml_node_create("color", xml_attributes = right_color) @@ -154,8 +154,8 @@ create_border <- function( right = right, top = top, bottom = bottom, - diagonalDown = diagonalDown, - diagonalUp = diagonalUp, + diagonalDown = diagonal_down, + diagonalUp = diagonal_up, diagonal = diagonal, vertical = vertical, horizontal = horizontal, @@ -370,23 +370,23 @@ create_fill <- function( # TODO can be further generalized with additional xf attributes and children #' create_cell_style -#' @param borderId dummy -#' @param fillId dummy -#' @param fontId dummy -#' @param numFmtId a numFmt ID for a builtin style -#' @param pivotButton dummy -#' @param quotePrefix dummy -#' @param xfId dummy +#' @param border_id dummy +#' @param fill_id dummy +#' @param font_id dummy +#' @param num_fmt_id a numFmt ID for a builtin style +#' @param pivot_button dummy +#' @param quote_prefix dummy +#' @param xf_id dummy #' @param horizontal dummy #' @param indent dummy -#' @param justifyLastLine dummy -#' @param readingOrder dummy -#' @param relativeIndent dummy -#' @param shrinkToFit dummy -#' @param textRotation dummy +#' @param justify_last_line dummy +#' @param reading_order dummy +#' @param relative_indent dummy +#' @param shrink_to_fit dummy +#' @param text_rotation dummy #' @param vertical dummy -#' @param wrapText dummy -#' @param extLst dummy +#' @param wrap_text dummy +#' @param ext_lst dummy #' @param hidden dummy #' @param locked dummy #' @param horizontal alignment can be "", "center", "right" @@ -426,51 +426,52 @@ create_fill <- function( #' | "49" | "@" | #' @export create_cell_style <- function( - borderId = "", - fillId = "", - fontId = "", - numFmtId = "", - pivotButton = "", - quotePrefix = "", - xfId = "", - horizontal = "", - indent = "", - justifyLastLine = "", - readingOrder = "", - relativeIndent = "", - shrinkToFit = "", - textRotation = "", - vertical = "", - wrapText = "", - extLst = "", - hidden = "", - locked = "", + border_id = "", + fill_id = "", + font_id = "", + num_fmt_id = "", + pivot_button = "", + quote_prefix = "", + xf_id = "", + horizontal = "", + indent = "", + justify_last_line = "", + reading_order = "", + relative_indent = "", + shrink_to_fit = "", + text_rotation = "", + vertical = "", + wrap_text = "", + ext_lst = "", + hidden = "", + locked = "", ... ) { - n <- length(numFmtId) + n <- length(num_fmt_id) args <- list(...) + standardize_case_names(...) is_cell_style_xf <- isTRUE(args$is_cell_style_xf) applyAlignment <- "" - if (any(horizontal != "") || any(textRotation != "") || any(vertical != "")) applyAlignment <- "1" + if (any(horizontal != "") || any(text_rotation != "") || any(vertical != "")) applyAlignment <- "1" if (is_cell_style_xf) applyAlignment <- "0" applyBorder <- "" - if (any(borderId != "")) applyBorder <- "1" - if (is_cell_style_xf && isTRUE(borderId == "")) applyBorder <- "0" + if (any(border_id != "")) applyBorder <- "1" + if (is_cell_style_xf && isTRUE(border_id == "")) applyBorder <- "0" applyFill <- "" - if (any(fillId != "")) applyFill <- "1" - if (is_cell_style_xf && isTRUE(fillId == "")) applyFill <- "0" + if (any(fill_id != "")) applyFill <- "1" + if (is_cell_style_xf && isTRUE(fill_id == "")) applyFill <- "0" applyFont <- "" - if (any(fontId != "")) applyFont <- "1" - if (is_cell_style_xf && isTRUE(fontId > "1")) applyFont <- "0" + if (any(font_id != "")) applyFont <- "1" + if (is_cell_style_xf && isTRUE(font_id > "1")) applyFont <- "0" applyNumberFormat <- "" - if (any(numFmtId != "")) applyNumberFormat <- "1" + if (any(num_fmt_id != "")) applyNumberFormat <- "1" if (is_cell_style_xf) applyNumberFormat <- "0" applyProtection <- "" @@ -485,23 +486,23 @@ create_cell_style <- function( applyFont = rep(applyFont, n), applyNumberFormat = rep(applyNumberFormat, n), applyProtection = rep(applyProtection, n), - borderId = rep(as_xml_attr(borderId), n), - fillId = rep(as_xml_attr(fillId), n), - fontId = rep(as_xml_attr(fontId), n), - numFmtId = as_xml_attr(numFmtId), - pivotButton = rep(as_xml_attr(pivotButton), n), - quotePrefix = rep(as_xml_attr(quotePrefix), n), - xfId = rep(as_xml_attr(xfId), n), + borderId = rep(as_xml_attr(border_id), n), + fillId = rep(as_xml_attr(fill_id), n), + fontId = rep(as_xml_attr(font_id), n), + numFmtId = as_xml_attr(num_fmt_id), + pivotButton = rep(as_xml_attr(pivot_button), n), + quotePrefix = rep(as_xml_attr(quote_prefix), n), + xfId = rep(as_xml_attr(xf_id), n), horizontal = rep(as_xml_attr(horizontal), n), indent = rep(as_xml_attr(indent), n), - justifyLastLine = rep(as_xml_attr(justifyLastLine), n), - readingOrder = rep(as_xml_attr(readingOrder), n), - relativeIndent = rep(as_xml_attr(relativeIndent), n), - shrinkToFit = rep(as_xml_attr(shrinkToFit), n), - textRotation = rep(as_xml_attr(textRotation), n), + justifyLastLine = rep(as_xml_attr(justify_last_line), n), + readingOrder = rep(as_xml_attr(reading_order), n), + relativeIndent = rep(as_xml_attr(relative_indent), n), + shrinkToFit = rep(as_xml_attr(shrink_to_fit), n), + textRotation = rep(as_xml_attr(text_rotation), n), vertical = rep(as_xml_attr(vertical), n), - wrapText = rep(as_xml_attr(wrapText), n), - extLst = rep(extLst, n), + wrapText = rep(as_xml_attr(wrap_text), n), + extLst = rep(ext_lst, n), hidden = rep(as_xml_attr(hidden), n), locked = rep(as_xml_attr(locked), n), stringsAsFactors = FALSE @@ -661,13 +662,13 @@ get_cell_styles <- function(wb, sheet, cell) { #' (Defaults to black) #' @param font_size Font size. A numeric greater than 0. #' If fontSize is NULL, the workbook base font size is used. (Defaults to 11) -#' @param numFmt Cell formatting. Some custom openxml format +#' @param num_fmt Cell formatting. Some custom openxml format #' @param border NULL or TRUE #' @param border_color "black" #' @param border_style "thin" -#' @param bgFill Cell background fill color. -#' @param fgColor Cell foreground fill color. -#' @param gradientFill An xml string beginning with `` ... +#' @param bg_fill Cell background fill color. +#' @param fg_color Cell foreground fill color. +#' @param gradient_fill An xml string beginning with `` ... #' @param text_bold bold #' @param text_strike strikeout #' @param text_italic italic @@ -701,13 +702,13 @@ create_dxfs_style <- function( font_name = NULL, font_size = NULL, font_color = NULL, - numFmt = NULL, + num_fmt = NULL, border = NULL, border_color = wb_color(getOption("openxlsx2.borderColor", "black")), border_style = getOption("openxlsx2.borderStyle", "thin"), - bgFill = NULL, - fgColor = NULL, - gradientFill = NULL, + bg_fill = NULL, + fg_color = NULL, + gradient_fill = NULL, text_bold = NULL, text_strike = NULL, text_italic = NULL, @@ -715,7 +716,7 @@ create_dxfs_style <- function( ... ) { - standardize_color_names(...) + standardize(...) args <- list(...) nams <- names(args) @@ -728,7 +729,7 @@ create_dxfs_style <- function( if (is.null(text_underline)) text_underline <- "" # found numFmtId=3 in MS365 xml not sure if this should be increased - if (!is.null(numFmt)) numFmt <- create_numfmt(3, numFmt) + if (!is.null(num_fmt)) num_fmt <- create_numfmt(3, num_fmt) font <- create_font( color = font_color, name = font_name, @@ -738,20 +739,20 @@ create_dxfs_style <- function( family = "", scheme = "" ) - if ("patternType" %in% nams) { - patternType <- args$patternType + if (exists("pattern_type")) { + pattern_type <- args$patternType } else { - patternType <- "solid" + pattern_type <- "solid" } - if (!is.null(bgFill) && !all(bgFill == "") || !is.null(gradientFill)) { - if (is.null(gradientFill)) { + if (!is.null(bg_fill) && !all(bg_fill == "") || !is.null(gradient_fill)) { + if (is.null(gradient_fill)) { # gradientFill is an xml string - gradientFill <- "" + gradient_fill <- "" } else { - patternType <- "" + pattern_type <- "" } - fill <- create_fill(patternType = patternType, bgColor = bgFill, fgColor = fgColor, gradientFill = gradientFill) + fill <- create_fill(patternType = pattern_type, bgColor = bg_fill, fgColor = fg_color, gradientFill = gradient_fill) } else { fill <- NULL } @@ -783,7 +784,7 @@ create_dxfs_style <- function( "dxf", xml_children = c( font, - numFmt, + num_fmt, fill, border ) @@ -793,114 +794,118 @@ create_dxfs_style <- function( #' create tableStyle #' @param name name -#' @param wholeTable wholeTable -#' @param headerRow headerRow -#' @param totalRow totalRow -#' @param firstColumn firstColumn -#' @param lastColumn lastColumn -#' @param firstRowStripe firstRowStripe -#' @param secondRowStripe secondRowStripe -#' @param firstColumnStripe firstColumnStripe -#' @param secondColumnStripe secondColumnStripe -#' @param firstHeaderCell firstHeaderCell -#' @param lastHeaderCell lastHeaderCell -#' @param firstTotalCell firstTotalCell -#' @param lastTotalCell lastTotalCell +#' @param whole_table wholeTable +#' @param header_row headerRow +#' @param total_row totalRow +#' @param first_column firstColumn +#' @param last_column lastColumn +#' @param first_row_stripe firstRowStripe +#' @param second_row_stripe secondRowStripe +#' @param first_column_stripe firstColumnStripe +#' @param second_column_stripe secondColumnStripe +#' @param first_header_cell firstHeaderCell +#' @param last_header_cell lastHeaderCell +#' @param first_total_cell firstTotalCell +#' @param last_total_cell lastTotalCell +#' @param ... additional arguments #' @export create_tablestyle <- function( name, - wholeTable = NULL, - headerRow = NULL, - totalRow = NULL, - firstColumn = NULL, - lastColumn = NULL, - firstRowStripe = NULL, - secondRowStripe = NULL, - firstColumnStripe = NULL, - secondColumnStripe = NULL, - firstHeaderCell = NULL, - lastHeaderCell = NULL, - firstTotalCell = NULL, - lastTotalCell = NULL + whole_table = NULL, + header_row = NULL, + total_row = NULL, + first_column = NULL, + last_column = NULL, + first_row_stripe = NULL, + second_row_stripe = NULL, + first_column_stripe = NULL, + second_column_stripe = NULL, + first_header_cell = NULL, + last_header_cell = NULL, + first_total_cell = NULL, + last_total_cell = NULL, + ... ) { + standardize_case_names(...) + tab_wholeTable <- NULL - if (length(wholeTable)) { + if (length(whole_table)) { tab_wholeTable <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "wholeTable", dxfId = wholeTable)) + xml_attributes = c(type = "wholeTable", dxfId = whole_table)) } tab_headerRow <- NULL - if (length(headerRow)) { + if (length(header_row)) { tab_headerRow <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "headerRow", dxfId = headerRow)) + xml_attributes = c(type = "headerRow", dxfId = header_row)) } tab_totalRow <- NULL - if (length(totalRow)) { + if (length(total_row)) { tab_totalRow <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "totalRow", dxfId = totalRow)) + xml_attributes = c(type = "totalRow", dxfId = total_row)) } tab_firstColumn <- NULL - if (length(firstColumn)) { + if (length(first_column)) { tab_firstColumn <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "firstColumn", dxfId = firstColumn)) + xml_attributes = c(type = "firstColumn", dxfId = first_column)) } tab_lastColumn <- NULL - if (length(lastColumn)) { + if (length(last_column)) { tab_lastColumn <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "lastColumn", dxfId = lastColumn)) + xml_attributes = c(type = "lastColumn", dxfId = last_column)) } tab_firstRowStripe <- NULL - if (length(firstRowStripe)) { + if (length(first_row_stripe)) { tab_firstRowStripe <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "firstRowStripe", dxfId = firstRowStripe)) + xml_attributes = c(type = "firstRowStripe", dxfId = first_row_stripe)) } tab_secondRowStripe <- NULL - if (length(secondRowStripe)) { + if (length(second_row_stripe)) { tab_secondRowStripe <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "secondRowStripe", dxfId = secondRowStripe)) + xml_attributes = c(type = "secondRowStripe", dxfId = second_row_stripe)) } tab_firstColumnStripe <- NULL - if (length(firstColumnStripe)) { + if (length(first_column_stripe)) { tab_firstColumnStripe <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "firstColumnStripe", dxfId = firstColumnStripe)) + xml_attributes = c(type = "firstColumnStripe", dxfId = first_column_stripe)) } tab_secondColumnStripe <- NULL - if (length(secondColumnStripe)) { + if (length(second_column_stripe)) { tab_secondColumnStripe <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "secondColumnStripe", dxfId = secondColumnStripe)) + xml_attributes = c(type = "secondColumnStripe", dxfId = second_column_stripe)) } tab_firstHeaderCell <- NULL - if (length(firstHeaderCell)) { + if (length(first_header_cell)) { tab_firstHeaderCell <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "firstHeaderCell", dxfId = firstHeaderCell)) + xml_attributes = c(type = "firstHeaderCell", dxfId = first_header_cell)) } tab_lastHeaderCell <- NULL - if (length(lastHeaderCell)) { + if (length(last_header_cell)) { tab_lastHeaderCell <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "lastHeaderCell", dxfId = lastHeaderCell)) + xml_attributes = c(type = "lastHeaderCell", dxfId = last_header_cell)) } tab_firstTotalCell <- NULL - if (length(firstTotalCell)) { + if (length(first_total_cell)) { tab_firstTotalCell <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "firstTotalCell", dxfId = firstTotalCell)) + xml_attributes = c(type = "firstTotalCell", dxfId = first_total_cell)) } tab_lastTotalCell <- NULL - if (length(lastTotalCell)) { + if (length(last_total_cell)) { tab_lastTotalCell <- xml_node_create( "tableStyleElement", - xml_attributes = c(type = "lastTotalCell", dxfId = lastTotalCell)) + xml_attributes = c(type = "lastTotalCell", dxfId = last_total_cell)) } xml_elements <- c( @@ -927,6 +932,7 @@ create_tablestyle <- function( name = name, pivot = "0", # pivot uses different styles count = as_xml_attr(length(xml_elements)), + # possible st_guid() `xr9:uid` = sprintf("{CE23B8CA-E823-724F-9713-%s}", rand_str) ), xml_children = xml_elements diff --git a/R/write.R b/R/write.R index 3ccea06ea..35492dec5 100644 --- a/R/write.R +++ b/R/write.R @@ -948,20 +948,21 @@ write_data_table <- function( #' @param wb A Workbook object containing a worksheet. #' @param sheet The worksheet to write to. Can be the worksheet index or name. #' @param x Object to be written. For classes supported look at the examples. -#' @param startCol A vector specifying the starting column to write to. -#' @param startRow A vector specifying the starting row to write to. +#' @param start_col A vector specifying the starting column to write to. +#' @param start_row A vector specifying the starting row to write to. #' @param dims Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B" #' @param array A bool if the function written is of type array -#' @param colNames If `TRUE`, column names of x are written. -#' @param rowNames If `TRUE`, data.frame row names of x are written. -#' @param withFilter If `TRUE`, add filters to the column name row. NOTE can only have one filter per worksheet. +#' @param col_names If `TRUE`, column names of x are written. +#' @param row_names If `TRUE`, data.frame row names of x are written. +#' @param with_filter If `TRUE`, add filters to the column name row. NOTE can only have one filter per worksheet. #' @param sep Only applies to list columns. The separator used to collapse list columns to a character vector e.g. sapply(x$list_column, paste, collapse = sep). #' @param name If not NULL, a named region is defined. -#' @param applyCellStyle apply styles when writing on the sheet -#' @param removeCellStyle if writing into existing cells, should the cell style be removed? +#' @param apply_cell_style apply styles when writing on the sheet +#' @param remove_cell_style if writing into existing cells, should the cell style be removed? #' @param na.strings Value used for replacing `NA` values from `x`. Default #' `na_strings()` uses the special `#N/A` value within the workbook. #' @param inline_strings write characters as inline strings +#' @param ... additional arguments #' @seealso [write_datatable()] #' @export write_data #' @details Formulae written using write_formula to a Workbook object will not get picked up by read_xlsx(). @@ -1025,45 +1026,48 @@ write_data <- function( wb, sheet, x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - array = FALSE, - colNames = TRUE, - rowNames = FALSE, - withFilter = FALSE, - sep = ", ", - name = NULL, - applyCellStyle = TRUE, - removeCellStyle = FALSE, - na.strings = na_strings(), - inline_strings = TRUE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + array = FALSE, + col_names = TRUE, + row_names = FALSE, + with_filter = FALSE, + sep = ", ", + name = NULL, + apply_cell_style = TRUE, + remove_cell_style = FALSE, + na.strings = na_strings(), + inline_strings = TRUE, + ... ) { + standardize_case_names(...) + write_data_table( - wb = wb, - sheet = sheet, - x = x, - startCol = startCol, - startRow = startRow, - dims = dims, - array = array, - colNames = colNames, - rowNames = rowNames, - tableStyle = NULL, - tableName = NULL, - withFilter = withFilter, - sep = sep, - firstColumn = FALSE, - lastColumn = FALSE, - bandedRows = FALSE, - bandedCols = FALSE, - name = name, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle, - data_table = FALSE, - na.strings = na.strings, - inline_strings = inline_strings + wb = wb, + sheet = sheet, + x = x, + dims = dims, + startCol = start_col, + startRow = start_row, + array = array, + colNames = col_names, + rowNames = row_names, + tableStyle = NULL, + tableName = NULL, + withFilter = with_filter, + sep = sep, + firstColumn = FALSE, + lastColumn = FALSE, + bandedRows = FALSE, + bandedCols = FALSE, + name = name, + applyCellStyle = apply_cell_style, + removeCellStyle = remove_cell_style, + data_table = FALSE, + na.strings = na.strings, + inline_strings = inline_strings ) } @@ -1084,13 +1088,14 @@ write_data <- function( #' @param wb A Workbook object containing a worksheet. #' @param sheet The worksheet to write to. Can be the worksheet index or name. #' @param x A character vector. -#' @param startCol A vector specifying the starting column to write to. -#' @param startRow A vector specifying the starting row to write to. #' @param dims Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B" +#' @param start_col A vector specifying the starting column to write to. +#' @param start_row A vector specifying the starting row to write to. #' @param array A bool if the function written is of type array #' @param cm A bool if the function is of type cm (array with hidden curly braces) -#' @param applyCellStyle apply styles when writing on the sheet -#' @param removeCellStyle if writing into existing cells, should the cell style be removed? +#' @param apply_cell_style apply styles when writing on the sheet +#' @param remove_cell_style if writing into existing cells, should the cell style be removed? +#' @param ... additional arguments #' @seealso [write_data()] #' @export write_formula #' @rdname write_formula @@ -1161,14 +1166,18 @@ write_formula <- function( wb, sheet, x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - array = FALSE, - cm = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + array = FALSE, + cm = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, + ... ) { + + standardize_case_names(...) + assert_class(x, "character") # remove xml encoding and reapply it afterwards. until v0.3 encoding was not enforced x <- replaceXMLEntities(x) @@ -1238,17 +1247,17 @@ write_formula <- function( } write_data( - wb = wb, - sheet = sheet, - x = dfx, - startCol = startCol, - startRow = startRow, - dims = dims, - array = array, - colNames = FALSE, - rowNames = FALSE, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle + wb = wb, + sheet = sheet, + x = dfx, + start_col = start_col, + start_row = start_row, + dims = dims, + array = array, + col_names = FALSE, + row_names = FALSE, + apply_cell_style = apply_cell_style, + remove_cell_style = remove_cell_style ) } @@ -1260,14 +1269,14 @@ write_formula <- function( #' @param wb A Workbook object containing a worksheet. #' @param sheet The worksheet to write to. Can be the worksheet index or name. #' @param x A data frame. -#' @param startCol A vector specifying the starting column to write df -#' @param startRow A vector specifying the starting row to write df +#' @param start_col A vector specifying the starting column to write df +#' @param start_row A vector specifying the starting row to write df #' @param dims Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B" -#' @param colNames If `TRUE`, column names of x are written. -#' @param rowNames If `TRUE`, row names of x are written. -#' @param tableStyle Any excel table style name or "none" (see "formatting" vignette). -#' @param tableName name of table in workbook. The table name must be unique. -#' @param withFilter If `TRUE`, columns with have filters in the first row. +#' @param col_names If `TRUE`, column names of x are written. +#' @param row_names If `TRUE`, row names of x are written. +#' @param table_style Any excel table style name or "none" (see "formatting" vignette). +#' @param table_name name of table in workbook. The table name must be unique. +#' @param with_filter If `TRUE`, columns with have filters in the first row. #' @param sep Only applies to list columns. The separator used to collapse list columns to a character vector e.g. sapply(x$list_column, paste, collapse = sep). #' \cr\cr #' \cr**The below options correspond to Excel table options:** @@ -1275,15 +1284,16 @@ write_formula <- function( #' \if{html}{\figure{tableoptions.png}{options: width="40\%" alt="Figure: table_options.png"}} #' \if{latex}{\figure{tableoptions.pdf}{options: width=7cm}} #' -#' @param firstColumn logical. If TRUE, the first column is bold -#' @param lastColumn logical. If TRUE, the last column is bold -#' @param bandedRows logical. If TRUE, rows are color banded -#' @param bandedCols logical. If TRUE, the columns are color banded -#' @param applyCellStyle apply styles when writing on the sheet -#' @param removeCellStyle if writing into existing cells, should the cell style be removed? +#' @param first_column logical. If TRUE, the first column is bold +#' @param last_column logical. If TRUE, the last column is bold +#' @param banded_rows logical. If TRUE, rows are color banded +#' @param banded_cols logical. If TRUE, the columns are color banded +#' @param apply_cell_style apply styles when writing on the sheet +#' @param remove_cell_style if writing into existing cells, should the cell style be removed? #' @param na.strings Value used for replacing `NA` values from `x`. Default #' `na_strings()` uses the special `#N/A` value within the workbook. #' @param inline_strings write characters as inline strings +#' @param ... additional arguments #' @details columns of x with class Date/POSIXt, currency, accounting, #' hyperlink, percentage are automatically styled as dates, currency, accounting, #' hyperlinks, percentages respectively. @@ -1380,48 +1390,51 @@ write_datatable <- function( wb, sheet, x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - colNames = TRUE, - rowNames = FALSE, - tableStyle = "TableStyleLight9", - tableName = NULL, - withFilter = TRUE, - sep = ", ", - firstColumn = FALSE, - lastColumn = FALSE, - bandedRows = TRUE, - bandedCols = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE, - na.strings = na_strings(), - inline_strings = TRUE + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + col_names = TRUE, + row_names = FALSE, + table_style = "TableStyleLight9", + table_name = NULL, + with_filter = TRUE, + sep = ", ", + first_column = FALSE, + last_column = FALSE, + banded_rows = TRUE, + banded_cols = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, + na.strings = na_strings(), + inline_strings = TRUE, + ... ) { + standardize_case_names(...) + write_data_table( - wb = wb, - sheet = sheet, - x = x, - startCol = startCol, - startRow = startRow, - dims = dims, - array = FALSE, - colNames = colNames, - rowNames = rowNames, - tableStyle = tableStyle, - tableName = tableName, - withFilter = withFilter, - sep = sep, - firstColumn = firstColumn, - lastColumn = lastColumn, - bandedRows = bandedRows, - bandedCols = bandedCols, - name = NULL, - data_table = TRUE, - applyCellStyle = applyCellStyle, - removeCellStyle = removeCellStyle, - na.strings = na.strings, - inline_strings = inline_strings + wb = wb, + sheet = sheet, + x = x, + startCol = start_col, + startRow = start_row, + dims = dims, + array = FALSE, + colNames = col_names, + rowNames = row_names, + tableStyle = table_style, + tableName = table_name, + withFilter = with_filter, + sep = sep, + firstColumn = first_column, + lastColumn = last_column, + bandedRows = banded_rows, + bandedCols = banded_cols, + name = NULL, + data_table = TRUE, + applyCellStyle = apply_cell_style, + removeCellStyle = remove_cell_style, + na.strings = na.strings, + inline_strings = inline_strings ) } diff --git a/R/write_xlsx.R b/R/write_xlsx.R index 0e1ce870e..506a82661 100644 --- a/R/write_xlsx.R +++ b/R/write_xlsx.R @@ -3,7 +3,7 @@ #' @description write a data.frame or list of data.frames to an xlsx file #' @param x object or a list of objects that can be handled by [write_data()] to write to file #' @param file xlsx file name -#' @param asTable write using write_datatable as opposed to write_data +#' @param as_table write using write_datatable as opposed to write_data #' @param ... optional parameters to pass to functions: #' \itemize{ #' \item{[wb_workbook()]} @@ -89,13 +89,19 @@ #' write_xlsx(l, temp_xlsx(), colWidths = list(rep(10, 5), rep(8, 11), rep(5, 5))) #' #' @export -write_xlsx <- function(x, file, asTable = FALSE, ...) { +write_xlsx <- function(x, file, as_table = FALSE, ...) { ## set scientific notation penalty params <- list(...) + # we need them in params + params <- standardize_case_names(params, return = TRUE) + + # and in global env for `asTable` + standardize_case_names(...) + ## Possible parameters #---wb_workbook---# @@ -139,8 +145,8 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { #---wb_save---# # overwrite = TRUE - if (!is.logical(asTable)) { - stop("asTable must be a logical.") + if (!is.logical(as_table)) { + stop("as_table must be a logical.") } creator <- if ("creator" %in% names(params)) params$creator else "" @@ -150,12 +156,12 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { sheetName <- "Sheet 1" - if ("sheetName" %in% names(params)) { - if (any(nchar(params$sheetName) > 31)) { - stop("sheetName too long! Max length is 31 characters.") + if ("sheet_name" %in% names(params)) { + if (any(nchar(params$sheet_name) > 31)) { + stop("sheet_name too long! Max length is 31 characters.") } - sheetName <- as.character(params$sheetName) + sheetName <- as.character(params$sheet_name) if (inherits(x, "list") && (length(sheetName) == length(x))) { names(x) <- sheetName @@ -163,10 +169,8 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { } tabColor <- NULL - if ("tabColor" %in% names(params)) { - tabColor <- params$tabColor - } else if ("tabColor" %in% names(params)) { - tabColor <- params$tabColor + if ("tab_color" %in% names(params)) { + tabColor <- params$tab_color } zoom <- 100 @@ -180,11 +184,11 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { ## wb_add_worksheet() gridLines <- TRUE - if ("gridLines" %in% names(params)) { - if (all(is.logical(params$gridLines))) { - gridLines <- params$gridLines + if ("grid_lines" %in% names(params)) { + if (all(is.logical(params$grid_lines))) { + gridLines <- params$grid_lines } else { - stop("Argument gridLines must be TRUE or FALSE") + stop("Argument grid_lines must be TRUE or FALSE") } } @@ -199,38 +203,38 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { withFilter <- TRUE - if ("withFilter" %in% names(params)) { - if (is.logical(params$withFilter)) { - withFilter <- params$withFilter + if ("with_filter" %in% names(params)) { + if (is.logical(params$with_filter)) { + withFilter <- params$with_filter } else { - stop("Argument withFilter must be TRUE or FALSE") + stop("Argument with_filter must be TRUE or FALSE") } } startRow <- 1 - if ("startRow" %in% names(params)) { - if (all(params$startRow > 0)) { - startRow <- params$startRow + if ("start_row" %in% names(params)) { + if (all(params$start_row > 0)) { + startRow <- params$start_row } else { - stop("startRow must be a positive integer") + stop("start_row must be a positive integer") } } startCol <- 1 - if ("startCol" %in% names(params)) { - if (all(col2int(params$startCol) > 0)) { - startCol <- params$startCol + if ("start_col" %in% names(params)) { + if (all(col2int(params$start_col) > 0)) { + startCol <- params$start_col } else { - stop("startCol must be a positive integer") + stop("start_col must be a positive integer") } } colNames <- TRUE - if ("colNames" %in% names(params)) { - if (is.logical(params$colNames)) { - colNames <- params$colNames + if ("col_names" %in% names(params)) { + if (is.logical(params$col_names)) { + colNames <- params$col_names } else { - stop("Argument colNames must be TRUE or FALSE") + stop("Argument col_names must be TRUE or FALSE") } } @@ -245,11 +249,11 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { rowNames <- FALSE - if ("rowNames" %in% names(params)) { - if (is.logical(params$rowNames)) { - rowNames <- params$rowNames + if ("row_names" %in% names(params)) { + if (is.logical(params$row_names)) { + rowNames <- params$row_names } else { - stop("Argument colNames must be TRUE or FALSE") + stop("Argument row_names must be TRUE or FALSE") } } @@ -263,15 +267,15 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { } colWidths <- NULL - if ("colWidths" %in% names(params)) { - colWidths <- params$colWidths + if ("col_widths" %in% names(params)) { + colWidths <- params$col_widths if (any(is.na(colWidths))) colWidths[is.na(colWidths)] <- 8.43 } tableStyle <- "TableStyleLight9" - if ("tableStyle" %in% names(params)) { - tableStyle <- params$tableStyle + if ("table_style" %in% names(params)) { + tableStyle <- params$table_style } na.strings <- @@ -340,8 +344,8 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { startCol <- rep_len(startCol, length.out = nSheets) } - if (length(asTable) != nSheets) { - asTable <- rep_len(asTable, length.out = nSheets) + if (length(as_table) != nSheets) { + as_table <- rep_len(as_table, length.out = nSheets) } if (length(tableStyle) != nSheets) { @@ -356,29 +360,29 @@ write_xlsx <- function(x, file, asTable = FALSE, ...) { for (i in seq_len(nSheets)) { wb$add_worksheet(nms[[i]], gridLines = gridLines[i], tabColor = tabColor[i], zoom = zoom[i]) - if (asTable[i]) { + if (as_table[i]) { write_datatable( - wb = wb, - sheet = i, - x = x[[i]], - startCol = startCol[[i]], - startRow = startRow[[i]], - colNames = colNames[[i]], - rowNames = rowNames[[i]], - tableStyle = tableStyle[[i]], - tableName = NULL, - withFilter = withFilter[[i]], - na.strings = na.strings + wb = wb, + sheet = i, + x = x[[i]], + start_col = startCol[[i]], + start_row = startRow[[i]], + col_names = colNames[[i]], + row_names = rowNames[[i]], + table_style = tableStyle[[i]], + table_name = NULL, + with_filter = withFilter[[i]], + na.strings = na.strings ) } else { write_data( wb = wb, sheet = i, x = x[[i]], - startCol = startCol[[i]], - startRow = startRow[[i]], - colNames = colNames[[i]], - rowNames = rowNames[[i]], + start_col = startCol[[i]], + start_row = startRow[[i]], + col_names = colNames[[i]], + row_names = rowNames[[i]], na.strings = na.strings ) } diff --git a/man/comment.Rd b/man/comment.Rd index c7249c3fd..29a9de510 100644 --- a/man/comment.Rd +++ b/man/comment.Rd @@ -35,23 +35,9 @@ remove_comment( dims = NULL ) -wb_add_comment( - wb, - sheet = current_sheet(), - col = NULL, - row = NULL, - dims = rowcol_to_dim(row, col), - comment -) +wb_add_comment(wb, sheet = current_sheet(), dims = "A1", comment, ...) -wb_remove_comment( - wb, - sheet = current_sheet(), - col = NULL, - row = NULL, - dims = rowcol_to_dims(row, col), - gridExpand = TRUE -) +wb_remove_comment(wb, sheet = current_sheet(), dims = "A1", ...) } \arguments{ \item{text}{Comment text. Character vector.} @@ -78,7 +64,10 @@ wb_remove_comment( \item{dims}{Optional row and column as spreadsheet dimension, e.g. "A1"} -\item{gridExpand}{Remove all comments inside the grid. Similar to dims "A1:B2"} +\item{gridExpand}{If \code{TRUE}, all data in rectangle min(rows):max(rows) X min(cols):max(cols) +will be removed.} + +\item{...}{additional arguments} } \value{ The \code{wbWorkbook} object @@ -113,3 +102,4 @@ write_comment(wb, 1, col = 6, row = 3, comment = c3) # remove the first comment remove_comment(wb, 1, col = "B", row = 10) } +\keyword{internal} diff --git a/man/create_border.Rd b/man/create_border.Rd index e394b7425..c895fb51a 100644 --- a/man/create_border.Rd +++ b/man/create_border.Rd @@ -5,8 +5,8 @@ \title{create border} \usage{ create_border( - diagonalDown = "", - diagonalUp = "", + diagonal_down = "", + diagonal_up = "", outline = "", bottom = NULL, bottom_color = NULL, @@ -26,9 +26,9 @@ create_border( ) } \arguments{ -\item{diagonalDown}{x} +\item{diagonal_down}{x} -\item{diagonalUp}{x} +\item{diagonal_up}{x} \item{outline}{x} diff --git a/man/create_cell_style.Rd b/man/create_cell_style.Rd index 59db85f49..947b80f24 100644 --- a/man/create_cell_style.Rd +++ b/man/create_cell_style.Rd @@ -5,62 +5,62 @@ \title{create_cell_style} \usage{ create_cell_style( - borderId = "", - fillId = "", - fontId = "", - numFmtId = "", - pivotButton = "", - quotePrefix = "", - xfId = "", + border_id = "", + fill_id = "", + font_id = "", + num_fmt_id = "", + pivot_button = "", + quote_prefix = "", + xf_id = "", horizontal = "", indent = "", - justifyLastLine = "", - readingOrder = "", - relativeIndent = "", - shrinkToFit = "", - textRotation = "", + justify_last_line = "", + reading_order = "", + relative_indent = "", + shrink_to_fit = "", + text_rotation = "", vertical = "", - wrapText = "", - extLst = "", + wrap_text = "", + ext_lst = "", hidden = "", locked = "", ... ) } \arguments{ -\item{borderId}{dummy} +\item{border_id}{dummy} -\item{fillId}{dummy} +\item{fill_id}{dummy} -\item{fontId}{dummy} +\item{font_id}{dummy} -\item{numFmtId}{a numFmt ID for a builtin style} +\item{num_fmt_id}{a numFmt ID for a builtin style} -\item{pivotButton}{dummy} +\item{pivot_button}{dummy} -\item{quotePrefix}{dummy} +\item{quote_prefix}{dummy} -\item{xfId}{dummy} +\item{xf_id}{dummy} \item{horizontal}{alignment can be "", "center", "right"} \item{indent}{dummy} -\item{justifyLastLine}{dummy} +\item{justify_last_line}{dummy} -\item{readingOrder}{dummy} +\item{reading_order}{dummy} -\item{relativeIndent}{dummy} +\item{relative_indent}{dummy} -\item{shrinkToFit}{dummy} +\item{shrink_to_fit}{dummy} -\item{textRotation}{dummy} +\item{text_rotation}{dummy} \item{vertical}{alignment can be "", "center", "right"} -\item{wrapText}{dummy} +\item{wrap_text}{dummy} -\item{extLst}{dummy} +\item{ext_lst}{dummy} \item{hidden}{dummy} diff --git a/man/create_dxfs_style.Rd b/man/create_dxfs_style.Rd index e371caba5..626229d9b 100644 --- a/man/create_dxfs_style.Rd +++ b/man/create_dxfs_style.Rd @@ -8,13 +8,13 @@ create_dxfs_style( font_name = NULL, font_size = NULL, font_color = NULL, - numFmt = NULL, + num_fmt = NULL, border = NULL, border_color = wb_color(getOption("openxlsx2.borderColor", "black")), border_style = getOption("openxlsx2.borderStyle", "thin"), - bgFill = NULL, - fgColor = NULL, - gradientFill = NULL, + bg_fill = NULL, + fg_color = NULL, + gradient_fill = NULL, text_bold = NULL, text_strike = NULL, text_italic = NULL, @@ -33,7 +33,7 @@ If fontSize is NULL, the workbook base font size is used. (Defaults to 11)} or one of colors(). If fontColor is NULL, the workbook base font colors is used. (Defaults to black)} -\item{numFmt}{Cell formatting. Some custom openxml format} +\item{num_fmt}{Cell formatting. Some custom openxml format} \item{border}{NULL or TRUE} @@ -41,11 +41,11 @@ or one of colors(). If fontColor is NULL, the workbook base font colors is used. \item{border_style}{"thin"} -\item{bgFill}{Cell background fill color.} +\item{bg_fill}{Cell background fill color.} -\item{fgColor}{Cell foreground fill color.} +\item{fg_color}{Cell foreground fill color.} -\item{gradientFill}{An xml string beginning with \verb{} ...} +\item{gradient_fill}{An xml string beginning with \verb{} ...} \item{text_bold}{bold} diff --git a/man/create_tablestyle.Rd b/man/create_tablestyle.Rd index f5b2beb11..585c76af5 100644 --- a/man/create_tablestyle.Rd +++ b/man/create_tablestyle.Rd @@ -6,49 +6,52 @@ \usage{ create_tablestyle( name, - wholeTable = NULL, - headerRow = NULL, - totalRow = NULL, - firstColumn = NULL, - lastColumn = NULL, - firstRowStripe = NULL, - secondRowStripe = NULL, - firstColumnStripe = NULL, - secondColumnStripe = NULL, - firstHeaderCell = NULL, - lastHeaderCell = NULL, - firstTotalCell = NULL, - lastTotalCell = NULL + whole_table = NULL, + header_row = NULL, + total_row = NULL, + first_column = NULL, + last_column = NULL, + first_row_stripe = NULL, + second_row_stripe = NULL, + first_column_stripe = NULL, + second_column_stripe = NULL, + first_header_cell = NULL, + last_header_cell = NULL, + first_total_cell = NULL, + last_total_cell = NULL, + ... ) } \arguments{ \item{name}{name} -\item{wholeTable}{wholeTable} +\item{whole_table}{wholeTable} -\item{headerRow}{headerRow} +\item{header_row}{headerRow} -\item{totalRow}{totalRow} +\item{total_row}{totalRow} -\item{firstColumn}{firstColumn} +\item{first_column}{firstColumn} -\item{lastColumn}{lastColumn} +\item{last_column}{lastColumn} -\item{firstRowStripe}{firstRowStripe} +\item{first_row_stripe}{firstRowStripe} -\item{secondRowStripe}{secondRowStripe} +\item{second_row_stripe}{secondRowStripe} -\item{firstColumnStripe}{firstColumnStripe} +\item{first_column_stripe}{firstColumnStripe} -\item{secondColumnStripe}{secondColumnStripe} +\item{second_column_stripe}{secondColumnStripe} -\item{firstHeaderCell}{firstHeaderCell} +\item{first_header_cell}{firstHeaderCell} -\item{lastHeaderCell}{lastHeaderCell} +\item{last_header_cell}{lastHeaderCell} -\item{firstTotalCell}{firstTotalCell} +\item{first_total_cell}{firstTotalCell} -\item{lastTotalCell}{lastTotalCell} +\item{last_total_cell}{lastTotalCell} + +\item{...}{additional arguments} } \description{ create tableStyle diff --git a/man/get_cell_refs.Rd b/man/get_cell_refs.Rd deleted file mode 100644 index 39784f8f7..000000000 --- a/man/get_cell_refs.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/converters.R -\name{get_cell_refs} -\alias{get_cell_refs} -\title{Return excel cell coordinates from (x,y) coordinates} -\usage{ -get_cell_refs(cellCoords) -} -\arguments{ -\item{cellCoords}{A data.frame with two columns coordinate pairs.} -} -\value{ -Excel alphanumeric cell reference -} -\description{ -Return excel cell coordinates from (x,y) coordinates -} -\examples{ -get_cell_refs(data.frame(1, 2)) -# "B1" -get_cell_refs(data.frame(1:3, 2:4)) -# "B1" "C2" "D3" -} diff --git a/man/get_date_origin.Rd b/man/get_date_origin.Rd deleted file mode 100644 index b840857f8..000000000 --- a/man/get_date_origin.Rd +++ /dev/null @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dates.R -\name{get_date_origin} -\alias{get_date_origin} -\title{Get the date origin an xlsx file is using} -\usage{ -get_date_origin(xlsxFile, origin = FALSE) -} -\arguments{ -\item{xlsxFile}{An xlsx or xlsm file or a wbWorkbook object.} - -\item{origin}{return the origin instead of the character string.} -} -\value{ -One of "1900-01-01" or "1904-01-01". -} -\description{ -Return the date origin used internally by an xlsx or xlsm file -} -\details{ -Excel stores dates as the number of days from either 1904-01-01 or 1900-01-01. This function -checks the date origin being used in an Excel file and returns is so it can be used in \code{\link[=convert_date]{convert_date()}} -} -\examples{ - -## create a file with some dates -temp <- temp_xlsx() -write_xlsx(as.Date("2015-01-10") - (0:4), file = temp) -m <- read_xlsx(temp) - -## convert to dates -do <- get_date_origin(system.file("extdata", "openxlsx2_example.xlsx", package = "openxlsx2")) -convert_date(m[[1]], do) - -get_date_origin(wb_workbook()) -get_date_origin(wb_workbook(), origin = TRUE) -} -\seealso{ -\code{\link[=convert_date]{convert_date()}} -} diff --git a/man/guess_col_type.Rd b/man/guess_col_type.Rd deleted file mode 100644 index 5e56c2d25..000000000 --- a/man/guess_col_type.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/wb_functions.R -\name{guess_col_type} -\alias{guess_col_type} -\title{function to estimate the column type. -0 = character, 1 = numeric, 2 = date.} -\usage{ -guess_col_type(tt) -} -\arguments{ -\item{tt}{dataframe produced by wb_to_df()} -} -\description{ -function to estimate the column type. -0 = character, 1 = numeric, 2 = date. -} diff --git a/man/named_region.Rd b/man/named_region.Rd index c08b9e688..b08090197 100644 --- a/man/named_region.Rd +++ b/man/named_region.Rd @@ -12,24 +12,23 @@ wb_add_named_region( wb, sheet = current_sheet(), dims = "A1", - cols, - rows, name, - localSheet = FALSE, + local_sheet = FALSE, overwrite = FALSE, comment = NULL, - customMenu = NULL, + custom_menu = NULL, description = NULL, is_function = NULL, - functionGroupId = NULL, + function_group_id = NULL, help = NULL, hidden = NULL, - localName = NULL, - publishToServer = NULL, - statusBar = NULL, - vbProcedure = NULL, - workbookParameter = NULL, - xml = NULL + local_name = NULL, + publish_to_server = NULL, + status_bar = NULL, + vb_procedure = NULL, + workbook_parameter = NULL, + xml = NULL, + ... ) wb_remove_named_region(wb, sheet = current_sheet(), name = NULL) @@ -43,42 +42,40 @@ wb_get_named_regions(x, tables = FALSE) \item{dims}{Worksheet dimension, single cell ("A1") or cell range ("A1:D4")} -\item{cols}{Numeric vector specifying columns to include in region} - -\item{rows}{Numeric vector specifying rows to include in region} - \item{name}{Name for region. A character vector of length 1. Note region names musts be case-insensitive unique.} -\item{localSheet}{If \code{TRUE} the named region will be local for this sheet} +\item{local_sheet}{If \code{TRUE} the named region will be local for this sheet} \item{overwrite}{Boolean. Overwrite if exists? Default to FALSE} \item{comment}{description text for named region} -\item{customMenu}{customMenu (unknown xml feature)} +\item{custom_menu}{customMenu (unknown xml feature)} \item{description}{description (unknown xml feature)} \item{is_function}{function (unknown xml feature)} -\item{functionGroupId}{function group id (unknown xml feature)} +\item{function_group_id}{function group id (unknown xml feature)} \item{help}{help (unknown xml feature)} \item{hidden}{hidden if the named region should be hidden} -\item{localName}{localName (unknown xml feature)} +\item{local_name}{localName (unknown xml feature)} -\item{publishToServer}{publish to server (unknown xml feature)} +\item{publish_to_server}{publish to server (unknown xml feature)} -\item{statusBar}{status bar (unknown xml feature)} +\item{status_bar}{status bar (unknown xml feature)} -\item{vbProcedure}{wbProcedure (unknown xml feature)} +\item{vb_procedure}{wbProcedure (unknown xml feature)} -\item{workbookParameter}{workbookParameter (unknown xml feature)} +\item{workbook_parameter}{workbookParameter (unknown xml feature)} \item{xml}{xml (unknown xml feature)} +\item{...}{additional arguments} + \item{x}{An xlsx file or Workbook object} \item{tables}{add tables too} @@ -102,8 +99,10 @@ wb$add_data(sheet = 1, x = iris, startCol = 1, startRow = 1) wb$add_named_region( sheet = 1, name = "iris", - rows = seq_len(nrow(iris) + 1), - cols = seq_along(iris) + dims = rowcol_to_dims( + row = seq_len(nrow(iris) + 1), + col = seq_along(iris) + ) ) @@ -127,37 +126,4 @@ head(df) df <- read_xlsx(out_file, namedRegion = "iris2") head(df) -## create named regions -wb <- wb_workbook() -wb$add_worksheet("Sheet 1") - -## specify region -wb$add_data(sheet = 1, x = iris, startCol = 1, startRow = 1) -wb$add_named_region( - sheet = 1, - name = "iris", - rows = seq_len(nrow(iris) + 1), - cols = seq_along(iris) -) - - -## using write_data 'name' argument to create a named region -wb$add_data(sheet = 1, x = iris, name = "iris2", startCol = 10) - -out_file <- temp_xlsx() -wb$save(out_file, overwrite = TRUE) - -## see named regions -wb_get_named_regions(wb) ## From Workbook object -wb_get_named_regions(out_file) ## From xlsx file - -## read named regions -df <- read_xlsx(wb, namedRegion = "iris") -head(df) - -df <- read_xlsx(out_file, namedRegion = "iris2") -head(df) -} -\seealso{ -\code{\link[=wb_add_named_region]{wb_add_named_region()}} \code{\link[=wb_remove_named_region]{wb_remove_named_region()}} } diff --git a/man/read_xlsx.Rd b/man/read_xlsx.Rd index a857ec639..1a3bc02ea 100644 --- a/man/read_xlsx.Rd +++ b/man/read_xlsx.Rd @@ -5,43 +5,43 @@ \title{Read from an Excel file or Workbook object} \usage{ read_xlsx( - xlsxFile, + xlsx_file, sheet, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, rows = NULL, cols = NULL, - detectDates = TRUE, - namedRegion, + detect_dates = TRUE, + named_region, na.strings = "#N/A", na.numbers = NA, check.names = FALSE, sep.names = ".", - fillMergedCells = FALSE, + fill_merged_cells = FALSE, ... ) } \arguments{ -\item{xlsxFile}{An xlsx file, Workbook object or URL to xlsx file.} +\item{xlsx_file}{An xlsx file, Workbook object or URL to xlsx file.} \item{sheet}{The name or index of the sheet to read data from.} -\item{startRow}{first row to begin looking for data.} +\item{start_row}{first row to begin looking for data.} -\item{startCol}{first column to begin looking for data.} +\item{start_col}{first column to begin looking for data.} -\item{rowNames}{If \code{TRUE}, first column of data will be used as row names.} +\item{row_names}{If \code{TRUE}, first column of data will be used as row names.} -\item{colNames}{If \code{TRUE}, the first row of data will be used as column names.} +\item{col_names}{If \code{TRUE}, the first row of data will be used as column names.} -\item{skipEmptyRows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data +\item{skip_empty_rows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data will return a row of NAs.} -\item{skipEmptyCols}{If \code{TRUE}, empty columns are skipped.} +\item{skip_empty_cols}{If \code{TRUE}, empty columns are skipped.} \item{rows}{A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.} @@ -49,9 +49,9 @@ If NULL, all rows are read.} \item{cols}{A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.} -\item{detectDates}{If \code{TRUE}, attempt to recognize dates and perform conversion.} +\item{detect_dates}{If \code{TRUE}, attempt to recognize dates and perform conversion.} -\item{namedRegion}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.} +\item{named_region}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.} \item{na.strings}{A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.} @@ -62,7 +62,7 @@ are checked to ensure that they are syntactically valid variable names} \item{sep.names}{(unimplemented) One character which substitutes blanks in column names. By default, "."} -\item{fillMergedCells}{If TRUE, the value in a merged cell is given to all cells within the merge.} +\item{fill_merged_cells}{If TRUE, the value in a merged cell is given to all cells within the merge.} \item{...}{additional arguments passed to \code{wb_to_df()}} } diff --git a/man/style_mgr.Rd b/man/style_mgr.Rd deleted file mode 100644 index 796345f62..000000000 --- a/man/style_mgr.Rd +++ /dev/null @@ -1,637 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-style_mgr.R -\name{style_mgr} -\alias{style_mgr} -\title{style manager} -\description{ -style manager - -style manager -} -\examples{ -xlsxFile <- system.file("extdata", "oxlsx2_sheet.xlsx", package = "openxlsx2") -wb <- wb_load(xlsxFile) - -# ## start style mgr -# style <- style_mgr$new(wb) -# style$initialize(wb) - -# wb$styles_mgr$get_numfmt() |> print() -# wb$styles_mgr$next_numfmt_id() |> print() -# wb$styles_mgr$get_numfmt_id("numFmt-166") - -# create new number format -new_numfmt <- create_numfmt(numFmtId = wb$styles_mgr$next_numfmt_id(), formatCode = "#,#") - -# add it via stylemgr -wb$styles_mgr$add(new_numfmt, "test") - -## get numfmts (invisible) -# z <- wb$styles_mgr$get_numfmt() -# z -wb$styles_mgr$styles$numFmts - -## create and add huge font -new_huge_font <- create_font(sz = "20", name = "Arial", b = "1", - color = wb_color(hex = "FFFFFFFF")) -wb$styles_mgr$add(new_huge_font, "arial_huge") - -## create another font -new_font <- create_font(name = "Arial") -wb$styles_mgr$add(new_font, "arial") - -## create and add new fill -new_fill <- create_fill(patternType = "solid", fgColor = wb_color(hex = "FF00224B")) -wb$styles_mgr$add(new_fill, "blue") - -# create new style with numfmt enabled -head_xf <- create_cell_style( - horizontal = "center", - textRotation = "45", - numFmtId = "0", - fontId = wb$styles_mgr$get_font_id("arial_huge"), - fillId = wb$styles_mgr$get_fill_id("blue") -) - -new_xf <- create_cell_style( - numFmtId = wb$styles_mgr$get_numfmt_id("test"), - fontId = wb$styles_mgr$get_font_id("arial") -) - -## add new styles -wb$styles_mgr$add(head_xf, "head_xf") -wb$styles_mgr$add(new_xf, "new_xf") - -## get cell style ids (invisible) -# z <- wb$styles_mgr$get_xf() - -## get cell style id -# wb$styles_mgr$get_xf_id("new_xf") - - ## assign styles to cells -wb$set_cell_style("SUM", "B3:I3", wb$styles_mgr$get_xf_id("head_xf")) -wb$set_cell_style("SUM", "C7:C16", wb$styles_mgr$get_xf_id("new_xf")) -# wb_open(wb) - -} -\section{Public fields}{ -\if{html}{\out{
}} -\describe{ -\item{\code{numfmt}}{numfmt-ids} - -\item{\code{font}}{font-ids} - -\item{\code{fill}}{fill-ids} - -\item{\code{border}}{border-ids} - -\item{\code{xf}}{xf-ids} - -\item{\code{cellStyle}}{cellStyle-ids} - -\item{\code{cellStyleXf}}{cellStyleXf-ids} - -\item{\code{dxf}}{dxf-ids} - -\item{\code{tableStyle}}{tableStyle-ids} - -\item{\code{defaultTableStyle}}{defaultTableStyle} - -\item{\code{defaultPivotStyle}}{defaultPivotStyle} - -\item{\code{styles}}{styles as xml} -} -\if{html}{\out{
}} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-wbStylesMgr-new}{\code{style_mgr$new()}} -\item \href{#method-wbStylesMgr-get_numfmt}{\code{style_mgr$get_numfmt()}} -\item \href{#method-wbStylesMgr-get_font}{\code{style_mgr$get_font()}} -\item \href{#method-wbStylesMgr-get_fill}{\code{style_mgr$get_fill()}} -\item \href{#method-wbStylesMgr-get_border}{\code{style_mgr$get_border()}} -\item \href{#method-wbStylesMgr-get_xf}{\code{style_mgr$get_xf()}} -\item \href{#method-wbStylesMgr-get_cellStyle}{\code{style_mgr$get_cellStyle()}} -\item \href{#method-wbStylesMgr-get_cellStyleXf}{\code{style_mgr$get_cellStyleXf()}} -\item \href{#method-wbStylesMgr-get_dxf}{\code{style_mgr$get_dxf()}} -\item \href{#method-wbStylesMgr-get_numfmt_id}{\code{style_mgr$get_numfmt_id()}} -\item \href{#method-wbStylesMgr-get_font_id}{\code{style_mgr$get_font_id()}} -\item \href{#method-wbStylesMgr-get_fill_id}{\code{style_mgr$get_fill_id()}} -\item \href{#method-wbStylesMgr-get_border_id}{\code{style_mgr$get_border_id()}} -\item \href{#method-wbStylesMgr-get_xf_id}{\code{style_mgr$get_xf_id()}} -\item \href{#method-wbStylesMgr-get_cellStyle_id}{\code{style_mgr$get_cellStyle_id()}} -\item \href{#method-wbStylesMgr-get_cellStyleXf_id}{\code{style_mgr$get_cellStyleXf_id()}} -\item \href{#method-wbStylesMgr-get_dxf_id}{\code{style_mgr$get_dxf_id()}} -\item \href{#method-wbStylesMgr-get_tableStyle_id}{\code{style_mgr$get_tableStyle_id()}} -\item \href{#method-wbStylesMgr-next_numfmt_id}{\code{style_mgr$next_numfmt_id()}} -\item \href{#method-wbStylesMgr-next_font_id}{\code{style_mgr$next_font_id()}} -\item \href{#method-wbStylesMgr-next_fill_id}{\code{style_mgr$next_fill_id()}} -\item \href{#method-wbStylesMgr-next_border_id}{\code{style_mgr$next_border_id()}} -\item \href{#method-wbStylesMgr-next_xf_id}{\code{style_mgr$next_xf_id()}} -\item \href{#method-wbStylesMgr-next_cellstyle_id}{\code{style_mgr$next_cellstyle_id()}} -\item \href{#method-wbStylesMgr-next_cellstylexf_id}{\code{style_mgr$next_cellstylexf_id()}} -\item \href{#method-wbStylesMgr-next_dxf_id}{\code{style_mgr$next_dxf_id()}} -\item \href{#method-wbStylesMgr-next_tableStyle_id}{\code{style_mgr$next_tableStyle_id()}} -\item \href{#method-wbStylesMgr-getstyle_ids}{\code{style_mgr$getstyle_ids()}} -\item \href{#method-wbStylesMgr-add}{\code{style_mgr$add()}} -\item \href{#method-wbStylesMgr-init_named_style}{\code{style_mgr$init_named_style()}} -\item \href{#method-wbStylesMgr-clone}{\code{style_mgr$clone()}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new \code{wbStylesMgr} object -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$new( - numfmt = NA, - font = NA, - fill = NA, - border = NA, - xf = NA, - cellStyle = NA, - cellStyleXf = NA, - dxf = NA, - styles = NA -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{numfmt}}{numfmt} - -\item{\code{font}}{font} - -\item{\code{fill}}{fill} - -\item{\code{border}}{border} - -\item{\code{xf}}{xf} - -\item{\code{cellStyle}}{cellStyles} - -\item{\code{cellStyleXf}}{cellStylesXf} - -\item{\code{dxf}}{dxf} - -\item{\code{styles}}{styles} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -a \code{wbStylesMgr} object -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_numfmt}{}}} -\subsection{Method \code{get_numfmt()}}{ -get numfmt ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_numfmt()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_font}{}}} -\subsection{Method \code{get_font()}}{ -get font ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_font()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_fill}{}}} -\subsection{Method \code{get_fill()}}{ -get fill ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_fill()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_border}{}}} -\subsection{Method \code{get_border()}}{ -get border ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_border()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_xf}{}}} -\subsection{Method \code{get_xf()}}{ -get xf ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_xf()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_cellStyle}{}}} -\subsection{Method \code{get_cellStyle()}}{ -get cellstyle ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_cellStyle()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_cellStyleXf}{}}} -\subsection{Method \code{get_cellStyleXf()}}{ -get cellstylexf ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_cellStyleXf()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_dxf}{}}} -\subsection{Method \code{get_dxf()}}{ -get dxf ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_dxf()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_numfmt_id}{}}} -\subsection{Method \code{get_numfmt_id()}}{ -get numfmt id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_numfmt_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_font_id}{}}} -\subsection{Method \code{get_font_id()}}{ -get font id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_font_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_fill_id}{}}} -\subsection{Method \code{get_fill_id()}}{ -get fill id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_fill_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_border_id}{}}} -\subsection{Method \code{get_border_id()}}{ -get border id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_border_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_xf_id}{}}} -\subsection{Method \code{get_xf_id()}}{ -get xf id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_xf_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_cellStyle_id}{}}} -\subsection{Method \code{get_cellStyle_id()}}{ -get cellstyle id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_cellStyle_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_cellStyleXf_id}{}}} -\subsection{Method \code{get_cellStyleXf_id()}}{ -get cellstyleXf id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_cellStyleXf_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_dxf_id}{}}} -\subsection{Method \code{get_dxf_id()}}{ -get dxf id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_dxf_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-get_tableStyle_id}{}}} -\subsection{Method \code{get_tableStyle_id()}}{ -get tableStyle id by name -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$get_tableStyle_id(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_numfmt_id}{}}} -\subsection{Method \code{next_numfmt_id()}}{ -get next numfmt id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_numfmt_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_font_id}{}}} -\subsection{Method \code{next_font_id()}}{ -get next font id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_font_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_fill_id}{}}} -\subsection{Method \code{next_fill_id()}}{ -get next fill id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_fill_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_border_id}{}}} -\subsection{Method \code{next_border_id()}}{ -get next border id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_border_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_xf_id}{}}} -\subsection{Method \code{next_xf_id()}}{ -get next xf id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_xf_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_cellstyle_id}{}}} -\subsection{Method \code{next_cellstyle_id()}}{ -get next xf id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_cellstyle_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_cellstylexf_id}{}}} -\subsection{Method \code{next_cellstylexf_id()}}{ -get next xf id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_cellstylexf_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_dxf_id}{}}} -\subsection{Method \code{next_dxf_id()}}{ -get next dxf id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_dxf_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-next_tableStyle_id}{}}} -\subsection{Method \code{next_tableStyle_id()}}{ -get next tableStyle id -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$next_tableStyle_id()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-getstyle_ids}{}}} -\subsection{Method \code{getstyle_ids()}}{ -get named style ids -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$getstyle_ids(name)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{name} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-add}{}}} -\subsection{Method \code{add()}}{ -add entry -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$add(style, style_name, skip_duplicates = TRUE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{style}}{new_style} - -\item{\code{style_name}}{a unique name identifying the style} - -\item{\code{skip_duplicates}}{should duplicates be added?} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-init_named_style}{}}} -\subsection{Method \code{init_named_style()}}{ -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$init_named_style(name, font_name = "Arial", font_size = 11)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{name}}{style name} - -\item{\code{font_name, font_size}}{optional else the default of the theme} - -\item{\code{wb}}{wbWorkbook} -} -\if{html}{\out{
}} -} -\subsection{Details}{ -possible styles are: -"20\% - Accent1" -"20\% - Accent2" -"20\% - Accent3" -"20\% - Accent4" -"20\% - Accent5" -"20\% - Accent6" -"40\% - Accent1" -"40\% - Accent2" -"40\% - Accent3" -"40\% - Accent4" -"40\% - Accent5" -"40\% - Accent6" -"60\% - Accent1" -"60\% - Accent2" -"60\% - Accent3" -"60\% - Accent4" -"60\% - Accent5" -"60\% - Accent6" -"Accent1" -"Accent2" -"Accent3" -"Accent4" -"Accent5" -"Accent6" -"Bad" -"Calculation" -"Check Cell" -"Comma" -"Comma [0]" -"Currency" -"Currency [0]" -"Explanatory Text" -"Good" -"Heading 1" -"Heading 2" -"Heading 3" -"Heading 4" -"Input" -"Linked Cell" -”Neutral" -"Normal" -"Note" -"Output" -"Per cent" -"Title" -"Total" -"Warning Text" -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbStylesMgr-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{style_mgr$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/wbChartSheet.Rd b/man/wbChartSheet.Rd index d094fca41..96bc52d25 100644 --- a/man/wbChartSheet.Rd +++ b/man/wbChartSheet.Rd @@ -91,68 +91,65 @@ get (prior) sheet data add sheetview \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbChartSheet$set_sheetview( - colorId = NULL, - defaultGridColor = NULL, - rightToLeft = NULL, - showFormulas = NULL, - showGridLines = NULL, - showOutlineSymbols = NULL, - showRowColHeaders = NULL, - showRuler = NULL, - showWhiteSpace = NULL, - showZeros = NULL, - tabSelected = NULL, - topLeftCell = NULL, + color_id = NULL, + default_grid_color = NULL, + right_to_left = NULL, + show_formulas = NULL, + show_grid_lines = NULL, + show_outline_symbols = NULL, + show_row_col_headers = NULL, + show_ruler = NULL, + show_white_space = NULL, + show_zeros = NULL, + tab_selected = NULL, + top_left_cell = NULL, view = NULL, - windowProtection = NULL, - workbookViewId = NULL, - zoomScale = NULL, - zoomScaleNormal = NULL, - zoomScalePageLayoutView = NULL, - zoomScaleSheetLayoutView = NULL + window_protection = NULL, + workbook_view_id = NULL, + zoom_scale = NULL, + zoom_scale_normal = NULL, + zoom_scale_page_layout_view = NULL, + zoom_scale_sheet_layout_view = NULL, + ... )}\if{html}{\out{
}} } \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{colorId}}{colorId} +\item{\code{color_id, default_grid_color}}{Integer: A color, default is 64} -\item{\code{defaultGridColor}}{defaultGridColor} +\item{\code{right_to_left}}{Logical: if TRUE column ordering is right to left} -\item{\code{rightToLeft}}{rightToLeft} +\item{\code{show_formulas}}{Logical: if TRUE cell formulas are shown} -\item{\code{showFormulas}}{showFormulas} +\item{\code{show_grid_lines}}{Logical: if TRUE the worksheet grid is shown} -\item{\code{showGridLines}}{showGridLines} +\item{\code{show_outline_symbols}}{Logical: if TRUE outline symbols are shown} -\item{\code{showOutlineSymbols}}{showOutlineSymbols} +\item{\code{show_row_col_headers}}{Logical: if TRUE row and column headers are shown} -\item{\code{showRowColHeaders}}{showRowColHeaders} +\item{\code{show_ruler}}{Logical: if TRUE a ruler is shown in page layout view} -\item{\code{showRuler}}{showRuler} +\item{\code{show_white_space}}{Logical: if TRUE margins are shown in page layout view} -\item{\code{showWhiteSpace}}{showWhiteSpace} +\item{\code{show_zeros}}{Logical: if FALSE cells containing zero are shown blank if !showFormulas} -\item{\code{showZeros}}{showZeros} +\item{\code{tab_selected}}{Integer: zero vector indicating the selected tab} -\item{\code{tabSelected}}{tabSelected} +\item{\code{top_left_cell}}{Cell: the cell shown in the top left corner / or top right with rightToLeft} -\item{\code{topLeftCell}}{topLeftCell} +\item{\code{view}}{View: "normal", "pageBreakPreview" or "pageLayout"} -\item{\code{view}}{view} +\item{\code{window_protection}}{Logical: if TRUE the panes are protected} -\item{\code{windowProtection}}{windowProtection} +\item{\code{workbook_view_id}}{integer: Pointing to some other view inside the workbook} -\item{\code{workbookViewId}}{workbookViewId} +\item{\code{zoom_scale, zoom_scale_normal, zoom_scale_page_layout_view, zoom_scale_sheet_layout_view}}{Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc.} -\item{\code{zoomScale}}{zoomScale} +\item{\code{...}}{additional arguments} -\item{\code{zoomScaleNormal}}{zoomScaleNormal} - -\item{\code{zoomScalePageLayoutView}}{zoomScalePageLayoutView} - -\item{\code{zoomScaleSheetLayoutView}}{zoomScaleSheetLayoutView} +\item{\code{sheet}}{sheet} } \if{html}{\out{
}} } diff --git a/man/wbComment.Rd b/man/wbComment.Rd deleted file mode 100644 index 04ccf8cc9..000000000 --- a/man/wbComment.Rd +++ /dev/null @@ -1,99 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-comment.R -\name{wbComment} -\alias{wbComment} -\title{R6 class for a Workbook Comments} -\value{ -The \code{wbComment} object, invisibly; called for its side effects -} -\description{ -R6 class for a Workbook Comments - -R6 class for a Workbook Comments -} -\details{ -A comment -} -\section{Public fields}{ -\if{html}{\out{
}} -\describe{ -\item{\code{text}}{Comment text} - -\item{\code{author}}{The comment author} - -\item{\code{style}}{A style for the comment} - -\item{\code{visible}}{\code{logical}, if \code{FALSE} is not visible} - -\item{\code{width}}{Width of the comment in ... units} - -\item{\code{height}}{Height of comment in ... units} -} -\if{html}{\out{
}} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-wbComment-new}{\code{wbComment$new()}} -\item \href{#method-wbComment-print}{\code{wbComment$print()}} -\item \href{#method-wbComment-clone}{\code{wbComment$clone()}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbComment-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new \code{wbComment} object -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbComment$new(text, author, style, visible = TRUE, width = 2, height = 4)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{text}}{Comment text} - -\item{\code{author}}{The comment author} - -\item{\code{style}}{A style for the comment} - -\item{\code{visible}}{\code{logical}, if \code{FALSE} is not visible} - -\item{\code{width}}{Width of the comment in ... units} - -\item{\code{height}}{Height of comment in ... units} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -a \code{wbComment} object -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbComment-print}{}}} -\subsection{Method \code{print()}}{ -Prints the object -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbComment$print()}\if{html}{\out{
}} -} - -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbComment-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbComment$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/wbHyperlink.Rd b/man/wbHyperlink.Rd deleted file mode 100644 index 523f4a4ed..000000000 --- a/man/wbHyperlink.Rd +++ /dev/null @@ -1,123 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-hyperlink.R -\name{wbHyperlink} -\alias{wbHyperlink} -\title{R6 class for a Workbook Hyperlink} -\value{ -A character vector of html if \code{is_external} is \code{TRUE}, otherwise \code{NULL} -} -\description{ -R6 class for a Workbook Hyperlink - -R6 class for a Workbook Hyperlink -} -\details{ -A hyperlink -} -\section{Public fields}{ -\if{html}{\out{
}} -\describe{ -\item{\code{ref}}{ref} - -\item{\code{target}}{target} - -\item{\code{location}}{location} - -\item{\code{display}}{display} - -\item{\code{is_external}}{is_external} -} -\if{html}{\out{
}} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-wbHyperlink-new}{\code{wbHyperlink$new()}} -\item \href{#method-wbHyperlink-to_xml}{\code{wbHyperlink$to_xml()}} -\item \href{#method-wbHyperlink-to_target_xml}{\code{wbHyperlink$to_target_xml()}} -\item \href{#method-wbHyperlink-clone}{\code{wbHyperlink$clone()}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbHyperlink-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new \code{wbHyperlink} object -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbHyperlink$new(ref, target, location, display = NULL, is_external = TRUE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{ref}}{ref} - -\item{\code{target}}{target} - -\item{\code{location}}{location} - -\item{\code{display}}{display} - -\item{\code{is_external}}{is_external} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -a \code{wbHyperlink} object -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbHyperlink-to_xml}{}}} -\subsection{Method \code{to_xml()}}{ -Convert to xml -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbHyperlink$to_xml(id)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{???} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -A character vector of xml -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbHyperlink-to_target_xml}{}}} -\subsection{Method \code{to_target_xml()}}{ -Convert to target xml -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbHyperlink$to_target_xml(id)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{id}}{???} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbHyperlink-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbHyperlink$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/wbSheetData.Rd b/man/wbSheetData.Rd deleted file mode 100644 index 1eba1e217..000000000 --- a/man/wbSheetData.Rd +++ /dev/null @@ -1,66 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-sheet-data.R -\name{wbSheetData} -\alias{wbSheetData} -\alias{wb_sheet_data} -\title{R6 class for a Workbook Hyperlink} -\usage{ -wb_sheet_data() -} -\description{ -R6 class for a Workbook Hyperlink - -R6 class for a Workbook Hyperlink -} -\details{ -A hyperlink -} -\section{Public fields}{ -\if{html}{\out{
}} -\describe{ -\item{\code{row_attr}}{row_attr} - -\item{\code{cc}}{cc} - -\item{\code{cc_out}}{cc_out} -} -\if{html}{\out{
}} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-wbSheetData-new}{\code{wbSheetData$new()}} -\item \href{#method-wbSheetData-clone}{\code{wbSheetData$clone()}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbSheetData-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new \code{wbSheetData} object -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbSheetData$new()}\if{html}{\out{
}} -} - -\subsection{Returns}{ -a \code{wbSheetData} object -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbSheetData-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbSheetData$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/wbWorkbook.Rd b/man/wbWorkbook.Rd index 715e9c2d5..d18961632 100644 --- a/man/wbWorkbook.Rd +++ b/man/wbWorkbook.Rd @@ -346,8 +346,9 @@ Creates a new \code{wbWorkbook} object title = NULL, subject = NULL, category = NULL, - datetimeCreated = Sys.time(), - theme = NULL + datetime_created = Sys.time(), + theme = NULL, + ... )}\if{html}{\out{}} } @@ -362,11 +363,13 @@ Creates a new \code{wbWorkbook} object \item{\code{category}}{category} -\item{\code{datetimeCreated}}{The datetime (as \code{POSIXt}) the workbook is +\item{\code{datetime_created}}{The datetime (as \code{POSIXt}) the workbook is created. Defaults to the current \code{Sys.time()} when the workbook object is created, not when the Excel files are saved.} \item{\code{theme}}{Optional theme identified by string or number} + +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -435,7 +438,7 @@ Add a chart sheet to the workbook \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$add_chartsheet( sheet = next_sheet(), - tabColor = NULL, + tab_color = NULL, zoom = 100, visible = c("true", "false", "hidden", "visible", "veryhidden"), ... @@ -447,7 +450,7 @@ Add a chart sheet to the workbook \describe{ \item{\code{sheet}}{sheet} -\item{\code{tabColor}}{tabColor} +\item{\code{tab_color}}{tab_color} \item{\code{zoom}}{zoom} @@ -469,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)), @@ -496,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} @@ -508,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} @@ -568,19 +571,20 @@ add data \if{html}{\out{
}}\preformatted{wbWorkbook$add_data( sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, array = FALSE, - colNames = TRUE, - rowNames = FALSE, - withFilter = FALSE, + col_names = TRUE, + row_names = FALSE, + with_filter = FALSE, name = NULL, sep = ", ", - applyCellStyle = TRUE, - removeCellStyle = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, na.strings = na_strings(), - inline_strings = TRUE + inline_strings = TRUE, + ... )}\if{html}{\out{
}} } @@ -591,33 +595,35 @@ add data \item{\code{x}}{x} -\item{\code{startCol}}{startCol} +\item{\code{dims}}{dims} -\item{\code{startRow}}{startRow} +\item{\code{start_col}}{startCol} -\item{\code{dims}}{dims} +\item{\code{start_row}}{startRow} \item{\code{array}}{array} -\item{\code{colNames}}{colNames} +\item{\code{col_names}}{colNames} -\item{\code{rowNames}}{rowNames} +\item{\code{row_names}}{rowNames} -\item{\code{withFilter}}{withFilter} +\item{\code{with_filter}}{withFilter} \item{\code{name}}{name} \item{\code{sep}}{sep} -\item{\code{applyCellStyle}}{applyCellStyle} +\item{\code{apply_cell_style}}{applyCellStyle} -\item{\code{removeCellStyle}}{if writing into existing cells, should the cell style be removed?} +\item{\code{remove_cell_style}}{if writing into existing cells, should the cell style be removed?} \item{\code{na.strings}}{Value used for replacing \code{NA} values from \code{x}. Default \code{na_strings()} uses the special \verb{#N/A} value within the workbook.} \item{\code{inline_strings}}{write characters as inline strings} +\item{\code{...}}{additional arguments} + \item{\code{return}}{The \code{wbWorkbook} object} } \if{html}{\out{
}} @@ -632,23 +638,24 @@ add a data table \if{html}{\out{
}}\preformatted{wbWorkbook$add_data_table( sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - colNames = TRUE, - rowNames = FALSE, - tableStyle = "TableStyleLight9", - tableName = NULL, - withFilter = TRUE, + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + col_names = TRUE, + row_names = FALSE, + table_style = "TableStyleLight9", + table_name = NULL, + with_filter = TRUE, sep = ", ", - firstColumn = FALSE, - lastColumn = FALSE, - bandedRows = TRUE, - bandedCols = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE, + first_column = FALSE, + last_column = FALSE, + banded_rows = TRUE, + banded_cols = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, na.strings = na_strings(), - inline_strings = TRUE + inline_strings = TRUE, + ... )}\if{html}{\out{
}} } @@ -659,40 +666,42 @@ add a data table \item{\code{x}}{x} -\item{\code{startCol}}{startCol} +\item{\code{dims}}{dims} -\item{\code{startRow}}{startRow} +\item{\code{start_col}}{startCol} -\item{\code{dims}}{dims} +\item{\code{start_row}}{startRow} -\item{\code{colNames}}{colNames} +\item{\code{col_names}}{colNames} -\item{\code{rowNames}}{rowNames} +\item{\code{row_names}}{rowNames} -\item{\code{tableStyle}}{tableStyle} +\item{\code{table_style}}{tableStyle} -\item{\code{tableName}}{tableName} +\item{\code{table_name}}{tableName} -\item{\code{withFilter}}{withFilter} +\item{\code{with_filter}}{withFilter} \item{\code{sep}}{sep} -\item{\code{firstColumn}}{firstColumn} +\item{\code{first_column}}{firstColumn} -\item{\code{lastColumn}}{lastColumn} +\item{\code{last_column}}{lastColumn} -\item{\code{bandedRows}}{bandedRows} +\item{\code{banded_rows}}{bandedRows} -\item{\code{bandedCols}}{bandedCols} +\item{\code{banded_cols}}{bandedCols} -\item{\code{applyCellStyle}}{applyCellStyle} +\item{\code{apply_cell_style}}{applyCellStyle} -\item{\code{removeCellStyle}}{if writing into existing cells, should the cell style be removed?} +\item{\code{remove_cell_style}}{if writing into existing cells, should the cell style be removed?} \item{\code{na.strings}}{Value used for replacing \code{NA} values from \code{x}. Default \code{na_strings()} uses the special \verb{#N/A} value within the workbook.} \item{\code{inline_strings}}{write characters as inline strings} + +\item{\code{...}}{additional arguments} } \if{html}{\out{
}} } @@ -749,13 +758,14 @@ add formula \if{html}{\out{
}}\preformatted{wbWorkbook$add_formula( sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, array = FALSE, cm = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE + apply_cell_style = TRUE, + remove_cell_style = FALSE, + ... )}\if{html}{\out{
}} } @@ -766,19 +776,21 @@ add formula \item{\code{x}}{x} -\item{\code{startCol}}{startCol} +\item{\code{dims}}{dims} -\item{\code{startRow}}{startRow} +\item{\code{start_col}}{startCol} -\item{\code{dims}}{dims} +\item{\code{start_row}}{startRow} \item{\code{array}}{array} \item{\code{cm}}{cm} -\item{\code{applyCellStyle}}{applyCellStyle} +\item{\code{apply_cell_style}}{applyCellStyle} -\item{\code{removeCellStyle}}{if writing into existing cells, should the cell style be removed?} +\item{\code{remove_cell_style}}{if writing into existing cells, should the cell style be removed?} + +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -810,26 +822,27 @@ to_df \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$to_df( sheet, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, - skipHiddenRows = FALSE, - skipHiddenCols = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, + skip_hidden_rows = FALSE, + skip_hidden_cols = FALSE, rows = NULL, cols = NULL, - detectDates = TRUE, + detect_dates = TRUE, na.strings = "#N/A", na.numbers = NA, - fillMergedCells = FALSE, + fill_merged_cells = FALSE, dims, - showFormula = FALSE, + show_formula = FALSE, convert = TRUE, types, named_region, - keep_attributes = FALSE + keep_attributes = FALSE, + ... )}\if{html}{\out{
}} } @@ -838,37 +851,37 @@ to_df \describe{ \item{\code{sheet}}{Either sheet name or index. When missing the first sheet in the workbook is selected.} -\item{\code{startRow}}{first row to begin looking for data.} +\item{\code{start_row}}{first row to begin looking for data.} -\item{\code{startCol}}{first column to begin looking for data.} +\item{\code{start_col}}{first column to begin looking for data.} -\item{\code{rowNames}}{If TRUE, the first col of data will be used as row names.} +\item{\code{row_names}}{If TRUE, the first col of data will be used as row names.} -\item{\code{colNames}}{If TRUE, the first row of data will be used as column names.} +\item{\code{col_names}}{If TRUE, the first row of data will be used as column names.} -\item{\code{skipEmptyRows}}{If TRUE, empty rows are skipped.} +\item{\code{skip_empty_rows}}{If TRUE, empty rows are skipped.} -\item{\code{skipEmptyCols}}{If TRUE, empty columns are skipped.} +\item{\code{skip_empty_cols}}{If TRUE, empty columns are skipped.} -\item{\code{skipHiddenRows}}{If TRUE, hidden rows are skipped.} +\item{\code{skip_hidden_rows}}{If TRUE, hidden rows are skipped.} -\item{\code{skipHiddenCols}}{If TRUE, hidden columns are skipped.} +\item{\code{skip_hidden_cols}}{If TRUE, hidden columns are skipped.} \item{\code{rows}}{A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.} \item{\code{cols}}{A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.} -\item{\code{detectDates}}{If TRUE, attempt to recognize dates and perform conversion.} +\item{\code{detect_dates}}{If TRUE, attempt to recognize dates and perform conversion.} \item{\code{na.strings}}{A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.} \item{\code{na.numbers}}{A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA.} -\item{\code{fillMergedCells}}{If TRUE, the value in a merged cell is given to all cells within the merge.} +\item{\code{fill_merged_cells}}{If TRUE, the value in a merged cell is given to all cells within the merge.} \item{\code{dims}}{Character string of type "A1:B2" as optional dimensions to be imported.} -\item{\code{showFormula}}{If TRUE, the underlying Excel formulas are shown.} +\item{\code{show_formula}}{If TRUE, the underlying Excel formulas are shown.} \item{\code{convert}}{If TRUE, a conversion to dates and numerics is attempted.} @@ -877,6 +890,8 @@ to_df \item{\code{named_region}}{Character string with a named_region (defined name or table). If no sheet is selected, the first appearance will be selected.} \item{\code{keep_attributes}}{If TRUE additional attributes are returned. (These are used internally to define a cell type.)} + +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -892,10 +907,11 @@ load workbook \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$load( file, - xlsxFile = NULL, + xlsx_file = NULL, sheet, data_only = FALSE, - calc_chain = FALSE + calc_chain = FALSE, + ... )}\if{html}{\out{
}} } @@ -904,13 +920,15 @@ load workbook \describe{ \item{\code{file}}{file} -\item{\code{xlsxFile}}{xlsxFile} +\item{\code{xlsx_file}}{xlsx_file} \item{\code{sheet}}{sheet} \item{\code{data_only}}{data_only} \item{\code{calc_chain}}{calc_chain} + +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -1098,9 +1116,9 @@ A list of of the font Get the base font \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$set_base_font( - fontSize = 11, - fontColor = wb_color(theme = "1"), - fontName = "Calibri", + font_size = 11, + font_color = wb_color(theme = "1"), + font_name = "Calibri", ... )}\if{html}{\out{
}} } @@ -1108,11 +1126,11 @@ Get the base font \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{fontSize}}{fontSize} +\item{\code{font_size}}{fontSize} -\item{\code{fontColor}}{fontColor} +\item{\code{font_color}}{font_color} -\item{\code{fontName}}{fontName} +\item{\code{font_name}}{font_name} \item{\code{...}}{...} } @@ -1129,50 +1147,53 @@ The \code{wbWorkbook} object Set the book views \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$set_bookview( - activeTab = NULL, - autoFilterDateGrouping = NULL, - firstSheet = NULL, + active_tab = NULL, + auto_filter_date_grouping = NULL, + first_sheet = NULL, minimized = NULL, - showHorizontalScroll = NULL, - showSheetTabs = NULL, - showVerticalScroll = NULL, - tabRatio = NULL, + show_horizontal_scroll = NULL, + show_sheet_tabs = NULL, + show_vertical_scroll = NULL, + tab_ratio = NULL, visibility = NULL, - windowHeight = NULL, - windowWidth = NULL, - xWindow = NULL, - yWindow = NULL + window_height = NULL, + window_width = NULL, + x_window = NULL, + y_window = NULL, + ... )}\if{html}{\out{
}} } \subsection{Arguments}{ \if{html}{\out{
}} \describe{ -\item{\code{activeTab}}{activeTab} +\item{\code{active_tab}}{activeTab} -\item{\code{autoFilterDateGrouping}}{autoFilterDateGrouping} +\item{\code{auto_filter_date_grouping}}{autoFilterDateGrouping} -\item{\code{firstSheet}}{firstSheet} +\item{\code{first_sheet}}{firstSheet} \item{\code{minimized}}{minimized} -\item{\code{showHorizontalScroll}}{showHorizontalScroll} +\item{\code{show_horizontal_scroll}}{showHorizontalScroll} -\item{\code{showSheetTabs}}{showSheetTabs} +\item{\code{show_sheet_tabs}}{showSheetTabs} -\item{\code{showVerticalScroll}}{showVerticalScroll} +\item{\code{show_vertical_scroll}}{showVerticalScroll} -\item{\code{tabRatio}}{tabRatio} +\item{\code{tab_ratio}}{tabRatio} \item{\code{visibility}}{visibility} -\item{\code{windowHeight}}{windowHeight} +\item{\code{window_height}}{windowHeight} -\item{\code{windowWidth}}{windowWidth} +\item{\code{window_width}}{windowWidth} -\item{\code{xWindow}}{xWindow} +\item{\code{x_window}}{xWindow} -\item{\code{yWindow}}{yWindow} +\item{\code{y_window}}{yWindow} + +\item{\code{...}}{additional arguments} } \if{html}{\out{
}} } @@ -1474,19 +1495,19 @@ Adds data validation \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$add_data_validation( sheet = current_sheet(), - cols, - rows, + dims = "A1", type, operator, value, - allowBlank = TRUE, - showInputMsg = TRUE, - showErrorMsg = TRUE, - errorStyle = NULL, - errorTitle = NULL, + allow_blank = TRUE, + show_input_msg = TRUE, + show_error_msg = TRUE, + error_style = NULL, + error_title = NULL, error = NULL, - promptTitle = NULL, - prompt = NULL + prompt_title = NULL, + prompt = NULL, + ... )}\if{html}{\out{
}} } @@ -1495,9 +1516,7 @@ Adds data validation \describe{ \item{\code{sheet}}{sheet} -\item{\code{cols}}{cols} - -\item{\code{rows}}{rows} +\item{\code{dims}}{cell dimension} \item{\code{type}}{type} @@ -1505,21 +1524,23 @@ Adds data validation \item{\code{value}}{value} -\item{\code{allowBlank}}{allowBlank} +\item{\code{allow_blank}}{allowBlank} -\item{\code{showInputMsg}}{showInputMsg} +\item{\code{show_input_msg}}{showInputMsg} -\item{\code{showErrorMsg}}{showErrorMsg} +\item{\code{show_error_msg}}{showErrorMsg} -\item{\code{errorStyle}}{The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input)} +\item{\code{error_style}}{The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input)} -\item{\code{errorTitle}}{The error title} +\item{\code{error_title}}{The error title} \item{\code{error}}{The error text} -\item{\code{promptTitle}}{The prompt title} +\item{\code{prompt_title}}{The prompt title} \item{\code{prompt}}{The prompt text} + +\item{\code{...}}{additional arguments} } \if{html}{\out{
}} } @@ -1608,13 +1629,7 @@ The \code{wbWorkbook} object, invisibly \subsection{Method \code{add_comment()}}{ Add comment \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorkbook$add_comment( - sheet = current_sheet(), - col = NULL, - row = NULL, - dims = rowcol_to_dim(row, col), - comment -)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{wbWorkbook$add_comment(sheet = current_sheet(), dims = "A1", comment, ...)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -1622,13 +1637,11 @@ Add comment \describe{ \item{\code{sheet}}{sheet} -\item{\code{col}}{column to apply the comment} - -\item{\code{row}}{row to apply the comment} - \item{\code{dims}}{row and column as spreadsheet dimension, e.g. "A1"} \item{\code{comment}}{a comment to apply to the worksheet} + +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -1639,13 +1652,7 @@ Add comment \subsection{Method \code{remove_comment()}}{ Remove comment \subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorkbook$remove_comment( - sheet = current_sheet(), - col = NULL, - row = NULL, - dims = rowcol_to_dims(row, col), - gridExpand = TRUE -)}\if{html}{\out{
}} +\if{html}{\out{
}}\preformatted{wbWorkbook$remove_comment(sheet = current_sheet(), dims = "A1", ...)}\if{html}{\out{
}} } \subsection{Arguments}{ @@ -1653,13 +1660,9 @@ Remove comment \describe{ \item{\code{sheet}}{sheet} -\item{\code{col}}{column to apply the comment} - -\item{\code{row}}{row to apply the comment} - \item{\code{dims}}{row and column as spreadsheet dimension, e.g. "A1"} -\item{\code{gridExpand}}{Remove all comments inside the grid. Similar to dims "A1:B2"} +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -1716,16 +1719,15 @@ Insert an image into a sheet \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$add_image( sheet = current_sheet(), + dims = "A1", file, width = 6, height = 3, - startRow = 1, - startCol = 1, - rowOffset = 0, - colOffset = 0, + row_offset = 0, + col_offset = 0, units = "in", dpi = 300, - dims = rowcol_to_dim(startRow, startCol) + ... )}\if{html}{\out{
}} } @@ -1734,25 +1736,21 @@ Insert an image into a sheet \describe{ \item{\code{sheet}}{sheet} +\item{\code{dims}}{dims} + \item{\code{file}}{file} \item{\code{width}}{width} \item{\code{height}}{height} -\item{\code{startRow}}{startRow} - -\item{\code{startCol}}{startCol} - -\item{\code{rowOffset}}{rowOffset} - -\item{\code{colOffset}}{colOffset} +\item{\code{row_offset, col_offset}}{offsets} \item{\code{units}}{units} \item{\code{dpi}}{dpi} -\item{\code{dims}}{dims} +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -1768,16 +1766,15 @@ Add plot. A wrapper for add_image() \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$add_plot( sheet = current_sheet(), + dims = "A1", width = 6, height = 4, - startRow = 1, - startCol = 1, - rowOffset = 0, - colOffset = 0, - fileType = "png", + row_offset = 0, + col_offset = 0, + file_type = "png", units = "in", dpi = 300, - dims = rowcol_to_dim(startRow, startCol) + ... )}\if{html}{\out{
}} } @@ -1786,25 +1783,21 @@ Add plot. A wrapper for add_image() \describe{ \item{\code{sheet}}{sheet} +\item{\code{dims}}{dims} + \item{\code{width}}{width} \item{\code{height}}{height} -\item{\code{startRow}}{startRow} - -\item{\code{startCol}}{startCol} - -\item{\code{rowOffset}}{rowOffset} +\item{\code{row_offset, col_offset}}{offsets} -\item{\code{colOffset}}{colOffset} - -\item{\code{fileType}}{fileType} +\item{\code{file_type}}{fileType} \item{\code{units}}{units} \item{\code{dpi}}{dpi} -\item{\code{dims}}{dims} +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -1817,10 +1810,11 @@ Add xml drawing \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$add_drawing( sheet = current_sheet(), + dims = "A1", xml, - dims = NULL, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... )}\if{html}{\out{
}} } @@ -1829,11 +1823,13 @@ Add xml drawing \describe{ \item{\code{sheet}}{sheet} +\item{\code{dims}}{dims} + \item{\code{xml}}{xml} -\item{\code{dims}}{dims} +\item{\code{col_offset, row_offset}}{offsets for column and row} -\item{\code{colOffset, rowOffset}}{offsets for column and row} +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -1849,10 +1845,11 @@ Add xml chart \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$add_chart_xml( sheet = current_sheet(), - xml, dims = NULL, - colOffset = 0, - rowOffset = 0 + xml, + col_offset = 0, + row_offset = 0, + ... )}\if{html}{\out{
}} } @@ -1861,11 +1858,13 @@ Add xml chart \describe{ \item{\code{sheet}}{sheet} +\item{\code{dims}}{dims} + \item{\code{xml}}{xml} -\item{\code{dims}}{dims} +\item{\code{col_offset, row_offset}}{positioning parameters} -\item{\code{colOffset, rowOffset}}{startCol and startRow} +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -1880,8 +1879,9 @@ Add mschart chart to the workbook sheet = current_sheet(), dims = NULL, graph, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... )}\if{html}{\out{}} } @@ -1894,7 +1894,9 @@ Add mschart chart to the workbook \item{\code{graph}}{mschart graph} -\item{\code{colOffset, rowOffset}}{startCol and startRow} +\item{\code{col_offset, row_offset}}{offsets for column and row} + +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -2179,10 +2181,11 @@ Sets headers and footers sheet = current_sheet(), header = NULL, footer = NULL, - evenHeader = NULL, - evenFooter = NULL, - firstHeader = NULL, - firstFooter = NULL + even_header = NULL, + even_footer = NULL, + first_header = NULL, + first_footer = NULL, + ... )}\if{html}{\out{}} } @@ -2195,13 +2198,15 @@ Sets headers and footers \item{\code{footer}}{footer} -\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{...}}{additional arguments} } \if{html}{\out{}} } @@ -2315,24 +2320,23 @@ add a named region \if{html}{\out{
}}\preformatted{wbWorkbook$add_named_region( sheet = current_sheet(), dims = "A1", - cols, - rows, name, - localSheet = FALSE, + local_sheet = FALSE, overwrite = FALSE, comment = NULL, - customMenu = NULL, + custom_menu = NULL, description = NULL, is_function = NULL, - functionGroupId = NULL, + function_group_id = NULL, help = NULL, hidden = NULL, - localName = NULL, - publishToServer = NULL, - statusBar = NULL, - vbProcedure = NULL, - workbookParameter = NULL, - xml = NULL + local_name = NULL, + publish_to_server = NULL, + status_bar = NULL, + vb_procedure = NULL, + workbook_parameter = NULL, + xml = NULL, + ... )}\if{html}{\out{
}} } @@ -2343,41 +2347,39 @@ add a named region \item{\code{dims}}{dims} -\item{\code{cols}}{cols} - -\item{\code{rows}}{rows} - \item{\code{name}}{name} -\item{\code{localSheet}}{localSheet} +\item{\code{local_sheet}}{local_sheet} \item{\code{overwrite}}{overwrite} \item{\code{comment}}{comment} -\item{\code{customMenu}}{customMenu} +\item{\code{custom_menu}}{custom_menu} \item{\code{description}}{description} \item{\code{is_function}}{function} -\item{\code{functionGroupId}}{function group id} +\item{\code{function_group_id}}{function group id} \item{\code{help}}{help} \item{\code{hidden}}{hidden} -\item{\code{localName}}{localName} +\item{\code{local_name}}{localName} -\item{\code{publishToServer}}{publish to server} +\item{\code{publish_to_server}}{publish to server} -\item{\code{statusBar}}{status bar} +\item{\code{status_bar}}{status bar} -\item{\code{vbProcedure}}{wbProcedure} +\item{\code{vb_procedure}}{vb procedure} -\item{\code{workbookParameter}}{workbookParameter} +\item{\code{workbook_parameter}}{workbookParameter} \item{\code{xml}}{xml} + +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -2665,7 +2667,7 @@ provide simple font function family = "", scheme = "", shadow = "", - vertAlign = "", + vert_align = "", ... )}\if{html}{\out{}} } @@ -2705,7 +2707,7 @@ provide simple font function \item{\code{shadow}}{shadow} -\item{\code{vertAlign}}{vertical alignment} +\item{\code{vert_align}}{vertical alignment} \item{\code{...}}{...} } @@ -2766,31 +2768,32 @@ provide simple cell style format function \if{html}{\out{
}}\preformatted{wbWorkbook$add_cell_style( sheet = current_sheet(), dims = "A1", - applyAlignment = NULL, - applyBorder = NULL, - applyFill = NULL, - applyFont = NULL, - applyNumberFormat = NULL, - applyProtection = NULL, - borderId = NULL, - extLst = NULL, - fillId = NULL, - fontId = NULL, + apply_alignment = NULL, + apply_border = NULL, + apply_fill = NULL, + apply_font = NULL, + apply_number_format = NULL, + apply_protection = NULL, + border_id = NULL, + ext_lst = NULL, + fill_id = NULL, + font_id = NULL, hidden = NULL, horizontal = NULL, indent = NULL, - justifyLastLine = NULL, + justify_last_line = NULL, locked = NULL, - numFmtId = NULL, - pivotButton = NULL, - quotePrefix = NULL, - readingOrder = NULL, - relativeIndent = NULL, - shrinkToFit = NULL, - textRotation = NULL, + num_fmt_id = NULL, + pivot_button = NULL, + quote_prefix = NULL, + reading_order = NULL, + relative_indent = NULL, + shrink_to_fit = NULL, + text_rotation = NULL, vertical = NULL, - wrapText = NULL, - xfId = NULL + wrap_text = NULL, + xf_id = NULL, + ... )}\if{html}{\out{
}} } @@ -2801,25 +2804,25 @@ provide simple cell style format function \item{\code{dims}}{the cell range} -\item{\code{applyAlignment}}{logical apply alignment} +\item{\code{apply_alignment}}{logical apply alignment} -\item{\code{applyBorder}}{logical apply border} +\item{\code{apply_border}}{logical apply border} -\item{\code{applyFill}}{logical apply fill} +\item{\code{apply_fill}}{logical apply fill} -\item{\code{applyFont}}{logical apply font} +\item{\code{apply_font}}{logical apply font} -\item{\code{applyNumberFormat}}{logical apply number format} +\item{\code{apply_number_format}}{logical apply number format} -\item{\code{applyProtection}}{logical apply protection} +\item{\code{apply_protection}}{logical apply protection} -\item{\code{borderId}}{border ID to apply} +\item{\code{border_id}}{border ID to apply} -\item{\code{extLst}}{extension list something like \verb{...}} +\item{\code{ext_lst}}{extension list something like \verb{...}} -\item{\code{fillId}}{fill ID to apply} +\item{\code{fill_id}}{fill ID to apply} -\item{\code{fontId}}{font ID to apply} +\item{\code{font_id}}{font ID to apply} \item{\code{hidden}}{logical cell is hidden} @@ -2827,29 +2830,31 @@ provide simple cell style format function \item{\code{indent}}{logical indent content} -\item{\code{justifyLastLine}}{logical justify last line} +\item{\code{justify_last_line}}{logical justify last line} \item{\code{locked}}{logical cell is locked} -\item{\code{numFmtId}}{number format ID to apply} +\item{\code{num_fmt_id}}{number format ID to apply} -\item{\code{pivotButton}}{unknown} +\item{\code{pivot_button}}{unknown} -\item{\code{quotePrefix}}{unknown} +\item{\code{quote_prefix}}{unknown} -\item{\code{readingOrder}}{reading order left to right} +\item{\code{reading_order}}{reading order left to right} -\item{\code{relativeIndent}}{relative indentation} +\item{\code{relative_indent}}{relative indentation} -\item{\code{shrinkToFit}}{logical shrink to fit} +\item{\code{shrink_to_fit}}{logical shrink to fit} -\item{\code{textRotation}}{degrees of text rotation} +\item{\code{text_rotation}}{degrees of text rotation} \item{\code{vertical}}{vertical alignment of content ('top', 'center', 'bottom')} -\item{\code{wrapText}}{wrap text in cell} +\item{\code{wrap_text}}{wrap text in cell} + +\item{\code{xf_id}}{xf ID to apply} -\item{\code{xfId}}{xf ID to apply} +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -2957,12 +2962,12 @@ These styles are used with conditional formatting and custom table styles font_name = NULL, font_size = NULL, font_color = NULL, - numFmt = NULL, + num_fmt = NULL, border = NULL, border_color = wb_color(getOption("openxlsx2.borderColor", "black")), border_style = getOption("openxlsx2.borderStyle", "thin"), - bgFill = NULL, - gradientFill = NULL, + bg_fill = NULL, + gradient_fill = NULL, text_bold = NULL, text_italic = NULL, text_underline = NULL, @@ -2981,7 +2986,7 @@ These styles are used with conditional formatting and custom table styles \item{\code{font_color}}{the font color (a \code{wb_color()} object)} -\item{\code{numFmt}}{the number format} +\item{\code{num_fmt}}{the number format} \item{\code{border}}{logical if borders are applied} @@ -2989,9 +2994,9 @@ These styles are used with conditional formatting and custom table styles \item{\code{border_style}}{the border style} -\item{\code{bgFill}}{any background fill} +\item{\code{bg_fill}}{any background fill} -\item{\code{gradientFill}}{any gradient fill} +\item{\code{gradient_fill}}{any gradient fill} \item{\code{text_bold}}{logical if text is bold} @@ -3054,15 +3059,16 @@ Ignore error on worksheet \if{html}{\out{
}}\preformatted{wbWorkbook$add_ignore_error( sheet = current_sheet(), dims = "A1", - calculatedColumn = FALSE, - emptyCellReference = FALSE, - evalError = FALSE, + calculated_column = FALSE, + empty_cell_reference = FALSE, + eval_error = FALSE, formula = FALSE, - formulaRange = FALSE, - listDataValidation = FALSE, - numberStoredAsText = FALSE, - twoDigitTextYear = FALSE, - unlockedFormula = FALSE + formula_range = FALSE, + list_data_validation = FALSE, + number_stored_as_text = FALSE, + two_digit_text_year = FALSE, + unlocked_formula = FALSE, + ... )}\if{html}{\out{
}} } @@ -3073,23 +3079,25 @@ Ignore error on worksheet \item{\code{dims}}{dims} -\item{\code{calculatedColumn}}{calculatedColumn} +\item{\code{calculated_column}}{calculatedColumn} -\item{\code{emptyCellReference}}{emptyCellReference} +\item{\code{empty_cell_reference}}{emptyCellReference} -\item{\code{evalError}}{evalError} +\item{\code{eval_error}}{evalError} \item{\code{formula}}{formula} -\item{\code{formulaRange}}{formulaRange} +\item{\code{formula_range}}{formulaRange} -\item{\code{listDataValidation}}{listDataValidation} +\item{\code{list_data_validation}}{listDataValidation} -\item{\code{numberStoredAsText}}{numberStoredAsText} +\item{\code{number_stored_as_text}}{numberStoredAsText} -\item{\code{twoDigitTextYear}}{twoDigitTextYear} +\item{\code{two_digit_text_year}}{twoDigitTextYear} -\item{\code{unlockedFormula}}{unlockedFormula} +\item{\code{unlocked_formula}}{unlockedFormula} + +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } @@ -3102,25 +3110,26 @@ add sheetview \subsection{Usage}{ \if{html}{\out{
}}\preformatted{wbWorkbook$set_sheetview( sheet = current_sheet(), - colorId = NULL, - defaultGridColor = NULL, - rightToLeft = NULL, - showFormulas = NULL, - showGridLines = NULL, - showOutlineSymbols = NULL, - showRowColHeaders = NULL, - showRuler = NULL, - showWhiteSpace = NULL, - showZeros = NULL, - tabSelected = NULL, - topLeftCell = NULL, + color_id = NULL, + default_grid_color = NULL, + right_to_left = NULL, + show_formulas = NULL, + show_grid_lines = NULL, + show_outline_symbols = NULL, + show_row_col_headers = NULL, + show_ruler = NULL, + show_white_space = NULL, + show_zeros = NULL, + tab_selected = NULL, + top_left_cell = NULL, view = NULL, - windowProtection = NULL, - workbookViewId = NULL, - zoomScale = NULL, - zoomScaleNormal = NULL, - zoomScalePageLayoutView = NULL, - zoomScaleSheetLayoutView = NULL + window_protection = NULL, + workbook_view_id = NULL, + zoom_scale = NULL, + zoom_scale_normal = NULL, + zoom_scale_page_layout_view = NULL, + zoom_scale_sheet_layout_view = NULL, + ... )}\if{html}{\out{
}} } @@ -3129,43 +3138,37 @@ add sheetview \describe{ \item{\code{sheet}}{sheet} -\item{\code{colorId}}{colorId} - -\item{\code{defaultGridColor}}{defaultGridColor} - -\item{\code{rightToLeft}}{rightToLeft} - -\item{\code{showFormulas}}{showFormulas} +\item{\code{color_id, default_grid_color}}{Integer: A color, default is 64} -\item{\code{showGridLines}}{showGridLines} +\item{\code{right_to_left}}{Logical: if TRUE column ordering is right to left} -\item{\code{showOutlineSymbols}}{showOutlineSymbols} +\item{\code{show_formulas}}{Logical: if TRUE cell formulas are shown} -\item{\code{showRowColHeaders}}{showRowColHeaders} +\item{\code{show_grid_lines}}{Logical: if TRUE the worksheet grid is shown} -\item{\code{showRuler}}{showRuler} +\item{\code{show_outline_symbols}}{Logical: if TRUE outline symbols are shown} -\item{\code{showWhiteSpace}}{showWhiteSpace} +\item{\code{show_row_col_headers}}{Logical: if TRUE row and column headers are shown} -\item{\code{showZeros}}{showZeros} +\item{\code{show_ruler}}{Logical: if TRUE a ruler is shown in page layout view} -\item{\code{tabSelected}}{tabSelected} +\item{\code{show_white_space}}{Logical: if TRUE margins are shown in page layout view} -\item{\code{topLeftCell}}{topLeftCell} +\item{\code{show_zeros}}{Logical: if FALSE cells containing zero are shown blank if !showFormulas} -\item{\code{view}}{view} +\item{\code{tab_selected}}{Integer: zero vector indicating the selected tab} -\item{\code{windowProtection}}{windowProtection} +\item{\code{top_left_cell}}{Cell: the cell shown in the top left corner / or top right with rightToLeft} -\item{\code{workbookViewId}}{workbookViewId} +\item{\code{view}}{View: "normal", "pageBreakPreview" or "pageLayout"} -\item{\code{zoomScale}}{zoomScale} +\item{\code{window_protection}}{Logical: if TRUE the panes are protected} -\item{\code{zoomScaleNormal}}{zoomScaleNormal} +\item{\code{workbook_view_id}}{integer: Pointing to some other view inside the workbook} -\item{\code{zoomScalePageLayoutView}}{zoomScalePageLayoutView} +\item{\code{zoom_scale, zoom_scale_normal, zoom_scale_page_layout_view, zoom_scale_sheet_layout_view}}{Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc.} -\item{\code{zoomScaleSheetLayoutView}}{zoomScaleSheetLayoutView} +\item{\code{...}}{additional arguments} } \if{html}{\out{}} } diff --git a/man/wbWorksheet.Rd b/man/wbWorksheet.Rd deleted file mode 100644 index 74914bced..000000000 --- a/man/wbWorksheet.Rd +++ /dev/null @@ -1,555 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-worksheet.R -\name{wbWorksheet} -\alias{wbWorksheet} -\title{R6 class for a Workbook Worksheet} -\value{ -The \code{wbWorksheet} object - -The \code{wbWorksheet} object -} -\description{ -R6 class for a Workbook Worksheet - -R6 class for a Workbook Worksheet -} -\details{ -A Worksheet -} -\section{Public fields}{ -\if{html}{\out{
}} -\describe{ -\item{\code{sheetPr}}{sheetPr} - -\item{\code{dimension}}{dimension} - -\item{\code{sheetViews}}{sheetViews} - -\item{\code{sheetFormatPr}}{sheetFormatPr} - -\item{\code{sheet_data}}{sheet_data} - -\item{\code{cols_attr}}{cols_attr} - -\item{\code{autoFilter}}{autoFilter} - -\item{\code{mergeCells}}{mergeCells} - -\item{\code{conditionalFormatting}}{conditionalFormatting} - -\item{\code{dataValidations}}{dataValidations} - -\item{\code{freezePane}}{freezePane} - -\item{\code{hyperlinks}}{hyperlinks} - -\item{\code{sheetProtection}}{sheetProtection} - -\item{\code{pageMargins}}{pageMargins} - -\item{\code{pageSetup}}{pageSetup} - -\item{\code{headerFooter}}{headerFooter} - -\item{\code{rowBreaks}}{rowBreaks} - -\item{\code{colBreaks}}{colBreaks} - -\item{\code{drawing}}{drawing} - -\item{\code{legacyDrawing}}{legacyDrawing} - -\item{\code{legacyDrawingHF}}{legacyDrawingHF} - -\item{\code{oleObjects}}{oleObjects} - -\item{\code{tableParts}}{tableParts} - -\item{\code{extLst}}{extLst} - -\item{\code{cellWatches}}{cellWatches} - -\item{\code{controls}}{controls} - -\item{\code{customProperties}}{customProperties} - -\item{\code{customSheetViews}}{customSheetViews} - -\item{\code{dataConsolidate}}{dataConsolidate} - -\item{\code{drawingHF}}{drawingHF} - -\item{\code{relships}}{relships} - -\item{\code{ignoredErrors}}{ignoredErrors} - -\item{\code{phoneticPr}}{phoneticPr} - -\item{\code{picture}}{picture} - -\item{\code{printOptions}}{printOptions} - -\item{\code{protectedRanges}}{protectedRanges} - -\item{\code{scenarios}}{scenarios} - -\item{\code{sheetCalcPr}}{sheetCalcPr} - -\item{\code{smartTags}}{smartTags} - -\item{\code{sortState}}{sortState} - -\item{\code{webPublishItems}}{webPublishItems} -} -\if{html}{\out{
}} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-wbWorksheet-new}{\code{wbWorksheet$new()}} -\item \href{#method-wbWorksheet-get_prior_sheet_data}{\code{wbWorksheet$get_prior_sheet_data()}} -\item \href{#method-wbWorksheet-get_post_sheet_data}{\code{wbWorksheet$get_post_sheet_data()}} -\item \href{#method-wbWorksheet-unfold_cols}{\code{wbWorksheet$unfold_cols()}} -\item \href{#method-wbWorksheet-fold_cols}{\code{wbWorksheet$fold_cols()}} -\item \href{#method-wbWorksheet-merge_cells}{\code{wbWorksheet$merge_cells()}} -\item \href{#method-wbWorksheet-unmerge_cells}{\code{wbWorksheet$unmerge_cells()}} -\item \href{#method-wbWorksheet-clean_sheet}{\code{wbWorksheet$clean_sheet()}} -\item \href{#method-wbWorksheet-add_page_break}{\code{wbWorksheet$add_page_break()}} -\item \href{#method-wbWorksheet-set_print_options}{\code{wbWorksheet$set_print_options()}} -\item \href{#method-wbWorksheet-append}{\code{wbWorksheet$append()}} -\item \href{#method-wbWorksheet-add_sparklines}{\code{wbWorksheet$add_sparklines()}} -\item \href{#method-wbWorksheet-set_sheetview}{\code{wbWorksheet$set_sheetview()}} -\item \href{#method-wbWorksheet-ignore_error}{\code{wbWorksheet$ignore_error()}} -\item \href{#method-wbWorksheet-clone}{\code{wbWorksheet$clone()}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-new}{}}} -\subsection{Method \code{new()}}{ -Creates a new \code{wbWorksheet} object -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$new( - tabColor = NULL, - oddHeader = NULL, - oddFooter = NULL, - evenHeader = NULL, - evenFooter = NULL, - firstHeader = NULL, - firstFooter = NULL, - paperSize = 9, - orientation = "portrait", - hdpi = 300, - vdpi = 300, - printGridLines = FALSE -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{tabColor}}{tabColor} - -\item{\code{oddHeader}}{oddHeader} - -\item{\code{oddFooter}}{oddFooter} - -\item{\code{evenHeader}}{evenHeader} - -\item{\code{evenFooter}}{evenFooter} - -\item{\code{firstHeader}}{firstHeader} - -\item{\code{firstFooter}}{firstFooter} - -\item{\code{paperSize}}{paperSize} - -\item{\code{orientation}}{orientation} - -\item{\code{hdpi}}{hdpi} - -\item{\code{vdpi}}{vdpi} - -\item{\code{printGridLines}}{printGridLines} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -a \code{wbWorksheet} object -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-get_prior_sheet_data}{}}} -\subsection{Method \code{get_prior_sheet_data()}}{ -Get prior sheet data -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$get_prior_sheet_data()}\if{html}{\out{
}} -} - -\subsection{Returns}{ -A character vector of xml -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-get_post_sheet_data}{}}} -\subsection{Method \code{get_post_sheet_data()}}{ -Get post sheet data -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$get_post_sheet_data()}\if{html}{\out{
}} -} - -\subsection{Returns}{ -A character vector of xml -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-unfold_cols}{}}} -\subsection{Method \code{unfold_cols()}}{ -unfold \verb{} node to dataframe. \verb{} are compressed. -Only columns with attributes are written to the file. This function -unfolds them so that each cell beginning with the "A" to the last one -found in cc gets a value. -TODO might extend this to match either largest cc or largest col. Could -be that "Z" is formatted, but the last value is written to "Y". -TODO might replace the xml nodes with the data frame? -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$unfold_cols()}\if{html}{\out{
}} -} - -\subsection{Returns}{ -The column data frame -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-fold_cols}{}}} -\subsection{Method \code{fold_cols()}}{ -fold the column dataframe back into a node. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$fold_cols(col_df)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{col_df}}{the column data frame} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -The \code{wbWorksheetObject}, invisibly -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-merge_cells}{}}} -\subsection{Method \code{merge_cells()}}{ -Set cell merging for a sheet -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$merge_cells(rows = NULL, cols = NULL)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{rows, cols}}{Row and column specifications.} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -The \code{wbWorkbook} object, invisibly -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-unmerge_cells}{}}} -\subsection{Method \code{unmerge_cells()}}{ -Removes cell merging for a sheet -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$unmerge_cells(rows = NULL, cols = NULL)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{rows, cols}}{Row and column specifications.} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -The \code{wbWorkbook} object, invisibly -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-clean_sheet}{}}} -\subsection{Method \code{clean_sheet()}}{ -clean sheet (remove all values) -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$clean_sheet( - dims = NULL, - numbers = TRUE, - characters = TRUE, - styles = TRUE, - merged_cells = TRUE -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{dims}}{dimensions} - -\item{\code{numbers}}{remove all numbers} - -\item{\code{characters}}{remove all characters} - -\item{\code{styles}}{remove all styles} - -\item{\code{merged_cells}}{remove all merged_cells} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -The \code{wbWorksheetObject}, invisibly -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-add_page_break}{}}} -\subsection{Method \code{add_page_break()}}{ -add page break -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$add_page_break(row = NULL, col = NULL)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{row}}{row} - -\item{\code{col}}{col} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-set_print_options}{}}} -\subsection{Method \code{set_print_options()}}{ -add print options -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$set_print_options( - gridLines = NULL, - gridLinesSet = NULL, - headings = NULL, - horizontalCentered = NULL, - verticalCentered = NULL -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{gridLines}}{gridLines} - -\item{\code{gridLinesSet}}{gridLinesSet} - -\item{\code{headings}}{If TRUE prints row and column headings} - -\item{\code{horizontalCentered}}{If TRUE the page is horizontally centered} - -\item{\code{verticalCentered}}{If TRUE the page is vertically centered} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-append}{}}} -\subsection{Method \code{append()}}{ -append a field. Intended for internal use only. Not -guaranteed to remain a public method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$append(field, value = NULL)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{field}}{a field name} - -\item{\code{value}}{a new value} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -The \code{wbWorksheetObject}, invisibly -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-add_sparklines}{}}} -\subsection{Method \code{add_sparklines()}}{ -add sparkline -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$add_sparklines(sparklines)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{sparklines}}{sparkline created by \code{create_sparkline()}} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -The \code{wbWorksheetObject}, invisibly -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-set_sheetview}{}}} -\subsection{Method \code{set_sheetview()}}{ -add sheetview -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$set_sheetview( - colorId = NULL, - defaultGridColor = NULL, - rightToLeft = NULL, - showFormulas = NULL, - showGridLines = NULL, - showOutlineSymbols = NULL, - showRowColHeaders = NULL, - showRuler = NULL, - showWhiteSpace = NULL, - showZeros = NULL, - tabSelected = NULL, - topLeftCell = NULL, - view = NULL, - windowProtection = NULL, - workbookViewId = NULL, - zoomScale = NULL, - zoomScaleNormal = NULL, - zoomScalePageLayoutView = NULL, - zoomScaleSheetLayoutView = NULL -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{colorId}}{colorId} - -\item{\code{defaultGridColor}}{defaultGridColor} - -\item{\code{rightToLeft}}{rightToLeft} - -\item{\code{showFormulas}}{showFormulas} - -\item{\code{showGridLines}}{showGridLines} - -\item{\code{showOutlineSymbols}}{showOutlineSymbols} - -\item{\code{showRowColHeaders}}{showRowColHeaders} - -\item{\code{showRuler}}{showRuler} - -\item{\code{showWhiteSpace}}{showWhiteSpace} - -\item{\code{showZeros}}{showZeros} - -\item{\code{tabSelected}}{tabSelected} - -\item{\code{topLeftCell}}{topLeftCell} - -\item{\code{view}}{view} - -\item{\code{windowProtection}}{windowProtection} - -\item{\code{workbookViewId}}{workbookViewId} - -\item{\code{zoomScale}}{zoomScale} - -\item{\code{zoomScaleNormal}}{zoomScaleNormal} - -\item{\code{zoomScalePageLayoutView}}{zoomScalePageLayoutView} - -\item{\code{zoomScaleSheetLayoutView}}{zoomScaleSheetLayoutView} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -The \code{wbWorksheetObject}, invisibly -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-ignore_error}{}}} -\subsection{Method \code{ignore_error()}}{ -Ignore error on worksheet -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$ignore_error( - dims = "A1", - calculatedColumn = FALSE, - emptyCellReference = FALSE, - evalError = FALSE, - formula = FALSE, - formulaRange = FALSE, - listDataValidation = FALSE, - numberStoredAsText = FALSE, - twoDigitTextYear = FALSE, - unlockedFormula = FALSE -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{dims}}{dims} - -\item{\code{calculatedColumn}}{calculatedColumn} - -\item{\code{emptyCellReference}}{emptyCellReference} - -\item{\code{evalError}}{evalError} - -\item{\code{formula}}{formula} - -\item{\code{formulaRange}}{formulaRange} - -\item{\code{listDataValidation}}{listDataValidation} - -\item{\code{numberStoredAsText}}{numberStoredAsText} - -\item{\code{twoDigitTextYear}}{twoDigitTextYear} - -\item{\code{unlockedFormula}}{unlockedFormula} -} -\if{html}{\out{
}} -} -\subsection{Returns}{ -The \code{wbWorksheetObject}, invisibly -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-wbWorksheet-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{wbWorksheet$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -} diff --git a/man/wb_add_cell_style.Rd b/man/wb_add_cell_style.Rd index 8fe4e5cce..4e7f74c4b 100644 --- a/man/wb_add_cell_style.Rd +++ b/man/wb_add_cell_style.Rd @@ -8,31 +8,32 @@ wb_add_cell_style( wb, sheet = current_sheet(), dims = "A1", - applyAlignment = NULL, - applyBorder = NULL, - applyFill = NULL, - applyFont = NULL, - applyNumberFormat = NULL, - applyProtection = NULL, - borderId = NULL, - extLst = NULL, - fillId = NULL, - fontId = NULL, + apply_alignment = NULL, + apply_border = NULL, + apply_fill = NULL, + apply_font = NULL, + apply_number_format = NULL, + apply_protection = NULL, + border_id = NULL, + ext_lst = NULL, + fill_id = NULL, + font_id = NULL, hidden = NULL, horizontal = NULL, indent = NULL, - justifyLastLine = NULL, + justify_last_line = NULL, locked = NULL, - numFmtId = NULL, - pivotButton = NULL, - quotePrefix = NULL, - readingOrder = NULL, - relativeIndent = NULL, - shrinkToFit = NULL, - textRotation = NULL, + num_fmt_id = NULL, + pivot_button = NULL, + quote_prefix = NULL, + reading_order = NULL, + relative_indent = NULL, + shrink_to_fit = NULL, + text_rotation = NULL, vertical = NULL, - wrapText = NULL, - xfId = NULL + wrap_text = NULL, + xf_id = NULL, + ... ) } \arguments{ @@ -42,25 +43,25 @@ wb_add_cell_style( \item{dims}{the cell range} -\item{applyAlignment}{logical apply alignment} +\item{apply_alignment}{logical apply alignment} -\item{applyBorder}{logical apply border} +\item{apply_border}{logical apply border} -\item{applyFill}{logical apply fill} +\item{apply_fill}{logical apply fill} -\item{applyFont}{logical apply font} +\item{apply_font}{logical apply font} -\item{applyNumberFormat}{logical apply number format} +\item{apply_number_format}{logical apply number format} -\item{applyProtection}{logical apply protection} +\item{apply_protection}{logical apply protection} -\item{borderId}{border ID to apply} +\item{border_id}{border ID to apply} -\item{extLst}{extension list something like \verb{...}} +\item{ext_lst}{extension list something like \verb{...}} -\item{fillId}{fill ID to apply} +\item{fill_id}{fill ID to apply} -\item{fontId}{font ID to apply} +\item{font_id}{font ID to apply} \item{hidden}{logical cell is hidden} @@ -68,29 +69,31 @@ wb_add_cell_style( \item{indent}{logical indent content} -\item{justifyLastLine}{logical justify last line} +\item{justify_last_line}{logical justify last line} \item{locked}{logical cell is locked} -\item{numFmtId}{number format ID to apply} +\item{num_fmt_id}{number format ID to apply} -\item{pivotButton}{unknown} +\item{pivot_button}{unknown} -\item{quotePrefix}{unknown} +\item{quote_prefix}{unknown} -\item{readingOrder}{reading order left to right} +\item{reading_order}{reading order left to right} -\item{relativeIndent}{relative indentation} +\item{relative_indent}{relative indentation} -\item{shrinkToFit}{logical shrink to fit} +\item{shrink_to_fit}{logical shrink to fit} -\item{textRotation}{degrees of text rotation} +\item{text_rotation}{degrees of text rotation} \item{vertical}{vertical alignment of content ('top', 'center', 'bottom')} -\item{wrapText}{wrap text in cell} +\item{wrap_text}{wrap text in cell} -\item{xfId}{xf ID to apply} +\item{xf_id}{xf ID to apply} + +\item{...}{additional arguments} } \value{ The \code{wbWorksheetObject}, invisibly diff --git a/man/wb_add_chart_xml.Rd b/man/wb_add_chart_xml.Rd index 15785c522..51e66432c 100644 --- a/man/wb_add_chart_xml.Rd +++ b/man/wb_add_chart_xml.Rd @@ -7,10 +7,11 @@ wb_add_chart_xml( wb, sheet = current_sheet(), - xml, dims = NULL, - colOffset = 0, - rowOffset = 0 + xml, + col_offset = 0, + row_offset = 0, + ... ) } \arguments{ @@ -18,12 +19,17 @@ wb_add_chart_xml( \item{sheet}{the sheet on which the graph will appear} +\item{dims}{the dimensions where the sheet will appear} + \item{xml}{chart xml} -\item{dims}{the dimensions where the sheet will appear} +\item{col_offset, row_offset}{positioning} -\item{colOffset, rowOffset}{startCol and startRow} +\item{...}{additional arguments} } \description{ add a chart xml to a workbook } +\seealso{ +\code{\link[=wb_add_drawing]{wb_add_drawing()}} \code{\link[=wb_add_image]{wb_add_image()}} \code{\link[=wb_add_mschart]{wb_add_mschart()}} \code{\link[=wb_add_plot]{wb_add_plot()}} +} diff --git a/man/wb_add_chartsheet.Rd b/man/wb_add_chartsheet.Rd index fcc8baaa1..37939f2dc 100644 --- a/man/wb_add_chartsheet.Rd +++ b/man/wb_add_chartsheet.Rd @@ -7,7 +7,7 @@ wb_add_chartsheet( wb, sheet = next_sheet(), - tabColor = NULL, + tab_color = NULL, zoom = 100, visible = c("true", "false", "hidden", "visible", "veryhidden"), ... @@ -18,7 +18,7 @@ wb_add_chartsheet( \item{sheet}{A name for the new worksheet} -\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 diff --git a/man/wb_add_data_table.Rd b/man/wb_add_data_table.Rd index 91632f492..97dc8e980 100644 --- a/man/wb_add_data_table.Rd +++ b/man/wb_add_data_table.Rd @@ -8,23 +8,24 @@ wb_add_data_table( wb, sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - colNames = TRUE, - rowNames = FALSE, - tableStyle = "TableStyleLight9", - tableName = NULL, - withFilter = TRUE, + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + col_names = TRUE, + row_names = FALSE, + table_style = "TableStyleLight9", + table_name = NULL, + with_filter = TRUE, sep = ", ", - firstColumn = FALSE, - lastColumn = FALSE, - bandedRows = TRUE, - bandedCols = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE, + first_column = FALSE, + last_column = FALSE, + banded_rows = TRUE, + banded_cols = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, na.strings = na_strings(), - inline_strings = TRUE + inline_strings = TRUE, + ... ) } \arguments{ @@ -34,22 +35,22 @@ wb_add_data_table( \item{x}{A dataframe.} -\item{startCol}{A vector specifying the starting column to write df} +\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} -\item{startRow}{A vector specifying the starting row to write df} +\item{start_col}{A vector specifying the starting column to write df} -\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} +\item{start_row}{A vector specifying the starting row to write df} -\item{colNames}{If \code{TRUE}, column names of x are written.} +\item{col_names}{If \code{TRUE}, column names of x are written.} -\item{rowNames}{If \code{TRUE}, row names of x are written.} +\item{row_names}{If \code{TRUE}, row names of x are written.} -\item{tableStyle}{Any excel table style name or "none" (see "formatting" +\item{table_style}{Any excel table style name or "none" (see "formatting" vignette).} -\item{tableName}{name of table in workbook. The table name must be unique.} +\item{table_name}{name of table in workbook. The table name must be unique.} -\item{withFilter}{If \code{TRUE}, columns with have filters in the first row.} +\item{with_filter}{If \code{TRUE}, columns with have filters in the first row.} \item{sep}{Only applies to list columns. The separator used to collapse list columns to a character vector e.g. sapply(x$list_column, paste, collapse = @@ -60,22 +61,24 @@ sep). \if{html}{\figure{tableoptions.png}{options: width="40\%" alt="Figure: table_options.png"}} \if{latex}{\figure{tableoptions.pdf}{options: width=7cm}}} -\item{firstColumn}{logical. If TRUE, the first column is bold} +\item{first_column}{logical. If TRUE, the first column is bold} -\item{lastColumn}{logical. If TRUE, the last column is bold} +\item{last_column}{logical. If TRUE, the last column is bold} -\item{bandedRows}{logical. If TRUE, rows are color banded} +\item{banded_rows}{logical. If TRUE, rows are color banded} -\item{bandedCols}{logical. If TRUE, the columns are color banded} +\item{banded_cols}{logical. If TRUE, the columns are color banded} -\item{applyCellStyle}{Should we write cell styles to the workbook} +\item{apply_cell_style}{Should we write cell styles to the workbook} -\item{removeCellStyle}{keep the cell style?} +\item{remove_cell_style}{keep the cell style?} \item{na.strings}{Value used for replacing \code{NA} values from \code{x}. Default \code{na_strings()} uses the special \verb{#N/A} value within the workbook.} \item{inline_strings}{write characters as inline strings} + +\item{...}{additional arguments} } \description{ Add data to a worksheet and format as an Excel table diff --git a/man/wb_add_data_validation.Rd b/man/wb_add_data_validation.Rd index 490c43b10..ed301ee87 100644 --- a/man/wb_add_data_validation.Rd +++ b/man/wb_add_data_validation.Rd @@ -7,19 +7,19 @@ wb_add_data_validation( wb, sheet = current_sheet(), - cols, - rows, + dims = "A1", type, operator, value, - allowBlank = TRUE, - showInputMsg = TRUE, - showErrorMsg = TRUE, - errorStyle = NULL, - errorTitle = NULL, + allow_blank = TRUE, + show_input_msg = TRUE, + show_error_msg = TRUE, + error_style = NULL, + error_title = NULL, error = NULL, - promptTitle = NULL, - prompt = NULL + prompt_title = NULL, + prompt = NULL, + ... ) } \arguments{ @@ -27,9 +27,7 @@ wb_add_data_validation( \item{sheet}{A name or index of a worksheet} -\item{cols}{Contiguous columns to apply conditional formatting to} - -\item{rows}{Contiguous rows to apply conditional formatting to} +\item{dims}{A cell dimension ("A1" or "A1:B2")} \item{type}{One of 'whole', 'decimal', 'date', 'time', 'textLength', 'list' (see examples)} @@ -38,21 +36,23 @@ wb_add_data_validation( \item{value}{a vector of length 1 or 2 depending on operator (see examples)} -\item{allowBlank}{logical} +\item{allow_blank}{logical} -\item{showInputMsg}{logical} +\item{show_input_msg}{logical} -\item{showErrorMsg}{logical} +\item{show_error_msg}{logical} -\item{errorStyle}{The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input)} +\item{error_style}{The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input)} -\item{errorTitle}{The error title} +\item{error_title}{The error title} \item{error}{The error text} -\item{promptTitle}{The prompt title} +\item{prompt_title}{The prompt title} \item{prompt}{The prompt text} + +\item{...}{additional arguments} } \description{ Add Excel data validation to cells @@ -64,11 +64,11 @@ wb$add_worksheet("Sheet 2") wb$add_data_table(1, x = iris[1:30, ]) wb$add_data_validation(1, - col = 1:3, rows = 2:31, type = "whole", + dims = "A2:C31", type = "whole", operator = "between", value = c(1, 9) ) wb$add_data_validation(1, - col = 5, rows = 2:31, type = "textLength", + dims = "E2:E31", type = "textLength", operator = "between", value = c(4, 6) ) @@ -83,7 +83,7 @@ wb$add_data_validation(2, operator = "greaterThanOrEqual", value = as.Date("2016-01-01") ) wb$add_data_validation(2, - col = 2, rows = 2:12, type = "time", + dims = "B2:B12", type = "time", operator = "between", value = df$t[c(4, 8)] ) @@ -99,5 +99,5 @@ wb$add_worksheet("Sheet 2") wb$add_data_table(sheet = 1, x = iris[1:30, ]) wb$add_data(sheet = 2, x = sample(iris$Sepal.Length, 10)) -wb$add_data_validation(1, col = 1, rows = 2:31, type = "list", value = "'Sheet 2'!$A$1:$A$10") +wb$add_data_validation(1, dims = "A2:A31", type = "list", value = "'Sheet 2'!$A$1:$A$10") } diff --git a/man/wb_add_drawing.Rd b/man/wb_add_drawing.Rd index 3b6ba002a..9807de6b1 100644 --- a/man/wb_add_drawing.Rd +++ b/man/wb_add_drawing.Rd @@ -7,10 +7,11 @@ wb_add_drawing( wb, sheet = current_sheet(), + dims = "A1", xml, - dims = NULL, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... ) } \arguments{ @@ -18,11 +19,13 @@ wb_add_drawing( \item{sheet}{a sheet in the workbook} +\item{dims}{the dimension where the drawing is added. Can be NULL} + \item{xml}{the drawing xml as character or file} -\item{dims}{the dimension where the drawing is added. Can be NULL} +\item{col_offset, row_offset}{offsets for column and row} -\item{colOffset, rowOffset}{offsets for column and row} +\item{...}{additional arguments} } \description{ add drawings to workbook @@ -43,3 +46,6 @@ wb <- wb_workbook()$ add_drawing(xml = tmp, dims = NULL) } } +\seealso{ +\code{\link[=wb_add_chart_xml]{wb_add_chart_xml()}} \code{\link[=wb_add_image]{wb_add_image()}} \code{\link[=wb_add_mschart]{wb_add_mschart()}} \code{\link[=wb_add_plot]{wb_add_plot()}} +} diff --git a/man/wb_add_dxfs_style.Rd b/man/wb_add_dxfs_style.Rd index 539cf1ef5..70832f165 100644 --- a/man/wb_add_dxfs_style.Rd +++ b/man/wb_add_dxfs_style.Rd @@ -11,12 +11,12 @@ wb_add_dxfs_style( font_name = NULL, font_size = NULL, font_color = NULL, - numFmt = NULL, + num_fmt = NULL, border = NULL, border_color = wb_color(getOption("openxlsx2.borderColor", "black")), border_style = getOption("openxlsx2.borderStyle", "thin"), - bgFill = NULL, - gradientFill = NULL, + bg_fill = NULL, + gradient_fill = NULL, text_bold = NULL, text_italic = NULL, text_underline = NULL, @@ -34,7 +34,7 @@ wb_add_dxfs_style( \item{font_color}{the font color (a \code{wb_color()} object)} -\item{numFmt}{the number format} +\item{num_fmt}{the number format} \item{border}{logical if borders are applied} @@ -42,9 +42,9 @@ wb_add_dxfs_style( \item{border_style}{the border style} -\item{bgFill}{any background fill} +\item{bg_fill}{any background fill} -\item{gradientFill}{any gradient fill} +\item{gradient_fill}{any gradient fill} \item{text_bold}{logical if text is bold} diff --git a/man/wb_add_font.Rd b/man/wb_add_font.Rd index ab910b5a0..d92408429 100644 --- a/man/wb_add_font.Rd +++ b/man/wb_add_font.Rd @@ -22,7 +22,7 @@ wb_add_font( family = "", scheme = "", shadow = "", - vertAlign = "", + vert_align = "", ... ) } @@ -61,7 +61,7 @@ wb_add_font( \item{shadow}{shadow} -\item{vertAlign}{vertical alignment} +\item{vert_align}{vertical alignment} \item{...}{...} } diff --git a/man/wb_add_formula.Rd b/man/wb_add_formula.Rd index a2baac28a..937c84679 100644 --- a/man/wb_add_formula.Rd +++ b/man/wb_add_formula.Rd @@ -8,13 +8,14 @@ wb_add_formula( wb, sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, array = FALSE, cm = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE + apply_cell_style = TRUE, + remove_cell_style = FALSE, + ... ) } \arguments{ @@ -24,19 +25,21 @@ wb_add_formula( \item{x}{A character vector.} -\item{startCol}{A vector specifying the starting column to write to.} +\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} -\item{startRow}{A vector specifying the starting row to write to.} +\item{start_col}{A vector specifying the starting column to write to.} -\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} +\item{start_row}{A vector specifying the starting row to write to.} \item{array}{A bool if the function written is of type array} \item{cm}{A special kind of array function that hides the curly braces in the cell. Add this, if you see "@" inserted into your formulas} -\item{applyCellStyle}{Should we write cell styles to the workbook} +\item{apply_cell_style}{Should we write cell styles to the workbook} + +\item{remove_cell_style}{keep the cell style?,} -\item{removeCellStyle}{keep the cell style?} +\item{...}{additional arguments} } \description{ Add a character vector containing Excel formula to a worksheet. diff --git a/man/wb_add_ignore_error.Rd b/man/wb_add_ignore_error.Rd index 540d3ffdd..2ca40c513 100644 --- a/man/wb_add_ignore_error.Rd +++ b/man/wb_add_ignore_error.Rd @@ -8,15 +8,16 @@ wb_add_ignore_error( wb, sheet = current_sheet(), dims = "A1", - calculatedColumn = FALSE, - emptyCellReference = FALSE, - evalError = FALSE, + calculated_column = FALSE, + empty_cell_reference = FALSE, + eval_error = FALSE, formula = FALSE, - formulaRange = FALSE, - listDataValidation = FALSE, - numberStoredAsText = FALSE, - twoDigitTextYear = FALSE, - unlockedFormula = FALSE + formula_range = FALSE, + list_data_validation = FALSE, + number_stored_as_text = FALSE, + two_digit_text_year = FALSE, + unlocked_formula = FALSE, + ... ) } \arguments{ @@ -26,23 +27,25 @@ wb_add_ignore_error( \item{dims}{dims} -\item{calculatedColumn}{calculatedColumn} +\item{calculated_column}{calculatedColumn} -\item{emptyCellReference}{emptyCellReference} +\item{empty_cell_reference}{emptyCellReference} -\item{evalError}{evalError} +\item{eval_error}{evalError} \item{formula}{formula} -\item{formulaRange}{formulaRange} +\item{formula_range}{formulaRange} -\item{listDataValidation}{listDataValidation} +\item{list_data_validation}{listDataValidation} -\item{numberStoredAsText}{numberStoredAsText} +\item{number_stored_as_text}{numberStoredAsText} -\item{twoDigitTextYear}{twoDigitTextYear} +\item{two_digit_text_year}{twoDigitTextYear} -\item{unlockedFormula}{unlockedFormula} +\item{unlocked_formula}{unlockedFormula} + +\item{...}{additional arguments} } \description{ Ignore error on worksheet diff --git a/man/wb_add_image.Rd b/man/wb_add_image.Rd index 0f42c496a..adc2ea304 100644 --- a/man/wb_add_image.Rd +++ b/man/wb_add_image.Rd @@ -7,16 +7,15 @@ wb_add_image( wb, sheet = current_sheet(), + dims = "A1", file, width = 6, height = 3, - startRow = 1, - startCol = 1, - rowOffset = 0, - colOffset = 0, + row_offset = 0, + col_offset = 0, units = "in", dpi = 300, - dims = rowcol_to_dim(startRow, startCol) + ... ) } \arguments{ @@ -24,44 +23,38 @@ wb_add_image( \item{sheet}{A name or index of a worksheet} +\item{dims}{Dimensions where to plot. Default absolute anchor, single cell (eg. "A1") oneCellAnchor, cell range (eg. "A1:D4") twoCellAnchor} + \item{file}{An image file. Valid file types are:\code{ "jpeg"}, \code{"png"}, \code{"bmp"}} \item{width}{Width of figure.} \item{height}{Height of figure.} -\item{startRow}{Row coordinate of upper left corner of the image} - -\item{startCol}{Column coordinate of upper left corner of the image} - -\item{rowOffset}{offset vector for one or two cell anchor within cell (row)} +\item{row_offset}{offset vector for one or two cell anchor within cell (row)} -\item{colOffset}{offset vector for one or two cell anchor within cell (column)} +\item{col_offset}{offset vector for one or two cell anchor within cell (column)} \item{units}{Units of width and height. Can be \code{"in"}, \code{"cm"} or \code{"px"}} \item{dpi}{Image resolution used for conversion between units.} -\item{dims}{Dimensions where to plot. Default absolute anchor, single cell (eg. "A1") oneCellAnchor, cell range (eg. "A1:D4") twoCellAnchor} +\item{...}{additional arguments} } \description{ Insert an image into a worksheet } \examples{ -## Create a new workbook -wb <- wb_workbook("Ayanami") - -## Add some worksheets -wb$add_worksheet("Sheet 1") -wb$add_worksheet("Sheet 2") -wb$add_worksheet("Sheet 3") - -## Insert images img <- system.file("extdata", "einstein.jpg", package = "openxlsx2") -wb$add_image("Sheet 1", img, startRow = 5, startCol = 3, width = 6, height = 5) -wb$add_image(2, img, startRow = 2, startCol = 2) -wb$add_image(3, img, width = 15, height = 12, startRow = 3, startCol = "G", units = "cm") + +wb <- wb_workbook()$ + add_worksheet()$ + add_image("Sheet 1", dims = "C5", file = img, width = 6, height = 5)$ + add_worksheet()$ + add_image(dims = "B2", file = img)$ + add_worksheet()$ + add_image(dims = "G3", file = img, width = 15, height = 12, units = "cm") } \seealso{ -\code{\link[=wb_add_plot]{wb_add_plot()}} +\code{\link[=wb_add_chart_xml]{wb_add_chart_xml()}} \code{\link[=wb_add_drawing]{wb_add_drawing()}} \code{\link[=wb_add_mschart]{wb_add_mschart()}} \code{\link[=wb_add_plot]{wb_add_plot()}} } diff --git a/man/wb_add_mschart.Rd b/man/wb_add_mschart.Rd index b86247a9d..8396c8668 100644 --- a/man/wb_add_mschart.Rd +++ b/man/wb_add_mschart.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/wb_functions.R +% Please edit documentation in R/class-workbook-wrappers.R \name{wb_add_mschart} \alias{wb_add_mschart} \title{Add mschart object to an existing workbook} @@ -9,8 +9,9 @@ wb_add_mschart( sheet = current_sheet(), dims = NULL, graph, - colOffset = 0, - rowOffset = 0 + col_offset = 0, + row_offset = 0, + ... ) } \arguments{ @@ -22,7 +23,9 @@ wb_add_mschart( \item{graph}{mschart object} -\item{colOffset, rowOffset}{startCol and startRow} +\item{col_offset, row_offset}{offsets for column and row} + +\item{...}{additional arguments} } \description{ Add mschart object to an existing workbook @@ -61,5 +64,5 @@ wb <- wb \%>\% } } \seealso{ -\code{\link[=wb_data]{wb_data()}} +\code{\link[=wb_data]{wb_data()}} \code{\link[=wb_add_chart_xml]{wb_add_chart_xml()}} \link{wb_add_image} \code{\link[=wb_add_mschart]{wb_add_mschart()}} \link{wb_add_plot} } diff --git a/man/wb_add_plot.Rd b/man/wb_add_plot.Rd index fb60e9eb6..0c07d419b 100644 --- a/man/wb_add_plot.Rd +++ b/man/wb_add_plot.Rd @@ -7,16 +7,15 @@ wb_add_plot( wb, sheet = current_sheet(), + dims = "A1", width = 6, height = 4, - startRow = 1, - startCol = 1, - rowOffset = 0, - colOffset = 0, - fileType = "png", + row_offset = 0, + col_offset = 0, + file_type = "png", units = "in", dpi = 300, - dims = rowcol_to_dim(startRow, startCol) + ... ) } \arguments{ @@ -24,25 +23,21 @@ wb_add_plot( \item{sheet}{A name or index of a worksheet} +\item{dims}{Worksheet dimension, single cell ("A1") or cell range ("A1:D4")} + \item{width}{Width of figure. Defaults to \code{6}in.} \item{height}{Height of figure . Defaults to \code{4}in.} -\item{startRow}{Row coordinate of upper left corner of figure.} - -\item{startCol}{Column coordinate of upper left corner of figure.} +\item{row_offset, col_offset}{offset for column and row} -\item{rowOffset}{offset within cell (row)} - -\item{colOffset}{offset within cell (column)} - -\item{fileType}{File type of image} +\item{file_type}{File type of image} \item{units}{Units of width and height. Can be \code{"in"}, \code{"cm"} or \code{"px"}} \item{dpi}{Image resolution} -\item{dims}{Worksheet dimension, single cell ("A1") or cell range ("A1:D4")} +\item{...}{additional arguments} } \description{ The current plot is saved to a temporary image file using @@ -76,5 +71,5 @@ wb$add_plot(1, dims = "J2", width = 16, height = 10, fileType = "png", units = " } } \seealso{ -\code{\link[=wb_add_image]{wb_add_image()}} +\code{\link[=wb_add_chart_xml]{wb_add_chart_xml()}} \code{\link[=wb_add_drawing]{wb_add_drawing()}} \code{\link[=wb_add_image]{wb_add_image()}} \code{\link[=wb_add_mschart]{wb_add_mschart()}} } 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"} diff --git a/man/wb_load.Rd b/man/wb_load.Rd index 3777825f8..4badaebd0 100644 --- a/man/wb_load.Rd +++ b/man/wb_load.Rd @@ -4,12 +4,19 @@ \alias{wb_load} \title{Load an existing .xlsx file} \usage{ -wb_load(file, xlsxFile = NULL, sheet, data_only = FALSE, calc_chain = FALSE) +wb_load( + file, + xlsx_file = NULL, + sheet, + data_only = FALSE, + calc_chain = FALSE, + ... +) } \arguments{ \item{file}{A path to an existing .xlsx or .xlsm file} -\item{xlsxFile}{alias for file} +\item{xlsx_file}{alias for file} \item{sheet}{optional sheet parameter. if this is applied, only the selected sheet will be loaded.} @@ -23,6 +30,8 @@ evaluated. Removing the calculation chain is considered harmless. The calc chain will be created upon the next time the worksheet is loaded in spreadsheet software. Keeping it, might only speed loading time in said software.} + +\item{...}{additional arguments} } \value{ Workbook object. diff --git a/man/wb_modify_basefont.Rd b/man/wb_modify_basefont.Rd index 547def796..9d389f9e1 100644 --- a/man/wb_modify_basefont.Rd +++ b/man/wb_modify_basefont.Rd @@ -7,20 +7,20 @@ \usage{ wb_set_base_font( wb, - fontSize = 11, - fontColor = wb_color(theme = "1"), - fontName = "Calibri", + font_size = 11, + font_color = wb_color(theme = "1"), + font_name = "Calibri", ... ) } \arguments{ \item{wb}{A workbook object} -\item{fontSize}{font size} +\item{font_size}{font size} -\item{fontColor}{font color} +\item{font_color}{font color} -\item{fontName}{Name of a font} +\item{font_name}{Name of a font} \item{...}{...} } diff --git a/man/wb_read.Rd b/man/wb_read.Rd index e1fd52263..24c8fe6f8 100644 --- a/man/wb_read.Rd +++ b/man/wb_read.Rd @@ -5,40 +5,40 @@ \title{Read from an Excel file or Workbook object} \usage{ wb_read( - xlsxFile, + xlsx_file, sheet = 1, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, rows = NULL, cols = NULL, - detectDates = TRUE, - namedRegion, + detect_dates = TRUE, + named_region, na.strings = "NA", na.numbers = NA, ... ) } \arguments{ -\item{xlsxFile}{An xlsx file, Workbook object or URL to xlsx file.} +\item{xlsx_file}{An xlsx file, Workbook object or URL to xlsx file.} \item{sheet}{The name or index of the sheet to read data from.} -\item{startRow}{first row to begin looking for data.} +\item{start_row}{first row to begin looking for data.} -\item{startCol}{first column to begin looking for data.} +\item{start_col}{first column to begin looking for data.} -\item{rowNames}{If \code{TRUE}, first column of data will be used as row names.} +\item{row_names}{If \code{TRUE}, first column of data will be used as row names.} -\item{colNames}{If \code{TRUE}, the first row of data will be used as column names.} +\item{col_names}{If \code{TRUE}, the first row of data will be used as column names.} -\item{skipEmptyRows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data +\item{skip_empty_rows}{If \code{TRUE}, empty rows are skipped else empty rows after the first row containing data will return a row of NAs.} -\item{skipEmptyCols}{If \code{TRUE}, empty columns are skipped.} +\item{skip_empty_cols}{If \code{TRUE}, empty columns are skipped.} \item{rows}{A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.} @@ -46,9 +46,9 @@ If NULL, all rows are read.} \item{cols}{A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.} -\item{detectDates}{If \code{TRUE}, attempt to recognize dates and perform conversion.} +\item{detect_dates}{If \code{TRUE}, attempt to recognize dates and perform conversion.} -\item{namedRegion}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.} +\item{named_region}{A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.} \item{na.strings}{A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.} diff --git a/man/wb_set_bookview.Rd b/man/wb_set_bookview.Rd index 423aaffa9..93566acce 100644 --- a/man/wb_set_bookview.Rd +++ b/man/wb_set_bookview.Rd @@ -6,49 +6,52 @@ \usage{ wb_set_bookview( wb, - activeTab = NULL, - autoFilterDateGrouping = NULL, - firstSheet = NULL, + active_tab = NULL, + auto_filter_date_grouping = NULL, + first_sheet = NULL, minimized = NULL, - showHorizontalScroll = NULL, - showSheetTabs = NULL, - showVerticalScroll = NULL, - tabRatio = NULL, + show_horizontal_scroll = NULL, + show_sheet_tabs = NULL, + show_vertical_scroll = NULL, + tab_ratio = NULL, visibility = NULL, - windowHeight = NULL, - windowWidth = NULL, - xWindow = NULL, - yWindow = NULL + window_height = NULL, + window_width = NULL, + x_window = NULL, + y_window = NULL, + ... ) } \arguments{ \item{wb}{A \link{wbWorkbook} object} -\item{activeTab}{activeTab} +\item{active_tab}{activeTab} -\item{autoFilterDateGrouping}{autoFilterDateGrouping} +\item{auto_filter_date_grouping}{autoFilterDateGrouping} -\item{firstSheet}{firstSheet} +\item{first_sheet}{firstSheet} \item{minimized}{minimized} -\item{showHorizontalScroll}{showHorizontalScroll} +\item{show_horizontal_scroll}{showHorizontalScroll} -\item{showSheetTabs}{showSheetTabs} +\item{show_sheet_tabs}{showSheetTabs} -\item{showVerticalScroll}{showVerticalScroll} +\item{show_vertical_scroll}{showVerticalScroll} -\item{tabRatio}{tabRatio} +\item{tab_ratio}{tabRatio} \item{visibility}{visibility} -\item{windowHeight}{windowHeight} +\item{window_height}{windowHeight} -\item{windowWidth}{windowWidth} +\item{window_width}{windowWidth} -\item{xWindow}{xWindow} +\item{x_window}{xWindow} -\item{yWindow}{yWindow} +\item{y_window}{yWindow} + +\item{...}{additional arguments} } \value{ The \code{wbWorkbook} object diff --git a/man/wb_set_header_footer.Rd b/man/wb_set_header_footer.Rd index 24b7d81bc..ac5105565 100644 --- a/man/wb_set_header_footer.Rd +++ b/man/wb_set_header_footer.Rd @@ -9,10 +9,11 @@ wb_set_header_footer( sheet = current_sheet(), header = NULL, footer = NULL, - evenHeader = NULL, - evenFooter = NULL, - firstHeader = NULL, - firstFooter = NULL + even_header = NULL, + even_footer = NULL, + first_header = NULL, + first_footer = NULL, + ... ) } \arguments{ @@ -24,13 +25,15 @@ wb_set_header_footer( \item{footer}{document footer. Character vector of length 3 corresponding to positions left, center, right. Use NA to skip a position.} -\item{evenHeader}{document header for even pages.} +\item{even_header}{document header for even pages.} -\item{evenFooter}{document footer for even pages.} +\item{even_footer}{document footer for even pages.} -\item{firstHeader}{document header for first page only.} +\item{first_header}{document header for first page only.} -\item{firstFooter}{document footer for first page only.} +\item{first_footer}{document footer for first page only.} + +\item{...}{additional arguments} } \description{ Set document headers and footers diff --git a/man/wb_set_sheetview.Rd b/man/wb_set_sheetview.Rd index f7996f162..2dde752bb 100644 --- a/man/wb_set_sheetview.Rd +++ b/man/wb_set_sheetview.Rd @@ -7,25 +7,26 @@ wb_set_sheetview( wb, sheet = current_sheet(), - colorId = NULL, - defaultGridColor = NULL, - rightToLeft = NULL, - showFormulas = NULL, - showGridLines = NULL, - showOutlineSymbols = NULL, - showRowColHeaders = NULL, - showRuler = NULL, - showWhiteSpace = NULL, - showZeros = NULL, - tabSelected = NULL, - topLeftCell = NULL, + color_id = NULL, + default_grid_color = NULL, + right_to_left = NULL, + show_formulas = NULL, + show_grid_lines = NULL, + show_outline_symbols = NULL, + show_row_col_headers = NULL, + show_ruler = NULL, + show_white_space = NULL, + show_zeros = NULL, + tab_selected = NULL, + top_left_cell = NULL, view = NULL, - windowProtection = NULL, - workbookViewId = NULL, - zoomScale = NULL, - zoomScaleNormal = NULL, - zoomScalePageLayoutView = NULL, - zoomScaleSheetLayoutView = NULL + window_protection = NULL, + workbook_view_id = NULL, + zoom_scale = NULL, + zoom_scale_normal = NULL, + zoom_scale_page_layout_view = NULL, + zoom_scale_sheet_layout_view = NULL, + ... ) } \arguments{ @@ -33,35 +34,37 @@ wb_set_sheetview( \item{sheet}{sheet} -\item{colorId, defaultGridColor}{Integer: A color, default is 64} +\item{color_id, default_grid_color}{Integer: A color, default is 64} -\item{rightToLeft}{Logical: if TRUE column ordering is right to left} +\item{right_to_left}{Logical: if TRUE column ordering is right to left} -\item{showFormulas}{Logical: if TRUE cell formulas are shown} +\item{show_formulas}{Logical: if TRUE cell formulas are shown} -\item{showGridLines}{Logical: if TRUE the worksheet grid is shown} +\item{show_grid_lines}{Logical: if TRUE the worksheet grid is shown} -\item{showOutlineSymbols}{Logical: if TRUE outline symbols are shown} +\item{show_outline_symbols}{Logical: if TRUE outline symbols are shown} -\item{showRowColHeaders}{Logical: if TRUE row and column headers are shown} +\item{show_row_col_headers}{Logical: if TRUE row and column headers are shown} -\item{showRuler}{Logical: if TRUE a ruler is shown in page layout view} +\item{show_ruler}{Logical: if TRUE a ruler is shown in page layout view} -\item{showWhiteSpace}{Logical: if TRUE margins are shown in page layout view} +\item{show_white_space}{Logical: if TRUE margins are shown in page layout view} -\item{showZeros}{Logical: if FALSE cells containing zero are shown blank if !showFormulas} +\item{show_zeros}{Logical: if FALSE cells containing zero are shown blank if !showFormulas} -\item{tabSelected}{Integer: zero vector indicating the selected tab} +\item{tab_selected}{Integer: zero vector indicating the selected tab} -\item{topLeftCell}{Cell: the cell shown in the top left corner / or top right with rightToLeft} +\item{top_left_cell}{Cell: the cell shown in the top left corner / or top right with rightToLeft} \item{view}{View: "normal", "pageBreakPreview" or "pageLayout"} -\item{windowProtection}{Logical: if TRUE the panes are protected} +\item{window_protection}{Logical: if TRUE the panes are protected} -\item{workbookViewId}{integer: Pointing to some other view inside the workbook} +\item{workbook_view_id}{integer: Pointing to some other view inside the workbook} -\item{zoomScale, zoomScaleNormal, zoomScalePageLayoutView, zoomScaleSheetLayoutView}{Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc.} +\item{zoom_scale, zoom_scale_normal, zoom_scale_page_layout_view, zoom_scale_sheet_layout_view}{Integer: the zoom scale should be between 10 and 400. These are values for current, normal etc.} + +\item{...}{additional arguments} } \value{ The \code{wbWorksheetObject}, invisibly diff --git a/man/wb_to_df.Rd b/man/wb_to_df.Rd index 266fb0d55..184053b16 100644 --- a/man/wb_to_df.Rd +++ b/man/wb_to_df.Rd @@ -5,66 +5,67 @@ \title{Create Dataframe from Workbook} \usage{ wb_to_df( - xlsxFile, + xlsx_file, sheet, - startRow = 1, - startCol = NULL, - rowNames = FALSE, - colNames = TRUE, - skipEmptyRows = FALSE, - skipEmptyCols = FALSE, - skipHiddenRows = FALSE, - skipHiddenCols = FALSE, + start_row = 1, + start_col = NULL, + row_names = FALSE, + col_names = TRUE, + skip_empty_rows = FALSE, + skip_empty_cols = FALSE, + skip_hidden_rows = FALSE, + skip_hidden_cols = FALSE, rows = NULL, cols = NULL, - detectDates = TRUE, + detect_dates = TRUE, na.strings = "#N/A", na.numbers = NA, - fillMergedCells = FALSE, + fill_merged_cells = FALSE, dims, - showFormula = FALSE, + show_formula = FALSE, convert = TRUE, types, named_region, - keep_attributes = FALSE + keep_attributes = FALSE, + ... ) } \arguments{ -\item{xlsxFile}{An xlsx file, Workbook object or URL to xlsx file.} +\item{xlsx_file}{An xlsx file, Workbook object or URL to xlsx file.} \item{sheet}{Either sheet name or index. When missing the first sheet in the workbook is selected.} -\item{startRow}{first row to begin looking for data.} +\item{start_row}{first row to begin looking for data.} -\item{startCol}{first column to begin looking for data.} +\item{start_col}{first column to begin looking for data.} -\item{rowNames}{If TRUE, the first col of data will be used as row names.} +\item{row_names}{If TRUE, the first col of data will be used as row names.} -\item{colNames}{If TRUE, the first row of data will be used as column names.} +\item{col_names}{If TRUE, the first row of data will be used as column names.} -\item{skipEmptyRows}{If TRUE, empty rows are skipped.} +\item{skip_empty_rows}{If TRUE, empty rows are skipped.} -\item{skipEmptyCols}{If TRUE, empty columns are skipped.} +\item{skip_empty_cols}{If TRUE, empty columns are skipped.} -\item{skipHiddenRows}{If TRUE, hidden rows are skipped.} +\item{skip_hidden_rows}{If TRUE, hidden rows are skipped.} -\item{skipHiddenCols}{If TRUE, hidden columns are skipped.} +\item{skip_hidden_cols}{If TRUE, hidden columns are skipped.} \item{rows}{A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.} \item{cols}{A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.} -\item{detectDates}{If TRUE, attempt to recognize dates and perform conversion.} +\item{detect_dates}{If TRUE, attempt to recognize dates and perform conversion.} \item{na.strings}{A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.} \item{na.numbers}{A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA.} -\item{fillMergedCells}{If TRUE, the value in a merged cell is given to all cells within the merge.} +\item{fill_merged_cells}{If TRUE, the value in a merged cell is given to all cells within the merge.} \item{dims}{Character string of type "A1:B2" as optional dimensions to be imported.} -\item{showFormula}{If TRUE, the underlying Excel formulas are shown.} +\item{show_formula}{If TRUE, the underlying Excel formulas are shown.} \item{convert}{If TRUE, a conversion to dates and numerics is attempted.} @@ -73,6 +74,8 @@ wb_to_df( \item{named_region}{Character string with a named_region (defined name or table). If no sheet is selected, the first appearance will be selected.} \item{keep_attributes}{If TRUE additional attributes are returned. (These are used internally to define a cell type.)} + +\item{...}{additional arguments} } \description{ Simple function to create a dataframe from a workbook. Simple as in simply diff --git a/man/wb_workbook.Rd b/man/wb_workbook.Rd index a84baeb91..7ba91737f 100644 --- a/man/wb_workbook.Rd +++ b/man/wb_workbook.Rd @@ -9,8 +9,9 @@ wb_workbook( title = NULL, subject = NULL, category = NULL, - datetimeCreated = Sys.time(), - theme = NULL + datetime_created = Sys.time(), + theme = NULL, + ... ) } \arguments{ @@ -22,9 +23,11 @@ wb_workbook( \item{category}{Workbook properties category} -\item{datetimeCreated}{The time of the workbook is created} +\item{datetime_created}{The time of the workbook is created} \item{theme}{Optional theme identified by string or number} + +\item{...}{additional arguments} } \value{ A \link{wbWorkbook} object diff --git a/man/write_data.Rd b/man/write_data.Rd index 485135ce9..24f9ca7ce 100644 --- a/man/write_data.Rd +++ b/man/write_data.Rd @@ -9,38 +9,40 @@ wb_add_data( wb, sheet = current_sheet(), x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, array = FALSE, - colNames = TRUE, - rowNames = FALSE, - withFilter = FALSE, + col_names = TRUE, + row_names = FALSE, + with_filter = FALSE, name = NULL, sep = ", ", - applyCellStyle = TRUE, - removeCellStyle = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, na.strings = na_strings(), - inline_strings = TRUE + inline_strings = TRUE, + ... ) write_data( wb, sheet, x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, array = FALSE, - colNames = TRUE, - rowNames = FALSE, - withFilter = FALSE, + col_names = TRUE, + row_names = FALSE, + with_filter = FALSE, sep = ", ", name = NULL, - applyCellStyle = TRUE, - removeCellStyle = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, na.strings = na_strings(), - inline_strings = TRUE + inline_strings = TRUE, + ... ) } \arguments{ @@ -50,32 +52,34 @@ write_data( \item{x}{Object to be written. For classes supported look at the examples.} -\item{startCol}{A vector specifying the starting column to write to.} +\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} -\item{startRow}{A vector specifying the starting row to write to.} +\item{start_col}{A vector specifying the starting column to write to.} -\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} +\item{start_row}{A vector specifying the starting row to write to.} \item{array}{A bool if the function written is of type array} -\item{colNames}{If \code{TRUE}, column names of x are written.} +\item{col_names}{If \code{TRUE}, column names of x are written.} -\item{rowNames}{If \code{TRUE}, data.frame row names of x are written.} +\item{row_names}{If \code{TRUE}, data.frame row names of x are written.} -\item{withFilter}{If \code{TRUE}, add filters to the column name row. NOTE can only have one filter per worksheet.} +\item{with_filter}{If \code{TRUE}, add filters to the column name row. NOTE can only have one filter per worksheet.} \item{name}{If not NULL, a named region is defined.} \item{sep}{Only applies to list columns. The separator used to collapse list columns to a character vector e.g. sapply(x$list_column, paste, collapse = sep).} -\item{applyCellStyle}{apply styles when writing on the sheet} +\item{apply_cell_style}{apply styles when writing on the sheet} -\item{removeCellStyle}{if writing into existing cells, should the cell style be removed?} +\item{remove_cell_style}{if writing into existing cells, should the cell style be removed?} \item{na.strings}{Value used for replacing \code{NA} values from \code{x}. Default \code{na_strings()} uses the special \verb{#N/A} value within the workbook.} \item{inline_strings}{write characters as inline strings} + +\item{...}{additional arguments} } \value{ A clone of `wb`` diff --git a/man/write_datatable.Rd b/man/write_datatable.Rd index f0801ac92..89d164be8 100644 --- a/man/write_datatable.Rd +++ b/man/write_datatable.Rd @@ -8,23 +8,24 @@ write_datatable( wb, sheet, x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), - colNames = TRUE, - rowNames = FALSE, - tableStyle = "TableStyleLight9", - tableName = NULL, - withFilter = TRUE, + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, + col_names = TRUE, + row_names = FALSE, + table_style = "TableStyleLight9", + table_name = NULL, + with_filter = TRUE, sep = ", ", - firstColumn = FALSE, - lastColumn = FALSE, - bandedRows = TRUE, - bandedCols = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE, + first_column = FALSE, + last_column = FALSE, + banded_rows = TRUE, + banded_cols = FALSE, + apply_cell_style = TRUE, + remove_cell_style = FALSE, na.strings = na_strings(), - inline_strings = TRUE + inline_strings = TRUE, + ... ) } \arguments{ @@ -34,21 +35,21 @@ write_datatable( \item{x}{A data frame.} -\item{startCol}{A vector specifying the starting column to write df} +\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} -\item{startRow}{A vector specifying the starting row to write df} +\item{start_col}{A vector specifying the starting column to write df} -\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} +\item{start_row}{A vector specifying the starting row to write df} -\item{colNames}{If \code{TRUE}, column names of x are written.} +\item{col_names}{If \code{TRUE}, column names of x are written.} -\item{rowNames}{If \code{TRUE}, row names of x are written.} +\item{row_names}{If \code{TRUE}, row names of x are written.} -\item{tableStyle}{Any excel table style name or "none" (see "formatting" vignette).} +\item{table_style}{Any excel table style name or "none" (see "formatting" vignette).} -\item{tableName}{name of table in workbook. The table name must be unique.} +\item{table_name}{name of table in workbook. The table name must be unique.} -\item{withFilter}{If \code{TRUE}, columns with have filters in the first row.} +\item{with_filter}{If \code{TRUE}, columns with have filters in the first row.} \item{sep}{Only applies to list columns. The separator used to collapse list columns to a character vector e.g. sapply(x$list_column, paste, collapse = sep). \cr\cr @@ -57,22 +58,24 @@ write_datatable( \if{html}{\figure{tableoptions.png}{options: width="40\%" alt="Figure: table_options.png"}} \if{latex}{\figure{tableoptions.pdf}{options: width=7cm}}} -\item{firstColumn}{logical. If TRUE, the first column is bold} +\item{first_column}{logical. If TRUE, the first column is bold} -\item{lastColumn}{logical. If TRUE, the last column is bold} +\item{last_column}{logical. If TRUE, the last column is bold} -\item{bandedRows}{logical. If TRUE, rows are color banded} +\item{banded_rows}{logical. If TRUE, rows are color banded} -\item{bandedCols}{logical. If TRUE, the columns are color banded} +\item{banded_cols}{logical. If TRUE, the columns are color banded} -\item{applyCellStyle}{apply styles when writing on the sheet} +\item{apply_cell_style}{apply styles when writing on the sheet} -\item{removeCellStyle}{if writing into existing cells, should the cell style be removed?} +\item{remove_cell_style}{if writing into existing cells, should the cell style be removed?} \item{na.strings}{Value used for replacing \code{NA} values from \code{x}. Default \code{na_strings()} uses the special \verb{#N/A} value within the workbook.} \item{inline_strings}{write characters as inline strings} + +\item{...}{additional arguments} } \description{ Write to a worksheet and format as an Excel table diff --git a/man/write_file.Rd b/man/write_file.Rd deleted file mode 100644 index 97aa90642..000000000 --- a/man/write_file.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pugixml.R -\name{write_file} -\alias{write_file} -\title{write xml file} -\usage{ -write_file(head = "", body = "", tail = "", fl = "", escapes = FALSE) -} -\arguments{ -\item{head}{head part of xml} - -\item{body}{body part of xml} - -\item{tail}{tail part of xml} - -\item{fl}{file name with full path} - -\item{escapes}{bool if characters like "&" should be escaped. The default is -no escape, assuming that xml to export is already valid.} -} -\description{ -brings the added benefit of xml checking -} diff --git a/man/write_formula.Rd b/man/write_formula.Rd index c0b89e409..23c78236c 100644 --- a/man/write_formula.Rd +++ b/man/write_formula.Rd @@ -8,13 +8,14 @@ write_formula( wb, sheet, x, - startCol = 1, - startRow = 1, - dims = rowcol_to_dims(startRow, startCol), + dims = rowcol_to_dims(start_row, start_col), + start_col = 1, + start_row = 1, array = FALSE, cm = FALSE, - applyCellStyle = TRUE, - removeCellStyle = FALSE + apply_cell_style = TRUE, + remove_cell_style = FALSE, + ... ) } \arguments{ @@ -24,19 +25,21 @@ write_formula( \item{x}{A character vector.} -\item{startCol}{A vector specifying the starting column to write to.} +\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} -\item{startRow}{A vector specifying the starting row to write to.} +\item{start_col}{A vector specifying the starting column to write to.} -\item{dims}{Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"} +\item{start_row}{A vector specifying the starting row to write to.} \item{array}{A bool if the function written is of type array} \item{cm}{A bool if the function is of type cm (array with hidden curly braces)} -\item{applyCellStyle}{apply styles when writing on the sheet} +\item{apply_cell_style}{apply styles when writing on the sheet} + +\item{remove_cell_style}{if writing into existing cells, should the cell style be removed?} -\item{removeCellStyle}{if writing into existing cells, should the cell style be removed?} +\item{...}{additional arguments} } \description{ Write a a character vector containing Excel formula to a worksheet. diff --git a/man/write_xlsx.Rd b/man/write_xlsx.Rd index ca3ead703..115201a84 100644 --- a/man/write_xlsx.Rd +++ b/man/write_xlsx.Rd @@ -4,14 +4,14 @@ \alias{write_xlsx} \title{write data to an xlsx file} \usage{ -write_xlsx(x, file, asTable = FALSE, ...) +write_xlsx(x, file, as_table = FALSE, ...) } \arguments{ \item{x}{object or a list of objects that can be handled by \code{\link[=write_data]{write_data()}} to write to file} \item{file}{xlsx file name} -\item{asTable}{write using write_datatable as opposed to write_data} +\item{as_table}{write using write_datatable as opposed to write_data} \item{...}{optional parameters to pass to functions: \itemize{ diff --git a/tests/testthat/test-class-comment.R b/tests/testthat/test-class-comment.R index 71146ac0a..f4b5f297b 100644 --- a/tests/testthat/test-class-comment.R +++ b/tests/testthat/test-class-comment.R @@ -94,7 +94,7 @@ test_that("wb_add_comment", { wb2 <- wb_workbook() %>% wb_add_worksheet() %>% - wb_add_comment(col = "A", row = 1, comment = c1) + wb_add_comment(dims = "A1", comment = c1) expect_equal(wb$comments, wb2$comments) @@ -114,10 +114,17 @@ test_that("wb_remove_comment", { add_comment(dims = "A1", comment = c1)$ remove_comment(dims = "A1") - wb2 <- wb_workbook() %>% - wb_add_worksheet() %>% - wb_add_comment(col = "A", row = 1, comment = c1) %>% - wb_remove_comment(col = "A", row = 1) + # deprecated col / row code + wb2 <- wb_workbook() %>% wb_add_worksheet() + expect_warning( + wb2 <- wb2 %>% + wb_add_comment(col = "A", row = 1, comment = c1), + "'col/row' is deprecated." + ) + expect_warning( + wb2 <- wb2 %>% wb_remove_comment(col = "A", row = 1), + "'col/row/gridExpand' is deprecated." + ) expect_equal(wb$comments, wb2$comments) @@ -141,7 +148,7 @@ test_that("removing comment sheet works", { wb <- wb_workbook()$ add_worksheet("Sheet 1")$ - add_comment(1, col = "B", row = 10, comment = c1)$ + add_comment(dims = "B10", comment = c1)$ add_worksheet()$ remove_worksheet(1) diff --git a/tests/testthat/test-class-workbook-wrappers.R b/tests/testthat/test-class-workbook-wrappers.R index 82b72e205..d067c5794 100644 --- a/tests/testthat/test-class-workbook-wrappers.R +++ b/tests/testthat/test-class-workbook-wrappers.R @@ -253,10 +253,10 @@ test_that("wb_grid_lines() is a wrapper", { test_that("wb_add_named_region(), wb_remove_named_region() are wrappers", { wb <- wb_workbook()$add_worksheet("a") - params <- list(sheet = 1, cols = 1, rows = 1, name = "cool") + params <- list(sheet = 1, dims = "A1", name = "cool") expect_wrapper("add_named_region", wb = wb, params = params) # now add the named region so that we can remove it - wb$add_named_region(sheet = 1, cols = 1, rows = 1, name = "cool") + wb$add_named_region(sheet = 1, dims = "A1", name = "cool") expect_wrapper("remove_named_region", wb = wb, params = list(name = "cool")) }) @@ -279,7 +279,7 @@ test_that("wb_get_sheet_visibility(), wb_set_sheet_visibility() are wrappers", { test_that("wb_add_data_validation() is a wrapper", { wb <- wb_workbook()$add_worksheet("a") - params <- list(sheet = 1, cols = 1, rows = 1, type = "whole", operator = "between", value = c(0, 1)) + params <- list(sheet = 1, dims = "A1", type = "whole", operator = "between", value = c(0, 1)) expect_wrapper("add_data_validation", wb = wb, params = params) }) diff --git a/tests/testthat/test-class-workbook.R b/tests/testthat/test-class-workbook.R index 251a148bb..407ac2bb9 100644 --- a/tests/testthat/test-class-workbook.R +++ b/tests/testthat/test-class-workbook.R @@ -127,22 +127,22 @@ test_that("data validation", { add_worksheet("Sheet 1")$ add_data_table(x = iris)$ # whole numbers are fine - add_data_validation(col = 1:3, rows = 2:151, type = "whole", + add_data_validation(dims = "A2:C151", type = "whole", operator = "between", value = c(1, 9) )$ # text width 7-9 is fine - add_data_validation(col = 5, rows = 2:151, type = "textLength", + add_data_validation(dims = "E2:E151", type = "textLength", operator = "between", value = c(7, 9) )$ ## Date and Time cell validation add_worksheet("Sheet 2")$ add_data_table(x = df)$ # date >= 2016-01-01 is fine - add_data_validation(col = 1, rows = 2:12, type = "date", + add_data_validation(dims = "A2:A12", type = "date", operator = "greaterThanOrEqual", value = as.Date("2016-01-01") )$ # a few timestamps are fine - add_data_validation(col = 2, rows = 2:12, type = "time", + add_data_validation(dims = "B2:B12", type = "time", operator = "between", value = df$t[c(4, 8)] )$ ## validate list: validate inputs on one sheet with another @@ -150,7 +150,7 @@ test_that("data validation", { add_data_table(x = iris[1:30, ])$ add_worksheet("Sheet 4")$ add_data(x = sample(iris$Sepal.Length, 10))$ - add_data_validation("Sheet 3", col = 1, rows = 2:31, type = "list", + add_data_validation("Sheet 3", dims = "A2:A31", type = "list", value = "'Sheet 4'!$A$1:$A$10") exp <- c( @@ -198,8 +198,11 @@ test_that("data validation", { wb2$worksheets[[3]]$dataValidations ) - wb2$add_data_validation("Sheet 3", col = 2, rows = 2:31, type = "list", - value = "'Sheet 4'!$A$1:$A$10") + expect_warning( + wb2$add_data_validation("Sheet 3", cols = 2, rows = 2:31, type = "list", + value = "'Sheet 4'!$A$1:$A$10"), + "'cols/rows' is deprecated." + ) exp <- c( "'Sheet 4'!$A$1:$A$10", @@ -211,13 +214,16 @@ test_that("data validation", { ### tests if conditions # test col2int - wb <- wb_workbook()$ - add_worksheet("Sheet 1")$ - add_data_table(x = head(iris))$ - # whole numbers are fine - add_data_validation(col = "A", rows = 2:151, type = "whole", - operator = "between", value = c(1, 9) - ) + expect_warning( + wb <- wb_workbook()$ + add_worksheet("Sheet 1")$ + add_data_table(x = head(iris))$ + # whole numbers are fine + add_data_validation(cols = "A", rows = 2:151, type = "whole", + operator = "between", value = c(1, 9) + ), + "'cols/rows' is deprecated." + ) exp <- "19" got <- wb$worksheets[[1]]$dataValidations @@ -287,7 +293,7 @@ test_that("data validation", { add_worksheet("Sheet 1")$ add_data(x = c(-1:1), colNames = FALSE)$ # whole numbers are fine - add_data_validation(col = 1, rows = 1:3, type = "whole", + add_data_validation(dims = "A1:A3", type = "whole", operator = "greaterThan", value = c(0), errorStyle = "information", errorTitle = "ERROR!", error = "Some error ocurred!", @@ -304,7 +310,7 @@ test_that("data validation", { add_worksheet("Sheet 1")$ add_data(x = data.frame(x = 1, y = 2), colNames = FALSE)$ # whole numbers are fine - add_data_validation(col = 1, rows = 1:3, type = "custom", value = "A1=B1") + add_data_validation(dims = "A1:A3", type = "custom", value = "A1=B1") exp <- "A1=B1" got <- wb$worksheets[[1]]$dataValidations @@ -693,7 +699,7 @@ test_that("various image functions work as expected", { expect_warning( wb$add_worksheet()$add_image(file = img, width = 6, height = 5, dims = NULL, startRow = 2, startCol = 2), - "dims is NULL, startRow/startCol will have no impact" + "'start_col/start_row' is deprecated." ) }) diff --git a/tests/testthat/test-named_regions.R b/tests/testthat/test-named_regions.R index 72d4efbaa..f3fc0d115 100644 --- a/tests/testthat/test-named_regions.R +++ b/tests/testthat/test-named_regions.R @@ -10,8 +10,11 @@ test_that("Maintaining Named Regions on Load", { wb$add_named_region( sheet = 1, name = "iris", - rows = seq_len(nrow(iris) + 1), - cols = seq_len(ncol(iris)) + dims = rowcol_to_dims( + seq_len(nrow(iris) + 1), + seq_len(ncol(iris) + ) + ) ) ## using write_data 'name' argument @@ -144,19 +147,25 @@ test_that("Missing rows in named regions", { wb$add_data(sheet = 1, x = iris[1:11, ], startCol = 1, startRow = 1) delete_data(wb, sheet = 1, cols = 1:2, rows = c(6, 6)) - wb$add_named_region( - sheet = 1, - name = "iris", - rows = 1:(5 + 1), - cols = 1:2 + expect_warning( + wb$add_named_region( + sheet = 1, + name = "iris", + rows = 1:(5 + 1), + cols = 1:2 + ), + "'cols/rows' is deprecated." ) - wb$add_named_region( - sheet = 1, - name = "iris2", - rows = 1:(5 + 2), - cols = 1:2 - ) + expect_warning( + wb$add_named_region( + sheet = 1, + name = "iris2", + rows = 1:(5 + 2), + cols = 1:2 + ), + "'cols/rows' is deprecated." +) ## iris region is rows 1:6 & cols 1:2 ## iris2 region is rows 1:7 & cols 1:2 @@ -220,15 +229,19 @@ test_that("Missing columns in named regions", { wb$add_named_region( sheet = 1, name = "iris", - rows = 1:5, - cols = 1:2 + dims = rowcol_to_dims( + 1:5, + 1:2 + ) ) wb$add_named_region( sheet = 1, name = "iris2", - rows = 1:5, - cols = 1:3 + dims = rowcol_to_dims( + 1:5, + 1:3 + ) ) ## iris region is rows 1:5 & cols 1:2 @@ -372,10 +385,10 @@ test_that("Overwrite and delete named regions", { # no overwrite expect_error(wb$add_data(1, iris[1:11, ], startCol = 1, startRow = 1, name = "iris")) - expect_error(wb$add_named_region(1, name = "iris", rows = 1:5, cols = 1:2)) + expect_error(wb$add_named_region(1, name = "iris", dims = rowcol_to_dims(1:5, 1:2))) # overwrite - wb$add_named_region(1, name = "iris", rows = 1:5, cols = 1:2, overwrite = TRUE) + wb$add_named_region(1, name = "iris", dims = "A1:B5", overwrite = TRUE) exp <- data.frame( name = "iris", @@ -396,7 +409,7 @@ test_that("Overwrite and delete named regions", { wb$remove_named_region(name = "iris") expect_false("iris" %in% wb_get_named_regions(wb)$name) - wb$add_named_region(1, name = "iris", rows = 1:5, cols = 1:2) + wb$add_named_region(1, name = "iris", dims = "A1:B5") expect_identical(wb_get_named_regions(wb), exp) # removing a worksheet removes the named region as well @@ -416,8 +429,10 @@ test_that("load table", { wb$add_named_region( sheet = 2, name = "iris", - rows = seq_len(nrow(iris) + 1), - cols = seq_along(iris) + dims = rowcol_to_dims( + seq_len(nrow(iris) + 1), + seq_along(iris) + ) ) expect_equal(c("iris", "iris_tab"), wb_get_named_regions(wb, tables = TRUE)$name) diff --git a/tests/testthat/test-read_sources.R b/tests/testthat/test-read_sources.R index ad1f51cb9..05dd8db42 100644 --- a/tests/testthat/test-read_sources.R +++ b/tests/testthat/test-read_sources.R @@ -148,7 +148,11 @@ test_that("reading charts", { img <- system.file("extdata", "einstein.jpg", package = "openxlsx2") which(wb$get_sheet_names() == "Uebersicht_Quoten") - wb$add_image(19, img, startRow = 5, startCol = 3, width = 6, height = 5) + expect_warning( + wb$add_image(19, file = img, startRow = 5, startCol = 3, width = 6, height = 5), + "'start_col/start_row' is deprecated." + ) + wb$save(temp) # check that we wrote a chartshape diff --git a/tests/testthat/test-standardize.R b/tests/testthat/test-standardize.R new file mode 100644 index 000000000..c8a04c605 --- /dev/null +++ b/tests/testthat/test-standardize.R @@ -0,0 +1,19 @@ +test_that("standardize works", { + + color <- NULL + standardize_color_names(colour = "green") + expect_equal(get("color"), "green") + + tabColor <- NULL + standardize_color_names(tabColour = "green") + expect_equal(get("tabColor"), "green") + + camelCase <- NULL + standardize_case_names(camelCase = "green") + expect_equal(get("camel_case"), "green") + + tab_color <- NULL + standardize(tabColour = "green") + expect_equal(get("tab_color"), "green") + +})