Class: Axlsx::PrintOptions

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

Overview

Note:

The recommended way to manage print options is via Worksheet#print_options

Options for printing a worksheet. All options are boolean and false by default.

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 = {}) ⇒ PrintOptions

Creates a new PrintOptions object

Parameters:

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

    a customizable set of options

Options Hash (options):

  • grid_lines (Boolean)

    Whether grid lines should be printed

  • headings (Boolean)

    Whether row and column headings should be printed

  • horizontal_centered (Boolean)

    Whether the content should be centered horizontally

  • vertical_centered (Boolean)

    Whether the content should be centered vertically



17
18
19
20
# File 'lib/axlsx/workbook/worksheet/print_options.rb', line 17

def initialize(options = {})
  @grid_lines = @headings = @horizontal_centered = @vertical_centered = false
  set(options)
end

Instance Method Details

#set(options) ⇒ Object

Set some or all options at once.

Parameters:

  • options (Hash)

    The options to set (possible keys are :grid_lines, :headings, :horizontal_centered, and :vertical_centered).



27
28
29
# File 'lib/axlsx/workbook/worksheet/print_options.rb', line 27

def set(options)
  parse_options options
end

#to_xml_string(str = '') ⇒ String

Note:

As all attributes default to "false" according to the xml schema definition, the generated xml includes only those attributes that are set to true.

Serializes the page options element.

Parameters:

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

Returns:

  • (String)


35
36
37
# File 'lib/axlsx/workbook/worksheet/print_options.rb', line 35

def to_xml_string(str = '')
  serialized_tag 'printOptions', str
end