View source: R/class-workbook-wrappers.R
| wb_clean_sheet | R Documentation |
The wb_clean_sheet() function removes data, formulas, and formatting from
a worksheet. It can be used to wipe an entire sheet clean or to target
specific cell regions (dims). This is particularly useful when you want
to reuse an existing sheet structure but replace the data or reset the styling.
wb_clean_sheet(
wb,
sheet = current_sheet(),
dims = NULL,
numbers = TRUE,
characters = TRUE,
styles = TRUE,
merged_cells = TRUE,
hyperlinks = TRUE
)
wb |
A wbWorkbook object. |
sheet |
The name or index of the worksheet to clean. Defaults to the current sheet. |
dims |
Optional character string defining a cell range (e.g., "A1:G20").
If |
numbers |
Logical; if |
characters |
Logical; if |
styles |
Logical; if |
merged_cells |
Logical; if |
hyperlinks |
Logical; if |
Unlike deleting a worksheet, cleaning a sheet preserves the sheet's existence, name, and properties (like tab color or sheet views) while emptying the cell-level data.
Selective Removal: By toggling the logical arguments, you can choose exactly what to discard. For example, you can remove data but keep the cell styles (borders, fills), or vice-versa.
Numbers/Characters: Targeting these specifically allows you to clear constants while potentially leaving other elements intact.
Styles: Resets cells to the workbook's default appearance.
Merged Cells: Unmerges ranges; if dims is provided, only merges
within that range are broken.
The wbWorkbook object, invisibly.
Currently, this function does not remove objects like images, charts, comments, or pivot tables.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.