UmyaSpreadsheet.SheetViewFunctions (umya_spreadsheet_ex v0.7.0)
View SourceFunctions for configuring how sheets are displayed in the Excel application.
Summary
Functions
Freezes panes at the specified row and column.
Gets the active selection in a worksheet.
Gets the sheet view type.
Gets whether gridlines are shown in a sheet.
Gets the tab color for a worksheet.
Gets the zoom scale for a sheet view.
Sets the active selection in a worksheet.
Sets the sheet view type.
Sets whether to show gridlines in a sheet.
Sets the tab color for a worksheet.
Sets whether a sheet tab is selected (active) when the workbook is opened.
Sets the top-left cell in the sheet view (the first visible cell).
Sets the zoom scale for a sheet view.
Sets the zoom scale for the normal view.
Sets the zoom scale for the page break preview view.
Sets the zoom scale for the page layout view.
Splits panes at the specified row and column.
Functions
Freezes panes at the specified row and column.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetrows
- The number of rows to freezecols
- The number of columns to freeze
Examples
# Freeze the top row
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.freeze_panes(spreadsheet, "Sheet1", 1, 0)
# Freeze the left column
:ok = UmyaSpreadsheet.SheetViewFunctions.freeze_panes(spreadsheet, "Sheet1", 0, 1)
# Freeze both top row and left column
:ok = UmyaSpreadsheet.SheetViewFunctions.freeze_panes(spreadsheet, "Sheet1", 1, 1)
Gets the active selection in a worksheet.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheet
Returns
{:ok, selection}
whereselection
is a map with "active_cell" and "sqref" keys{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, selection} = UmyaSpreadsheet.SheetViewFunctions.get_selection(spreadsheet, "Sheet1")
# selection = %{"active_cell" => "A1", "sqref" => "A1:B5"}
Gets the sheet view type.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheet
Returns
{:ok, view_type}
whereview_type
is one of "normal", "page_layout", or "page_break_preview"{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, view_type} = UmyaSpreadsheet.SheetViewFunctions.get_sheet_view(spreadsheet, "Sheet1")
# view_type = "normal"
Gets whether gridlines are shown in a sheet.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheet
Returns
{:ok, boolean}
whereboolean
indicates whether gridlines are shown{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, show_gridlines} = UmyaSpreadsheet.SheetViewFunctions.get_show_grid_lines(spreadsheet, "Sheet1")
# show_gridlines = true
Gets the tab color for a worksheet.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheet
Returns
{:ok, color}
wherecolor
is a string with the color code (e.g., "#FF0000" for red) or an empty string if no color is set{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, color} = UmyaSpreadsheet.SheetViewFunctions.get_tab_color(spreadsheet, "Sheet1")
# color = "#FF0000"
Gets the zoom scale for a sheet view.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheet
Returns
{:ok, integer}
whereinteger
is the zoom scale percentage{:error, reason}
on failure
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
{:ok, zoom_scale} = UmyaSpreadsheet.SheetViewFunctions.get_zoom_scale(spreadsheet, "Sheet1")
# zoom_scale = 100
Sets the active selection in a worksheet.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetactive_cell
- The active cell address (e.g., "A1", "B5")sqref
- The selection range reference (e.g., "A1:B5")
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.set_selection(spreadsheet, "Sheet1", "C3", "C3:D5")
Sets the sheet view type.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetview_type
- The type of view: "normal", "page_layout", or "page_break_preview"
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
# Set to normal view
:ok = UmyaSpreadsheet.SheetViewFunctions.set_sheet_view(spreadsheet, "Sheet1", "normal")
# Set to page layout view
:ok = UmyaSpreadsheet.SheetViewFunctions.set_sheet_view(spreadsheet, "Sheet1", "page_layout")
# Set to page break preview
:ok = UmyaSpreadsheet.SheetViewFunctions.set_sheet_view(spreadsheet, "Sheet1", "page_break_preview")
Sets whether to show gridlines in a sheet.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetshow_gridlines
- Boolean indicating whether to show gridlines
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.set_show_grid_lines(spreadsheet, "Sheet1", false)
Sets the tab color for a worksheet.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcolor
- The color code (e.g., "#FF0000" for red)
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
# Set sheet tab to red
:ok = UmyaSpreadsheet.SheetViewFunctions.set_tab_color(spreadsheet, "Sheet1", "#FF0000")
Sets whether a sheet tab is selected (active) when the workbook is opened.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetselected
- Boolean indicating whether the sheet tab should be selected
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.set_tab_selected(spreadsheet, "Sheet1", true)
Sets the top-left cell in the sheet view (the first visible cell).
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetcell_address
- The cell address (e.g., "A1", "B5") to set as the top-left cell
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.set_top_left_cell(spreadsheet, "Sheet1", "B5")
Sets the zoom scale for a sheet view.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetscale
- The zoom scale percentage (e.g., 100 for 100%, 150 for 150%)
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.set_zoom_scale(spreadsheet, "Sheet1", 150)
Sets the zoom scale for the normal view.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetscale
- The zoom scale percentage (e.g., 100 for 100%, 150 for 150%)
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.set_zoom_scale_normal(spreadsheet, "Sheet1", 75)
Sets the zoom scale for the page break preview view.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetscale
- The zoom scale percentage (e.g., 100 for 100%, 150 for 150%)
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.set_zoom_scale_page_break(spreadsheet, "Sheet1", 80)
Sets the zoom scale for the page layout view.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetscale
- The zoom scale percentage (e.g., 100 for 100%, 150 for 150%)
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.set_zoom_scale_page_layout(spreadsheet, "Sheet1", 120)
Splits panes at the specified row and column.
Parameters
spreadsheet
- The spreadsheet structsheet_name
- The name of the sheetheight
- The height of the split in pixelswidth
- The width of the split in pixels
Examples
{:ok, spreadsheet} = UmyaSpreadsheet.read_file("input.xlsx")
:ok = UmyaSpreadsheet.SheetViewFunctions.split_panes(spreadsheet, "Sheet1", 2000, 2000)