Class: Axlsx::CellAlignment

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/stylesheet/cell_alignment.rb

Overview

Note:

Using Styles#add_style is the recommended way to manage cell alignment.

CellAlignment stores information about the cell alignment of a style Xf Object.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CellAlignment

Create a new cell_alignment object

Parameters:

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

    a customizable set of options

Options Hash (options):

  • horizontal (Symbol)
  • vertical (Symbol)
  • textRotation (Integer)
  • wrapText (Boolean)
  • indent (Integer)
  • relativeIndent (Integer)
  • justifyLastLine (Boolean)
  • shrinkToFit (Boolean)
  • readingOrder (Integer)


73
74
75
76
77
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 73

def initialize(options={})
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
end

Instance Attribute Details

#horizontalSymbol

Note:

The horizontal cell alignement style must be one of

:general
:left
:center
:right
:fill
:justify
:centerContinuous
:distributed

The horizontal alignment of the cell.

Returns:

  • (Symbol)


19
20
21
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 19

def horizontal
  @horizontal
end

#indentInteger

The amount of indent

Returns:

  • (Integer)


42
43
44
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 42

def indent
  @indent
end

#justifyLastLineBoolean

Indicate if the last line should be justified.

Returns:

  • (Boolean)


50
51
52
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 50

def justifyLastLine
  @justifyLastLine
end

#readingOrderInteger

The reading order of the text 0 Context Dependent 1 Left-to-Right 2 Right-to-Left

Returns:

  • (Integer)


61
62
63
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 61

def readingOrder
  @readingOrder
end

#relativeIndentInteger

The amount of relativeIndent

Returns:

  • (Integer)


46
47
48
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 46

def relativeIndent
  @relativeIndent
end

#shrinkToFitBoolean

Indicate if the text should be shrunk to the fit in the cell.

Returns:

  • (Boolean)


54
55
56
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 54

def shrinkToFit
  @shrinkToFit
end

#textRotationInteger

The textRotation of the cell.

Returns:

  • (Integer)


34
35
36
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 34

def textRotation
  @textRotation
end

#verticalSymbol

Note:

The vertical cell allingment style must be one of the following:

:top
:center
:bottom
:justify
:distributed

The vertical alignment of the cell.

Returns:

  • (Symbol)


30
31
32
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 30

def vertical
  @vertical
end

#wrapTextBoolean

Indicate if the text of the cell should wrap

Returns:

  • (Boolean)


38
39
40
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 38

def wrapText
  @wrapText
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


101
102
103
104
105
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 101

def to_xml_string(str = '')
  str << '<alignment '
  str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
  str << '/>'
end