Skip to content

Commit

Permalink
Tweaks to docs (#812)
Browse files Browse the repository at this point in the history
* Progress.

* Remove examples from wbWorkbook + use R6 support from roxygen2.

* Tweaks.

* Capitalization.

* Avoid loading testthat when using `add_plot()` by inlining the `testthat::is_testing()` function.

* [ci skip] reindent.
  • Loading branch information
olivroy authored Oct 2, 2023
1 parent 1532bdf commit 5ae95d8
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 513 deletions.
87 changes: 61 additions & 26 deletions R/class-workbook-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ wb_protect_worksheet <- function(
#' @param lock_structure Whether the workbook structure should be locked
#' @param lock_windows Whether the window position of the spreadsheet should be
#' locked
#' @param type Lock type (see details)
#' @param type Lock type (see **Details**)
#' @param file_sharing Whether to enable a popup requesting the unlock password
#' is prompted
#' @param username The username for the `file_sharing` popup
Expand All @@ -1565,12 +1565,10 @@ wb_protect_worksheet <- function(
#' @details
#' Lock types:
#'
#' \describe{
#' \item{`1` }{xlsx with password (default)}
#' \item{`2` }{xlsx recommends read-only}
#' \item{`4` }{xlsx enforces read-only}
#' \item{`8` }{xlsx is locked for annotation}
#' }
#' * `1` xlsx with password (default)
#' * `2` xlsx recommends read-only
#' * `4` xlsx enforces read-only
#' * `8` xlsx is locked for annotation
#'
#' @export
#' @examples
Expand Down Expand Up @@ -2600,6 +2598,32 @@ wb_set_cell_style <- function(wb, sheet = current_sheet(), dims, style) {
#' left_color = wb_color(hex = "FFFFFF00"), right_color = wb_color(hex = "FFFF7F00"),
#' bottom_color = wb_color(hex = "FFFF0000"))
#' wb <- wb_add_border(wb, 1, dims = "D28:E28")
#'
#' # With chaining
#'
#' wb <- wb_workbook()
#' wb$add_worksheet("S1")$add_data("S1", mtcars)
#' wb$add_border(1, dims = "A1:K1",
#' left_border = NULL, right_border = NULL,
#' top_border = NULL, bottom_border = "double")
#' wb$add_border(1, dims = "A5",
#' left_border = "dotted", right_border = "dotted",
#' top_border = "hair", bottom_border = "thick")
#' wb$add_border(1, dims = "C2:C5")
#' wb$add_border(1, dims = "G2:H3")
#' wb$add_border(1, dims = "G12:H13",
#' left_color = wb_color(hex = "FF9400D3"), right_color = wb_color(hex = "FF4B0082"),
#' top_color = wb_color(hex = "FF0000FF"), bottom_color = wb_color(hex = "FF00FF00"))
#' wb$add_border(1, dims = "A20:C23")
#' wb$add_border(1, dims = "B12:D14",
#' left_color = wb_color(hex = "FFFFFF00"), right_color = wb_color(hex = "FFFF7F00"),
#' bottom_color = wb_color(hex = "FFFF0000"))
#' wb$add_border(1, dims = "D28:E28")
#' # if (interactive()) wb$open()
#'
#' wb <- wb_workbook()
#' wb$add_worksheet("S1")$add_data("S1", mtcars)
#' wb$add_border(1, dims = "A2:K33", inner_vgrid = "thin", inner_vcolor = c(rgb="FF808080"))
#' @family styles
#' @export
wb_add_border <- function(
Expand Down Expand Up @@ -2733,6 +2757,9 @@ wb_add_fill <- function(
#' @examples
#' wb <- wb_workbook() %>% wb_add_worksheet("S1") %>% wb_add_data("S1", mtcars)
#' wb %>% wb_add_font("S1", "A1:K1", name = "Arial", color = wb_color(theme = "4"))
#' # With chaining
#' wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
#' wb$add_font("S1", "A1:K1", name = "Arial", color = wb_color(theme = "4"))
#' @return A `wbWorkbook`, invisibly
#' @family styles
#' @export
Expand Down Expand Up @@ -2793,8 +2820,11 @@ wb_add_font <- function(
#' @param dims the cell range
#' @param numfmt either an id or a character
#' @examples
#' wb <- wb_workbook() %>% wb_add_worksheet("S1") %>% wb_add_data("S1", mtcars)
#' wb %>% wb_add_numfmt("S1", dims = "F1:F33", numfmt = "#.0")
#' wb <- wb_workbook() %>% wb_add_worksheet("S1") %>% wb_add_data("S1", mtcars)
#' wb %>% wb_add_numfmt("S1", dims = "F1:F33", numfmt = "#.0")
#' # Chaining
#' wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
#' wb$add_numfmt("S1", "A1:A33", numfmt = 1)
#' @return The `wbWorkbook` object, invisibly.
#' @family styles
#' @export
Expand Down Expand Up @@ -2848,20 +2878,25 @@ wb_add_numfmt <- function(
#' @param xf_id xf ID to apply
#' @param ... additional arguments
#' @examples
#' wb <-
#' wb_workbook() %>%
#' wb_add_worksheet("S1") %>%
#' wb_add_data("S1", x = mtcars)
#'
#' wb %>%
#' wb_add_cell_style(
#' "S1",
#' dims = "A1:K1",
#' text_rotation = "45",
#' horizontal = "center",
#' vertical = "center",
#' wrap_text = "1"
#' )
#' wb <- wb_workbook() %>%
#' wb_add_worksheet("S1") %>%
#' wb_add_data("S1", x = mtcars)
#'
#' wb %>%
#' wb_add_cell_style(
#' dims = "A1:K1",
#' text_rotation = "45",
#' horizontal = "center",
#' vertical = "center",
#' wrap_text = "1"
#' )
#' # Chaining
#' wb <- wb_workbook()$add_worksheet("S1")$add_data(x = mtcars)
#' wb$add_cell_style(dims = "A1:K1",
#' text_rotation = "45",
#' horizontal = "center",
#' vertical = "center",
#' wrap_text = "1")
#' @return The `wbWorkbook` object, invisibly
#' @family styles
#' @export
Expand Down Expand Up @@ -3104,7 +3139,7 @@ wb_remove_comment <- function(
#' Adds a person to a workbook, so that they can be the author of threaded
#' comments in a workbook with [wb_add_thread()]
#'
#' @name wb_person
#' @name person-wb
#' @param wb a Workbook
#' @param name the name of the person to display.
#' @param id (optional) the display id
Expand All @@ -3129,7 +3164,7 @@ wb_add_person <- function(
)
}

#' @rdname wb_person
#' @rdname person-wb
#' @export
wb_get_person <- function(wb, name = NULL) {
assert_workbook(wb)
Expand All @@ -3156,7 +3191,7 @@ wb_get_person <- function(wb, name = NULL) {
#' `getOption("openxlsx2.thread_id")` if set.
#' @param reply Is the comment a reply? (default `FALSE`)
#' @param resolve Should the comment be resolved? (default `FALSE`)
#' @seealso [wb_add_comment()] [wb_person]
#' @seealso [wb_add_comment()] [`person-wb`]
#' @family worksheet content functions
#' @examples
#' wb <- wb_workbook()$add_worksheet()
Expand Down
Loading

0 comments on commit 5ae95d8

Please sign in to comment.