insertImage | R Documentation |
Insert an image into a worksheet
insertImage(
wb,
sheet,
file,
width = 6,
height = 3,
startRow = 1,
startCol = 1,
units = "in",
dpi = 300,
address
)
wb |
A workbook object |
sheet |
A name or index of a worksheet |
file |
An image file. Valid file types are: jpeg, png, bmp |
width |
Width of figure. |
height |
Height of figure. |
startRow |
Row coordinate of upper left corner of the image |
startCol |
Column coordinate of upper left corner of the image |
units |
Units of width and height. Can be "in", "cm" or "px" |
dpi |
Image resolution used for conversion between units. |
address |
An optional character string specifying an external URL, relative or absolute path to a file, or mailto string (e.g. "mailto:example@example.com") that will be opened when the image is clicked. |
Alexander Walker
insertPlot()
## Create a new workbook
wb <- createWorkbook("Ayanami")
## Add some worksheets
addWorksheet(wb, "Sheet 1")
addWorksheet(wb, "Sheet 2")
addWorksheet(wb, "Sheet 3")
addWorksheet(wb, "Sheet 4")
## Insert images
img <- system.file("extdata", "einstein.jpg", package = "openxlsx")
insertImage(wb, "Sheet 1", img, startRow = 5, startCol = 3, width = 6, height = 5)
insertImage(wb, 2, img, startRow = 2, startCol = 2)
insertImage(wb, 3, img, width = 15, height = 12, startRow = 3, startCol = "G", units = "cm")
insertImage(wb, 4, img, address = "https://github.com/ycphs/openxlsx")
## Save workbook
## Not run:
saveWorkbook(wb, "insertImageExample.xlsx", overwrite = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.