R6 class that manages a drawing file for an xlsx
sheet. Used internally by sheet_add_drawing() methods.
Methods
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.
Usage
xlsx_drawing$new(package_dir, sheet_obj, content_type)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
fromandtoas 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
fromonly. The chart anchors to that cell with the size set bywidth/height.Fixed position: leave
fromandtoNULL. The chart is placed atleft/topwith sizewidth/height, independent of cell layout.
Usage
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
)Arguments
chart_ridrelationship id of the chart (returned by
add_chart_rel()). Ignored whenchart_inneris 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 bothfromandtoare 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
NULLto let the method build the right reference fromgraphic_uri.
xlsx_drawing$add_chart_rel()
Register a chart part with the drawing. Returns
the relationship id, to be passed to add_chart_anchor().
Usage
xlsx_drawing$add_chart_rel(
chart_basename,
rel_type = ooxml_chart_uris("drawingml")$rel_type
)Arguments
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_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.
Usage
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 = ""
)Arguments
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 bothfromandtoare supplied.altalternative text
