View source: R/class-workbook-wrappers.R
| wb_set_sheetview | R Documentation |
The wb_set_sheetview() function controls the visual presentation of a
worksheet. It allows you to toggle UI elements like grid lines, row/column
headers, and formula visibility, as well as setting the zoom level and
view mode (e.g., Normal vs. Page Layout).
wb_set_sheetview(
wb,
sheet = current_sheet(),
color_id = NULL,
default_grid_color = NULL,
right_to_left = NULL,
show_formulas = NULL,
show_grid_lines = NULL,
show_outline_symbols = NULL,
show_row_col_headers = NULL,
show_ruler = NULL,
show_white_space = NULL,
show_zeros = NULL,
tab_selected = NULL,
top_left_cell = NULL,
view = NULL,
window_protection = NULL,
workbook_view_id = NULL,
zoom_scale = NULL,
zoom_scale_normal = NULL,
zoom_scale_page_layout_view = NULL,
zoom_scale_sheet_layout_view = NULL,
...
)
wb |
A wbWorkbook object. |
sheet |
The name or index of the worksheet. Defaults to the current sheet. |
color_id, default_grid_color |
Integer; internal color index for grid lines. Default is 64 (automatic). |
right_to_left |
Logical; if |
show_formulas |
Logical; if |
show_grid_lines |
Logical; if |
show_outline_symbols |
Logical; if |
show_row_col_headers |
Logical; if |
show_ruler |
Logical; if |
show_white_space |
Logical; if |
show_zeros |
Logical; if |
tab_selected |
Integer; a zero-based index indicating if this sheet tab is selected. |
top_left_cell |
Character; the address of the cell that should be positioned in the top-left corner of the view (e.g., "B10"). |
view |
Character; the view mode. One of |
window_protection |
Logical; if |
workbook_view_id |
Integer; links the sheet view to a specific global workbook view. |
zoom_scale, zoom_scale_normal, zoom_scale_page_layout_view, zoom_scale_sheet_layout_view |
Integer; the zoom percentage (between 10 and 400). |
... |
Additional arguments. |
Sheet views are saved properties that tell the spreadsheet application how to render the sheet upon opening. These settings are specific to the worksheet and do not affect the actual data or styles of the cells.
Common Use Cases:
Zooming: Use zoom_scale to make large datasets more readable or
to provide a high-level dashboard view.
Clean Layouts: For reports or dashboards, setting show_grid_lines = FALSE
and show_row_col_headers = FALSE creates a cleaner, application-like
interface.
Audit Mode: Setting show_formulas = TRUE is helpful for debugging
complex spreadsheets by displaying the formulas directly in the cells.
Right-to-Left: Essential for spreadsheets in languages like Arabic or Hebrew.
The wbWorkbook object, invisibly.
The wbWorkbook object, invisibly
wb <- wb_workbook()$add_worksheet()
wb$set_sheetview(
zoom_scale = 75,
right_to_left = FALSE,
show_formulas = TRUE,
show_grid_lines = TRUE,
show_outline_symbols = FALSE,
show_row_col_headers = TRUE,
show_ruler = TRUE,
show_white_space = FALSE,
tab_selected = 1,
top_left_cell = "B1",
view = "normal",
window_protection = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.