View source: R/wb_add_flextable.R
wb_add_flextable | R Documentation |
wb_add_flextable(
wb,
sheet,
ft,
start_col = 1,
start_row = 1,
offset_caption_rows = 0L,
dims = NULL
)
wb |
an openxlsx2 workbook |
sheet |
an openxlsx2 workbook sheet |
ft |
a flextable |
start_col |
a vector specifying the starting column to write to. |
start_row |
a vector specifying the starting row to write to. |
offset_caption_rows |
number of rows to offset the caption by |
dims |
Spreadsheet dimensions that will determine start_col and start_row: "A1", "A1:B2", "A:B" |
an openxlsx2 workbook
if(requireNamespace("flextable", quietly = TRUE)) {
# Create a flextable
ft <- flextable::as_flextable(table(mtcars[,c("am","cyl")]))
# Create a workbook
wb <- openxlsx2::wb_workbook()$add_worksheet("mtcars")
# Add flextable to workbook
wb <- wb_add_flextable(wb, "mtcars", ft)
# Workbook can now be saved wb$save(),
# opened wb$open() - or removed
rm(wb)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.