Module: Writexlsx::Worksheet::Panes
- Included in:
- Writexlsx::Worksheet
- Defined in:
- lib/write_xlsx/worksheet/panes.rb
Overview
Pane-related operations extracted from Worksheet to slim the main class.
Instance Method Summary collapse
-
#freeze_panes(*args) ⇒ Object
:call-seq: freeze_panes(row, col [ , top_row, left_col ] ).
-
#set_top_left_cell(row, col = nil) ⇒ Object
set_top_left_cell().
-
#split_panes(*args) ⇒ Object
:call-seq: split_panes(y, x, top_row, left_col).
Instance Method Details
#freeze_panes(*args) ⇒ Object
:call-seq:
freeze_panes(row, col [ , top_row, left_col ] )
This method can be used to divide a worksheet into horizontal or vertical regions known as panes and to also "freeze" these panes so that the splitter bars are not visible. This is the same as the Window->Freeze Panes menu command in Excel
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/write_xlsx/worksheet/panes.rb', line 33 def freeze_panes(*args) return if args.empty? # Check for a cell reference in A1 notation and substitute row and column. if (row_col_array = row_col_notation(args.first)) row, col, top_row, left_col = row_col_array type = args[1] else row, col, top_row, left_col, type = args end col ||= 0 top_row ||= row left_col ||= col type ||= 0 @panes = [row, col, top_row, left_col, type] end |
#set_top_left_cell(row, col = nil) ⇒ Object
set_top_left_cell()
Set the first visible cell at the top left of the worksheet.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/write_xlsx/worksheet/panes.rb', line 13 def set_top_left_cell(row, col = nil) if (row_col_array = row_col_notation(row)) _row, _col = row_col_array else _row = row _col = col end @top_left_cell = xl_rowcol_to_cell(_row, _col) end |
#split_panes(*args) ⇒ Object
:call-seq:
split_panes(y, x, top_row, left_col)
Set panes and mark them as split.
58 59 60 61 |
# File 'lib/write_xlsx/worksheet/panes.rb', line 58 def split_panes(*args) # Call freeze panes but add the type flag for split panes. freeze_panes(args[0], args[1], args[2], args[3], 2) end |