Learn R Programming

openxlsx2 (version 0.6.1)

wb_remove_tables: Remove an Excel table in a workbook

Description

List Excel tables in a workbook

Usage

wb_remove_tables(wb, sheet = current_sheet(), table)

Value

character vector of table names on the specified sheet

Arguments

wb

A workbook object

sheet

A name or index of a worksheet

table

Name of table to remove. See wb_get_tables()

Examples

Run this code

wb <- wb_workbook()
wb$add_worksheet(sheet = "Sheet 1")
wb$add_worksheet(sheet = "Sheet 2")
wb$add_data_table(sheet = "Sheet 1", x = iris, tableName = "iris")
wb$add_data_table(sheet = 1, x = mtcars, tableName = "mtcars", startCol = 10)


wb <- wb_remove_worksheet(wb, sheet = 1) ## delete worksheet removes table objects

wb$add_data_table(sheet = 1, x = iris, tableName = "iris")
wb$add_data_table(sheet = 1, x = mtcars, tableName = "mtcars", startCol = 10)

## wb_remove_tables() deletes table object and all data
wb_get_tables(wb, sheet = 1)
wb$remove_tables(sheet = 1, table = "iris")
wb$add_data_table(sheet = 1, x = iris, tableName = "iris", startCol = 1)

wb_get_tables(wb, sheet = 1)
wb$remove_tables(sheet = 1, table = "iris")
wb$add_data_table(sheet = 1, x = iris, tableName = "iris", startCol = 1)

Run the code above in your browser using DataLab