walk_regions {tatoo}R Documentation

Apply a function to all named regions on an openxlsx Workbook

Description

This applies a .fun to all named regions in a workbook names match .pattern. This is especially useful since as_workbook() methods for Tatoo_tables add named regions for certain parts of the Table. See also vignette("named_regions") for how the names of named regions are constructed by tatoo.

Usage

walk_regions(.wb, .pattern = ".*", .fun, ...)

map_regions(.wb, .pattern = ".*", .fun, ...)

Arguments

.wb

an openxlsx Workbook Object

.pattern

character scalar. A regex filter pattern for named region names (passed on to grep())

.fun

A function with the formal arguments wb, sheet and either rows, cols, or both. For example: openxlsx::addStyle(), openxlsx::addFilter(), openxlsx::setRowHeights(), openxlsx::setColWidths()

...

passed on to .fun

Value

walk_regions returns .wb. map_regions returns a modified copy of .wb

Examples


x <- iris
title(iris) <- "Iris example table"
wb <- as_workbook(iris)

regions(wb)  # display regions


# Apply a style
# Keep in mind that openxlsx functions modify worksheets by reference.
# If you do not want this behaviour you can use map_regions instead.

style <- openxlsx::createStyle(textDecoration = "bold")
walk_regions(
  wb,
  .pattern = "colnames.*",
  .fun = openxlsx::addStyle,
  style = style
)

## Not run: 
  openxlsx::openXL(wb)

## End(Not run)




[Package tatoo version 1.1.2 Index]