insertImage: Insert an image into a worksheet

Description Usage Arguments Author(s) See Also Examples

Description

Insert an image into a worksheet

Usage

1
2
insertImage(wb, sheet, file, width = 6, height = 3, startRow = 1,
  startCol = 1, units = "in", dpi = 300)

Arguments

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.

Author(s)

Alexander Walker

See Also

insertPlot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Create a new workbook
wb <- createWorkbook("Ayanami")

## Add some worksheets
addWorksheet(wb, "Sheet 1")
addWorksheet(wb, "Sheet 2")
addWorksheet(wb, "Sheet 3")

## Insert images
img <- system.file("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")
 
## Save workbook
saveWorkbook(wb, "insertImageExample.xlsx", overwrite = TRUE)

awalker89/openxlsx documentation built on May 11, 2019, 4:09 p.m.