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

- (CellAlignment) initialize(options = {})

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)


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

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

Instance Attribute Details

- (Symbol) horizontal

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)


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

def horizontal
  @horizontal
end

- (Integer) indent

The amount of indent

Returns:

  • (Integer)


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

def indent
  @indent
end

- (Boolean) justifyLastLine

Indicate if the last line should be justified.

Returns:

  • (Boolean)


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

def justifyLastLine
  @justifyLastLine
end

- (Integer) readingOrder

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

Returns:

  • (Integer)


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

def readingOrder
  @readingOrder
end

- (Integer) relativeIndent

The amount of relativeIndent

Returns:

  • (Integer)


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

def relativeIndent
  @relativeIndent
end

- (Boolean) shrinkToFit

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

Returns:

  • (Boolean)


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

def shrinkToFit
  @shrinkToFit
end

- (Integer) textRotation

The textRotation of the cell.

Returns:

  • (Integer)


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

def textRotation
  @textRotation
end

- (Symbol) vertical

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)


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

def vertical
  @vertical
end

- (Boolean) wrapText

Indicate if the text of the cell should wrap

Returns:

  • (Boolean)


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

def wrapText
  @wrapText
end

Instance Method Details

- (String) to_xml(xml)

Serializes the cell alignment

Parameters:

  • xml (Nokogiri::XML::Builder)

    The document builder instance this objects xml will be added to.

Returns:

  • (String)


91
92
93
# File 'lib/axlsx/stylesheet/cell_alignment.rb', line 91

def to_xml(xml)
  xml.alignment(self.instance_values)      
end