Class: Axlsx::SheetView

Inherits:
Object
  • Object
show all
Includes:
Accessors, OptionsParser, SerializedAttributes
Defined in:
lib/axlsx/workbook/worksheet/sheet_view.rb

Overview

Note:

The recommended way to manage the sheet view is via Worksheet#sheet_view

View options for a worksheet.

Constant Summary collapse

CHILD_ELEMENTS =

instance values that must be serialized as their own elements - e.g. not attributes.

[ :pane, :selections ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SerializedAttributes

#declared_attributes, included, #serialized_attributes, #serialized_element_attributes, #serialized_tag

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) ⇒ SheetView

Creates a new Axlsx::SheetView object

Parameters:

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

    a customizable set of options

Options Hash (options):

  • color_id (Integer)

    Color Id

  • default_grid_color (Boolean)

    Default Grid Color

  • right_to_left (Boolean)

    Right To Left

  • show_formulas (Boolean)

    Show Formulas

  • show_grid_lines (Boolean)

    Show Grid Lines

  • show_outline_symbols (Boolean)

    Show Outline Symbols

  • show_row_col_headers (Boolean)

    Show Headers

  • show_ruler (Boolean)

    Show Ruler

  • show_white_space (Boolean)

    Show White Space

  • show_zeros (Boolean)

    Show Zero Values

  • tab_selected (Boolean)

    Sheet Tab Selected

  • top_left_cell (String, Cell)

    Top Left Visible Cell

  • view (Symbol)

    View Type

  • window_protection (Boolean)

    Window Protection

  • workbook_view_id (Integer)

    Workbook View Index

  • zoom_scale (Integer)
  • zoom_scale_normal (Integer)

    Zoom Scale Normal View

  • zoom_scale_page_layout_view (Integer)

    Zoom Scale Page Layout View

  • zoom_scale_sheet_layout_view (Integer)

    Zoom Scale Page Break Preview



33
34
35
36
37
38
39
40
41
42
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 33

def initialize(options={})
  #defaults
  @color_id = @top_left_cell = @pane = nil
  @right_to_left = @show_formulas = @show_outline_symbols = @show_white_space = @tab_selected = @window_protection = false
  @default_grid_color = @show_grid_lines = @show_row_col_headers = @show_ruler = @show_zeros = true
  @zoom_scale = 100
  @zoom_scale_normal = @zoom_scale_page_layout_view = @zoom_scale_sheet_layout_view = @workbook_view_id = 0
  @selections = {}
  parse_options options
end

Instance Attribute Details

#color_idInteger

Color Id Index to the color value for row/column text headings and gridlines. This is an 'index color value' (ICV) rather than rgb value. default nil

Returns:

  • (Integer)

See Also:

  • type


78
79
80
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 78

def color_id
  @color_id
end

#selectionsHash (readonly)

A hash of selection objects keyed by pane type associated with this sheet view.

Returns:

  • (Hash)


67
68
69
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 67

def selections
  @selections
end

#top_left_cellString

Top Left Visible Cell Location of the 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:

See Also:

  • type


87
88
89
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 87

def top_left_cell
  @top_left_cell
end

#viewSymbol

View Type Indicates the view type. Options are

  • normal: Normal view
  • page_break_preview: Page break preview
  • page_layout: Page Layout View default :normal

Returns:

  • (Symbol)

See Also:

  • type


99
100
101
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 99

def view
  @view
end

#workbook_view_idInteger

Workbook View Index Zero-based index of this workbook view, pointing to a workbookView element in the bookViews collection. default 0

Returns:

  • (Integer)

See Also:

  • type


107
108
109
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 107

def workbook_view_id
  @workbook_view_id
end

#zoom_scaleInteger

Zoom Scale Window zoom magnification for current view representing percent values. This attribute is restricted to values ranging from 10 to 400. Horizontal & Vertical scale together. Current view can be Normal, Page Layout, or Page Break Preview. default 100

Returns:

  • (Integer)

See Also:

  • type


119
120
121
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 119

def zoom_scale
  @zoom_scale
end

#zoom_scale_normalInteger

Zoom Scale Normal View Zoom magnification to use when in normal view, representing percent values. This attribute is restricted to values ranging from 10 to 400. Horizontal & Vertical scale together. Applies for worksheets only; zero implies the automatic setting. default 0

Returns:

  • (Integer)

See Also:

  • type


132
133
134
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 132

def zoom_scale_normal
  @zoom_scale_normal
end

#zoom_scale_page_layout_viewInteger

Zoom Scale Page Layout View Zoom magnification to use when in page layout view, representing percent values. This attribute is restricted to values ranging from 10 to 400. Horizontal & Vertical scale together. Applies for worksheets only; zero implies the automatic setting. default 0

Returns:

  • (Integer)

See Also:

  • type


145
146
147
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 145

def zoom_scale_page_layout_view
  @zoom_scale_page_layout_view
end

#zoom_scale_sheet_layout_viewInteger

Zoom Scale Page Break Preview Zoom magnification to use when in page break preview, representing percent values. This attribute is restricted to values ranging from 10 to 400. Horizontal & Vertical scale together. Applies for worksheet only; zero implies the automatic setting. default 0

Returns:

  • (Integer)

See Also:

  • type


159
160
161
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 159

def zoom_scale_sheet_layout_view
  @zoom_scale_sheet_layout_view
end

Instance Method Details

#add_selection(pane, options = {}) ⇒ Object

Adds a new selection param [Symbol] pane param [Hash] options return [Selection]



165
166
167
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 165

def add_selection(pane, options = {})
  @selections[pane] = Selection.new(options.merge(:pane => pane))
end

#pane {|@pane| ... } ⇒ Pane

The pane object for the sheet view

Yields:

Returns:

See Also:

  • [Pane]


59
60
61
62
63
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 59

def pane
  @pane ||= Pane.new
  yield @pane if block_given?
  @pane
end

#to_xml_string(str = '') ⇒ String

Serializes the data validation

Parameters:

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

Returns:



200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/axlsx/workbook/worksheet/sheet_view.rb', line 200

def to_xml_string(str = '')
  str << '<sheetViews>'
  str << '<sheetView '
  serialized_attributes str
  str << '>'
  @pane.to_xml_string(str) if @pane
  @selections.each do |key, selection|
    selection.to_xml_string(str)
  end
  str << '</sheetView>'
  str << '</sheetViews>'
end