R6 class that manages a drawing file for an xlsx
sheet. Used internally by sheet_add_drawing() methods.
openxml_document -> xlsx_drawing
Inherited methods
openxml_document$dir_name()openxml_document$feed()openxml_document$file_name()openxml_document$get()openxml_document$name()openxml_document$rel_df()openxml_document$relationship()openxml_document$remove()openxml_document$replace_xml()openxml_document$save()
xlsx_drawing$new()Create or reuse a drawing for a sheet.
xlsx_drawing$new(package_dir, sheet_obj, content_type)package_dirpath to the unpacked xlsx directory
sheet_obja sheet R6 object
content_typea content_type R6 object
xlsx_drawing$add_chart_anchor()Place a chart on the sheet. The chart can be positioned in three ways, matching Excel's own "Format Picture" options:
Move and size with cells (Excel's default): supply
from and to as cell references (e.g. "B2" and
"H20"). The chart spans those two cells and follows them
when rows/columns are inserted or resized.
Move but don't size with cells: supply from only.
The chart anchors to that cell with the size set by
width/height.
Fixed position: leave from and to NULL. The
chart is placed at left/top with size width/height,
independent of cell layout.
xlsx_drawing$add_chart_anchor(
chart_rid,
left = 1,
top = 1,
width = 6,
height = 4,
from = NULL,
to = NULL,
edit_as = c("twoCell", "oneCell", "absolute"),
graphic_uri = ooxml_chart_uris("drawingml")$graphic_uri,
chart_inner = NULL
)chart_ridrelationship id of the chart (returned by
add_chart_rel()). Ignored when chart_inner is supplied
explicitly.
left, toptop-left position in inches (fixed-position mode)
width, heightsize in inches
from, toExcel cell references like "C4" (1-based,
case-insensitive)
edit_ashow Excel should treat the drawing when rows or
columns are resized: "twoCell" (move and size with cells, the
default), "oneCell" (move only) or "absolute" (neither). Only
meaningful when both from and to are supplied.
graphic_urichart family URI; defaults to the classic
chart family. Use ooxml_chart_uris() to obtain the value
for the chartEx family.
chart_inneradvanced. XML fragment referencing the chart
part. Leave NULL to let the method build the right reference
from graphic_uri.
xlsx_drawing$add_chart_rel()Register a chart part with the drawing. Returns
the relationship id, to be passed to add_chart_anchor().
xlsx_drawing$add_chart_rel(
chart_basename,
rel_type = ooxml_chart_uris("drawingml")$rel_type
)chart_basenamefilename of the chart XML
rel_typechart family relationship type; defaults to the
classic chart family. Use ooxml_chart_uris() to obtain the
value for the chartEx family.
xlsx_drawing$add_image_rel()Add a relationship from the drawing to a media image.
xlsx_drawing$add_image_rel(image_basename)image_basenamefilename (without directory) of the image
sitting in xl/media/.
xlsx_drawing$add_image_anchor()Place an image on the sheet. Positioning works
the same way as add_chart_anchor(): supply from and to
to move and size with cells, from only to move (but not
resize) with cells, or leave both NULL for a fixed position.
xlsx_drawing$add_image_anchor(
image_rid,
left = 1,
top = 1,
width = 2,
height = 2,
from = NULL,
to = NULL,
edit_as = c("twoCell", "oneCell", "absolute"),
alt = ""
)image_ridrelationship id of the image (returned by
add_image_rel())
left, toptop-left position in inches (fixed-position mode)
width, heightsize in inches
from, toExcel cell references like "C4" (1-based,
case-insensitive)
edit_ashow Excel should treat the drawing when rows or
columns are resized: "twoCell" (move and size with cells, the
default), "oneCell" (move only) or "absolute" (neither). Only
meaningful when both from and to are supplied.
altalternative text
xlsx_drawing$clone()The objects of this class are cloneable with this method.
xlsx_drawing$clone(deep = FALSE)deepWhether to make a deep clone.