Class: Axlsx::Xf

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

Overview

The Xf class defines a formatting record for use in Styles

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Xf) initialize(options = {})

Creates a new Xf object

Parameters:

  • [Integer] (Hash)

    a customizable set of options

  • [Boolean] (Hash)

    a customizable set of options

  • [CellAlignment] (Hash)

    a customizable set of options

  • [CellProtection] (Hash)

    a customizable set of options



84
85
86
87
88
# File 'lib/axlsx/stylesheet/xf.rb', line 84

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

Instance Attribute Details

- (CellAlignment) alignment

The cell alignment for this style

Returns:

See Also:



9
10
11
# File 'lib/axlsx/stylesheet/xf.rb', line 9

def alignment
  @alignment
end

- (Boolean) applyAlignment

Indicates if the alignment options should be applied

Returns:

  • (Boolean)


62
63
64
# File 'lib/axlsx/stylesheet/xf.rb', line 62

def applyAlignment
  @applyAlignment
end

- (Boolean) applyBorder

indicates if the borderId should be applied

Returns:

  • (Boolean)


58
59
60
# File 'lib/axlsx/stylesheet/xf.rb', line 58

def applyBorder
  @applyBorder
end

- (Boolean) applyFill

indicates if the fillId should be applied

Returns:

  • (Boolean)


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

def applyFill
  @applyFill
end

- (Boolean) applyFont

indicates if the fontId should be applied

Returns:

  • (Boolean)


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

def applyFont
  @applyFont
end

- (Boolean) applyNumberFormat

indicates if the numFmtId should be applied

Returns:

  • (Boolean)


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

def applyNumberFormat
  @applyNumberFormat
end

- (Boolean) applyProtection

Indicates if the protection options should be applied

Returns:

  • (Boolean)


66
67
68
# File 'lib/axlsx/stylesheet/xf.rb', line 66

def applyProtection
  @applyProtection
end

- (Integer) borderId

index (0 based) of the border to be used in this style

Returns:

  • (Integer)


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

def borderId
  @borderId
end

- (Integer) fillId

index (0 based) of the fill to be used in this style

Returns:

  • (Integer)


26
27
28
# File 'lib/axlsx/stylesheet/xf.rb', line 26

def fillId
  @fillId
end

- (Integer) fontId

index (0 based) of the font to be used in this style

Returns:

  • (Integer)


22
23
24
# File 'lib/axlsx/stylesheet/xf.rb', line 22

def fontId
  @fontId
end

- (Integer) numFmtId

id of the numFmt to apply to this style

Returns:

  • (Integer)


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

def numFmtId
  @numFmtId
end

- (Boolean) pivotButton

indicates if the cell has a pivot table drop down button

Returns:

  • (Boolean)


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

def pivotButton
  @pivotButton
end

- (CellProtection) protection

The cell protection for this style

Returns:

See Also:



14
15
16
# File 'lib/axlsx/stylesheet/xf.rb', line 14

def protection
  @protection
end

- (Boolean) quotePrefix

indecates if text should be prefixed by a single quote in the cell

Returns:

  • (Boolean)


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

def quotePrefix
  @quotePrefix
end

- (Integer) xfId

index (0 based) of cellStylesXfs item to be used in this style. Only applies to cellXfs items

Returns:

  • (Integer)


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

def xfId
  @xfId
end

Instance Method Details

- (String) to_xml(xml)

Serializes the xf elemen

Parameters:

  • xml (Nokogiri::XML::Builder)

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

Returns:

  • (String)


110
111
112
113
114
115
# File 'lib/axlsx/stylesheet/xf.rb', line 110

def to_xml(xml)
  xml.xf(self.instance_values.reject { |k, v| [:alignment, :protection, :extList, :name].include? k.to_sym}) {
    alignment.to_xml(xml) if self.alignment
    protection.to_xml(xml) if self.protection
  }
end