View source: R/create_table_of_contents.R
create_table_of_contents | R Documentation |
Excel
) fileThis function adds a table of contents to an Excel
file by reading the
information from the Excel
sheet in, and then using that data to create
the table of contents. It guesses what the information is, see details below.
create_table_of_contents(
file,
title = NA_character_,
overwrite = TRUE,
pull_titles = TRUE,
TOC_sheet_name = "Table of Contents"
)
file |
the file name. |
title |
the title for the table. |
overwrite |
logical. When |
pull_titles |
when |
TOC_sheet_name |
string. the sheet name for the table of contents. |
This function uses the sheet names to create the table of contents. For the titles it pulls the text that is the position A1 in each of the sheets. It chooses this as this is the default location of titles when you write a xlr_table with write_xlsx.
Returns a logical or error if writing the file succeeded.
library(xlr)
library(openxlsx)
table_list <- list("Sheet name 1" = mtcars,
"Sheet name 2" = mtcars)
output_file <- "example_file.xlsx"
# using write xlsx we create an `Excel` document
# You could use xlr::write_xlsx to create a table of
# contents automatically.
write.xlsx(table_list,
output_file)
# Now add the table of contents to the existing file
create_table_of_contents(output_file,
"A workbook with example tables",
# it only makes sense to pull titles when
# the first cell has a text description
pull_titles = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.