setHyperlink-methods

0th

Percentile

Setting hyperlinks

Sets hyperlinks for specific cells in a '>workbook.

Keywords
methods, utilities
Usage
# S4 method for workbook,missing,character
setHyperlink(object,formula,sheet,row,col,type,address)
# S4 method for workbook,missing,numeric
setHyperlink(object,formula,sheet,row,col,type,address)
# S4 method for workbook,character,missing
setHyperlink(object,formula,sheet,row,col,type,address)
Arguments
object

The '>workbook to use

formula

A formula specification in the form Sheet!B8:C17. Use either the argument formula or the combination of sheet, row and col.

sheet

Name or index of the sheet the cell is on. Use either the argument formula or the combination of sheet, row and col.

row

Row index of the cell to apply the cellstyle to.

col

Column index of the cell to apply the cellstyle to.

type

Hyperlink type. See the corresponding "HYPERLINK.*" constants from the XLC object.

address

Hyperlink address. This needs to be a valid URI including scheme. E.g. for email mailto:myself@me.org, for a URL http://www.somewhere.net or for a file file:///a/b/c.dat

Details

Sets a hyperlink for the specified cells. Note that '>cellstyles for hyperlinks can be defined independently using setCellStyle. The arguments are vectorized such that multiple hyperlinks can be set in one method call. Use either the argument formula or the combination of sheet, row and col.

See Also

'>workbook, setCellStyle

Aliases
  • setHyperlink
  • setHyperlink-methods
  • setHyperlink,workbook,missing,character-method
  • setHyperlink,workbook,missing,numeric-method
  • setHyperlink,workbook,character,missing-method
Examples
# NOT RUN {
# Load workbook (create if not existing)
wb <- loadWorkbook("setHyperlink.xlsx", create = TRUE)

# Create a sheet named 'mtcars'
createSheet(wb, name = "mtcars")


# Write built-in data set 'mtcars' to the above defined worksheet
writeWorksheet(wb, mtcars, sheet = "mtcars", rownames = "Car")

# Set hyperlinks
links <- paste0("http://www.google.com?q=", gsub(" ", "+", rownames(mtcars)))
setHyperlink(wb, sheet = "mtcars", row = seq_len(nrow(mtcars)) + 1, col = 1,
  type = XLC$HYPERLINK.URL, address = links)

# Save workbook (this actually writes the file to disk)
saveWorkbook(wb)
# }
Documentation reproduced from package XLConnect, version 0.2-14, License: GPL-3

Community examples

Looks like there are no examples yet.