## create named regions
wb <- wb_workbook()
wb$add_worksheet("Sheet 1")
## specify region
wb$add_data(x = iris, start_col = 1, start_row = 1)
wb$add_named_region(
name = "iris",
dims = wb_dims(x = iris)
)
## using add_data 'name' argument
wb$add_data(sheet = 1, x = iris, name = "iris2", start_col = 10)
## delete one
wb$remove_named_region(name = "iris2")
wb$get_named_regions()
## read named regions
df <- wb_to_df(wb, named_region = "iris")
head(df)
# Extract named regions from a file
out_file <- temp_xlsx()
wb_save(wb, out_file, overwrite = TRUE)
# Load the file as a workbook first, then get named regions.
wb1 <- wb_load(out_file)
wb1$get_named_regions()
Run the code above in your browser using DataLab