Helper to add shared hyperlinks into a worksheet or remove shared hyperlinks from a worksheet
Usage
wb_add_hyperlink(
wb,
sheet = current_sheet(),
dims = "A1",
target = NULL,
tooltip = NULL,
is_external = TRUE,
col_names = FALSE
)
wb_remove_hyperlink(wb, sheet = current_sheet(), dims = NULL)
Arguments
- wb
A Workbook object containing a worksheet.
- sheet
The worksheet to write to. (either as index or name)
- dims
Spreadsheet dimensions that will determine where the hyperlink reference spans: "A1", "A1:B2", "A:B"
- target
An optional target, if no target is specified, it is assumed that the cell already contains a reference (the cell could be a url or a filename)
- tooltip
An optional description for a variable that will be visible when hovering over the link text in the spreadsheet
- is_external
A logical indicating if the hyperlink is external (a url, a mail address, a file) or internal (a reference to worksheet cells)
- col_names
Whether or not the object contains column names. If yes the first column of the dimension will be ignored
Details
There are multiple ways to add hyperlinks into a worksheet. One way is to construct a formula with create_hyperlink()
another is to assign a class hyperlink
to a column of a data frame.
Contrary to the previous method, shared hyperlinks are not cell formulas in the worksheet, but references in the worksheet relationship and hyperlinks in the worksheet xml structure.
These shared hyperlinks can be reused and they are not visible to spreadsheet users as HYPERLINK()
formulas.
See also
Other workbook wrappers:
base_font-wb
,
col_widths-wb
,
creators-wb
,
grouping-wb
,
row_heights-wb
,
wb_add_chartsheet()
,
wb_add_data()
,
wb_add_data_table()
,
wb_add_formula()
,
wb_add_pivot_table()
,
wb_add_slicer()
,
wb_add_worksheet()
,
wb_base_colors
,
wb_clone_worksheet()
,
wb_copy_cells()
,
wb_freeze_pane()
,
wb_merge_cells()
,
wb_save()
,
wb_set_last_modified_by()
,
wb_workbook()
Other worksheet content functions:
col_widths-wb
,
filter-wb
,
grouping-wb
,
named_region-wb
,
row_heights-wb
,
wb_add_conditional_formatting()
,
wb_add_data()
,
wb_add_data_table()
,
wb_add_formula()
,
wb_add_pivot_table()
,
wb_add_slicer()
,
wb_add_thread()
,
wb_freeze_pane()
,
wb_merge_cells()
Examples
wb <- wb_workbook()$add_worksheet()$
add_data(x = "openxlsx2 on CRAN")$
add_hyperlink(target = "https://cran.r-project.org/package=openxlsx2",
tooltip = "The canonical form to link to our CRAN page.")
wb$remove_hyperlink()