Class: Axlsx::Pane

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/workbook/worksheet/pane.rb

Overview

Note:

The recommended way to manage the pane options is via SheetView#pane

Pane options for a worksheet.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Pane

Creates a new Axlsx::Pane object

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • active_pane (Symbol)

    Active Pane

  • state (Symbol)

    Split State

  • top_left_cell (Cell, String)

    Top Left Visible Cell

  • x_split (Integer)

    Horizontal Split Position

  • y_split (Integer)

    Vertical Split Position



91
92
93
94
95
96
97
98
99
100
# File 'lib/axlsx/workbook/worksheet/pane.rb', line 91

def initialize(options={})
  #defaults
  @active_pane = @state = @top_left_cell = nil
  @x_split = @y_split = 0
  
  # write options to instance variables
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
end

Instance Attribute Details

#active_paneSymbol

Active Pane The pane that is active. Options are

  • bottom_left: Bottom left pane, when both vertical and horizontal splits are applied. This value is also used when only a horizontal split has been applied, dividing the pane into upper and lower regions. In that case, this value specifies the bottom pane.
  • bottom_right: Bottom right pane, when both vertical and horizontal splits are applied.
  • top_left: Top left pane, when both vertical and horizontal splits are applied. This value is also used when only a horizontal split has been applied, dividing the pane into upper and lower regions. In that case, this value specifies the top pane. This value is also used when only a vertical split has been applied, dividing the pane into right and left regions. In that case, this value specifies the left pane
  • top_right: Top right pane, when both vertical and horizontal splits are applied. This value is also used when only a vertical split has been applied, dividing the pane into right and left regions. In that case, this value specifies the right pane. default nil

Returns:

  • (Symbol)

See Also:

  • type


34
35
36
# File 'lib/axlsx/workbook/worksheet/pane.rb', line 34

def active_pane
  @active_pane
end

#stateSymbol

Split State Indicates whether the pane has horizontal / vertical splits, and whether those splits are frozen. Options are

  • frozen: Panes are frozen, but were not split being frozen. In this state, when the panes are unfrozen again, a single pane results, with no split. In this state, the split bars are not adjustable.
  • frozen_split: Panes are frozen and were split before being frozen. In this state, when the panes are unfrozen again, the split remains, but is adjustable.
  • split: Panes are split, but not frozen. In this state, the split bars are adjustable by the user. default nil

Returns:

  • (Symbol)

See Also:

  • type


53
54
55
# File 'lib/axlsx/workbook/worksheet/pane.rb', line 53

def state
  @state
end

#top_left_cellString

Top Left Visible Cell Location of the top left visible cell in the bottom right pane (when in Left-To-Right mode). default nil

Returns:

  • (String)

See Also:

  • type


62
63
64
# File 'lib/axlsx/workbook/worksheet/pane.rb', line 62

def top_left_cell
  @top_left_cell
end

#x_splitInteger

Horizontal Split Position Horizontal position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of columns visible in the top pane. default 0

Returns:

  • (Integer)

See Also:

  • type


72
73
74
# File 'lib/axlsx/workbook/worksheet/pane.rb', line 72

def x_split
  @x_split
end

#y_splitInteger

Vertical Split Position Vertical position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of rows visible in the left pane. default 0

Returns:

  • (Integer)

See Also:

  • type


82
83
84
# File 'lib/axlsx/workbook/worksheet/pane.rb', line 82

def y_split
  @y_split
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the data validation

Parameters:

  • str (String) (defaults to: '')

Returns:

  • (String)


130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/axlsx/workbook/worksheet/pane.rb', line 130

def to_xml_string(str = '')
  if @state == :frozen && @top_left_cell.nil?
    row = @y_split || 0
    column = @x_split || 0
    
    @top_left_cell = "#{('A'..'ZZ').to_a[column]}#{row+1}"
  end
  
  str << '<pane '
  str << instance_values.map { |key, value| '' << key.gsub(/_(.)/){ $1.upcase } << 
    %{="#{[:active_pane, :state].include?(key.to_sym) ? value.to_s.gsub(/_(.)/){ $1.upcase } : value}"} unless value.nil? }.join(' ')
  str << '/>'
end