Skip to content

Commit

Permalink
* wb_set_bookview
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Jul 10, 2023
1 parent 78cec09 commit 2d0d4f5
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 123 deletions.
77 changes: 40 additions & 37 deletions R/class-workbook-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1111,52 +1111,55 @@ wb_get_base_font <- function(wb) {
#'
#' Get the base font used in the workbook.
#' @param wb A [wbWorkbook] object
#' @param activeTab activeTab
#' @param autoFilterDateGrouping autoFilterDateGrouping
#' @param firstSheet firstSheet
#' @param active_tab activeTab
#' @param auto_filter_date_grouping autoFilterDateGrouping
#' @param first_sheet firstSheet
#' @param minimized minimized
#' @param showHorizontalScroll showHorizontalScroll
#' @param showSheetTabs showSheetTabs
#' @param showVerticalScroll showVerticalScroll
#' @param tabRatio tabRatio
#' @param show_horizontal_scroll showHorizontalScroll
#' @param show_sheet_tabs showSheetTabs
#' @param show_vertical_scroll showVerticalScroll
#' @param tab_ratio tabRatio
#' @param visibility visibility
#' @param windowHeight windowHeight
#' @param windowWidth windowWidth
#' @param xWindow xWindow
#' @param yWindow yWindow
#' @param window_height windowHeight
#' @param window_width windowWidth
#' @param x_window xWindow
#' @param y_window yWindow
#' @param ... additional arguments
#' @return The `wbWorkbook` object
#' @export
wb_set_bookview <- function(
wb,
activeTab = NULL,
autoFilterDateGrouping = NULL,
firstSheet = NULL,
minimized = NULL,
showHorizontalScroll = NULL,
showSheetTabs = NULL,
showVerticalScroll = NULL,
tabRatio = NULL,
visibility = NULL,
windowHeight = NULL,
windowWidth = NULL,
xWindow = NULL,
yWindow = NULL
active_tab = NULL,
auto_filter_date_grouping = NULL,
first_sheet = NULL,
minimized = NULL,
show_horizontal_scroll = NULL,
show_sheet_tabs = NULL,
show_vertical_scroll = NULL,
tab_ratio = NULL,
visibility = NULL,
window_height = NULL,
window_width = NULL,
x_window = NULL,
y_window = NULL,
...
) {
assert_workbook(wb)
wb$clone()$set_bookview(
activeTab = activeTab,
autoFilterDateGrouping = autoFilterDateGrouping,
firstSheet = firstSheet,
minimized = minimized,
showHorizontalScroll = showHorizontalScroll,
showSheetTabs = showSheetTabs,
showVerticalScroll = showVerticalScroll,
tabRatio = tabRatio,
visibility = visibility,
windowHeight = windowHeight,
windowWidth = windowWidth,
xWindow = xWindow,
yWindow = yWindow
active_tab = active_tab,
auto_filter_date_grouping = auto_filter_date_grouping,
first_sheet = first_sheet,
minimized = minimized,
show_horizontal_scroll = show_horizontal_scroll,
show_sheet_tabs = show_sheet_tabs,
show_vertical_scroll = show_vertical_scroll,
tab_ratio = tab_ratio,
visibility = visibility,
window_height = window_height,
window_width = window_width,
x_window = x_window,
y_window = y_window,
... = ...
)
}

Expand Down
86 changes: 45 additions & 41 deletions R/class-workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -2584,36 +2584,40 @@ wbWorkbook <- R6::R6Class(

#' @description
#' Set the book views
#' @param activeTab activeTab
#' @param autoFilterDateGrouping autoFilterDateGrouping
#' @param firstSheet firstSheet
#' @param active_tab activeTab
#' @param auto_filter_date_grouping autoFilterDateGrouping
#' @param first_sheet firstSheet
#' @param minimized minimized
#' @param showHorizontalScroll showHorizontalScroll
#' @param showSheetTabs showSheetTabs
#' @param showVerticalScroll showVerticalScroll
#' @param tabRatio tabRatio
#' @param show_horizontal_scroll showHorizontalScroll
#' @param show_sheet_tabs showSheetTabs
#' @param show_vertical_scroll showVerticalScroll
#' @param tab_ratio tabRatio
#' @param visibility visibility
#' @param windowHeight windowHeight
#' @param windowWidth windowWidth
#' @param xWindow xWindow
#' @param yWindow yWindow
#' @param window_height windowHeight
#' @param window_width windowWidth
#' @param x_window xWindow
#' @param y_window yWindow
#' @param ... additional arguments
#' @return The `wbWorkbook` object
set_bookview = function(
activeTab = NULL,
autoFilterDateGrouping = NULL,
firstSheet = NULL,
minimized = NULL,
showHorizontalScroll = NULL,
showSheetTabs = NULL,
showVerticalScroll = NULL,
tabRatio = NULL,
visibility = NULL,
windowHeight = NULL,
windowWidth = NULL,
xWindow = NULL,
yWindow = NULL
active_tab = NULL,
auto_filter_date_grouping = NULL,
first_sheet = NULL,
minimized = NULL,
show_horizontal_scroll = NULL,
show_sheet_tabs = NULL,
show_vertical_scroll = NULL,
tab_ratio = NULL,
visibility = NULL,
window_height = NULL,
window_width = NULL,
x_window = NULL,
y_window = NULL,
...
) {

standardize_case_names(...)

wbv <- self$workbook$bookViews

if (is.null(wbv)) {
Expand All @@ -2625,19 +2629,19 @@ wbWorkbook <- R6::R6Class(
wbv <- xml_attr_mod(
wbv,
xml_attributes = c(
activeTab = as_xml_attr(activeTab),
autoFilterDateGrouping = as_xml_attr(autoFilterDateGrouping),
firstSheet = as_xml_attr(firstSheet),
activeTab = as_xml_attr(active_tab),
autoFilterDateGrouping = as_xml_attr(auto_filter_date_grouping),
firstSheet = as_xml_attr(first_sheet),
minimized = as_xml_attr(minimized),
showHorizontalScroll = as_xml_attr(showHorizontalScroll),
showSheetTabs = as_xml_attr(showSheetTabs),
showVerticalScroll = as_xml_attr(showVerticalScroll),
tabRatio = as_xml_attr(tabRatio),
showHorizontalScroll = as_xml_attr(show_horizontal_scroll),
showSheetTabs = as_xml_attr(show_sheet_tabs),
showVerticalScroll = as_xml_attr(show_vertical_scroll),
tabRatio = as_xml_attr(tab_ratio),
visibility = as_xml_attr(visibility),
windowHeight = as_xml_attr(windowHeight),
windowWidth = as_xml_attr(windowWidth),
xWindow = as_xml_attr(xWindow),
yWindow = as_xml_attr(yWindow)
windowHeight = as_xml_attr(window_height),
windowWidth = as_xml_attr(window_width),
xWindow = as_xml_attr(x_window),
yWindow = as_xml_attr(y_window)
),
remove_empty_attr = FALSE
)
Expand Down Expand Up @@ -7505,12 +7509,12 @@ wbWorkbook <- R6::R6Class(

if (is.null(self$workbook$bookViews))
self$set_bookview(
xWindow = 0,
yWindow = 0,
windowWidth = 13125,
windowHeight = 13125,
firstSheet = visible_sheet_index - 1L,
activeTab = visible_sheet_index - 1L
x_window = 0,
y_window = 0,
window_width = 13125,
window_height = 13125,
first_sheet = visible_sheet_index - 1L,
active_tab = visible_sheet_index - 1L
)

# Failsafe: hidden sheet can not be selected.
Expand Down
2 changes: 1 addition & 1 deletion R/wb_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ wb_set_active_sheet <- function(wb, sheet) {
# active tab requires a c index
assert_workbook(wb)
sheet <- wb_validate_sheet(wb, sheet)
wb$clone()$set_bookview(activeTab = sheet - 1L)
wb$clone()$set_bookview(active_tab = sheet - 1L)
}

#' @name select_active_sheet
Expand Down
47 changes: 25 additions & 22 deletions man/wbWorkbook.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 25 additions & 22 deletions man/wb_set_bookview.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2d0d4f5

Please sign in to comment.