UmyaSpreadsheet.WorkbookViewFunctions (umya_spreadsheet_ex v0.7.0)
View SourceFunctions for configuring how the workbook is displayed in the Excel application. These settings affect the overall workbook window rather than individual sheet views.
This module provides functions to:
- Get and set the active tab (worksheet) when the workbook is opened
- Get and set the position and size of the Excel application window
Summary
Functions
Gets the index of the active tab (worksheet) when the workbook is opened.
Gets the position and size settings for the workbook window in Excel.
Sets which tab (worksheet) is active when the workbook is opened.
Sets the position and size of the workbook window when opened in Excel.
Functions
Gets the index of the active tab (worksheet) when the workbook is opened.
Tab indices are zero-based, meaning the first tab has index 0, the second has index 1, etc.
Parameters
spreadsheet
- The spreadsheet struct
Returns
{:ok, tab_index}
where tab_index is the zero-based index of the active tab{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, active_tab} = UmyaSpreadsheet.WorkbookViewFunctions.get_active_tab(spreadsheet)
# active_tab = 2 (third worksheet is active)
Gets the position and size settings for the workbook window in Excel.
Parameters
spreadsheet
- The spreadsheet struct
Returns
{:ok, window_info}
where window_info is a map containing position and size information with keys:x_position
,:y_position
,:width
, and:height
{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, window_info} = UmyaSpreadsheet.WorkbookViewFunctions.get_workbook_window_position(spreadsheet)
# window_info = %{"x_position" => "240", "y_position" => "105", "width" => "14805", "height" => "8010"}
Sets which tab (worksheet) is active when the workbook is opened.
Parameters
spreadsheet
- The spreadsheet structtab_index
- The zero-based index of the tab to make active
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
# Make the second tab active when opening the file
:ok = UmyaSpreadsheet.WorkbookViewFunctions.set_active_tab(spreadsheet, 1)
# Make the first tab active
:ok = UmyaSpreadsheet.WorkbookViewFunctions.set_active_tab(spreadsheet, 0)
Sets the position and size of the workbook window when opened in Excel.
Parameters
spreadsheet
- The spreadsheet structx_position
- The horizontal position of the window in pixelsy_position
- The vertical position of the window in pixelswindow_width
- The width of the window in pixelswindow_height
- The height of the window in pixels
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
# Set the workbook to open at position (100, 50) with a size of 800x600
:ok = UmyaSpreadsheet.WorkbookViewFunctions.set_workbook_window_position(spreadsheet, 100, 50, 800, 600)