`xl_chartsheet()` is a worksheet-sized chart: a tab of its own holding one chart and no cells. Give it to [write_xlsx()] in place of a data frame.
Because a chartsheet has no cells, every range in the chart's series must name the sheet it plots — `list(sheet = "Data", cols = "revenue")` or `"Data!B2:B10"`. A bare `list(cols = )` has nothing to resolve against and is refused.
A chartsheet supports only part of what a worksheet does, and the parts it does not are refused rather than dropped: of [xl_page_setup()] it takes the orientation, paper size, margins and the header and footer; of [xl_sheet_view()] it takes `active`, `selected`, `visible` and `first_tab`.
Arguments
- chart
The [xl_chart()] to fill the sheet with.
- tab_color
The colour of the sheet tab.
- zoom
The zoom level as a percentage, 10 to 400.
- protect
`TRUE`, a password string, or a named list. A chartsheet has no cells, so of Excel's protection options it takes only `no_content` (let the chart be edited) and `no_objects` (let the shapes on it be edited); the worksheet options are refused by name.
- page
An [xl_page_setup()] describing how it prints.
- view
An [xl_sheet_view()] setting the tab state.
See also
[xl_chart], [xl_sheet]
Other images and charts:
xl_chart(),
xl_chart_axis(),
xl_chart_error_bars(),
xl_chart_labels(),
xl_chart_legend(),
xl_chart_marker(),
xl_chart_series(),
xl_chart_table(),
xl_chart_trendline(),
xl_image()
Examples
sales <- data.frame(quarter = c("Q1", "Q2"), revenue = c(10, 25))
chart <- xl_chart("column",
xl_chart_series(values = list(sheet = "Data",
cols = "revenue")))
write_xlsx(list(Data = sales, Overview = xl_chartsheet(chart)),
tempfile(fileext = ".xlsx"))
