Class: Axlsx::Xf

Inherits:
Object
  • Object
show all
Includes:
OptionsParser, SerializedAttributes
Defined in:
lib/axlsx/stylesheet/xf.rb

Overview

The Xf class defines a formatting record for use in Styles. The recommended way to manage styles for your workbook is with Styles#add_style

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionsParser

#parse_options

Methods included from SerializedAttributes

included, #serialized_attributes, #serialized_element_attributes, #serialized_tag

Constructor Details

#initialize(options = {}) ⇒ Xf

Creates a new Xf object

Parameters:

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

    a customizable set of options

Options Hash (options):

  • numFmtId (Integer)
  • fontId (Integer)
  • fillId (Integer)
  • borderId (Integer)
  • xfId (Integer)
  • quotePrefix (Boolean)
  • pivotButton (Boolean)
  • applyNumberFormat (Boolean)
  • applyFont (Boolean)
  • applyFill (Boolean)
  • applyBorder (Boolean)
  • applyAlignment (Boolean)
  • applyProtection (Boolean)
  • alignment (CellAlignment)
  • protection (CellProtection)


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

def initialize(options = {})
  parse_options options
end

Instance Attribute Details

#alignmentCellAlignment

The cell alignment for this style

Returns:

See Also:



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

def alignment
  @alignment
end

#applyAlignmentBoolean

Indicates if the alignment options should be applied

Returns:

  • (Boolean)


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

def applyAlignment
  @applyAlignment
end

#applyBorderBoolean

indicates if the borderId should be applied

Returns:

  • (Boolean)


87
88
89
# File 'lib/axlsx/stylesheet/xf.rb', line 87

def applyBorder
  @applyBorder
end

#applyFillBoolean

indicates if the fillId should be applied

Returns:

  • (Boolean)


83
84
85
# File 'lib/axlsx/stylesheet/xf.rb', line 83

def applyFill
  @applyFill
end

#applyFontBoolean

indicates if the fontId should be applied

Returns:

  • (Boolean)


79
80
81
# File 'lib/axlsx/stylesheet/xf.rb', line 79

def applyFont
  @applyFont
end

#applyNumberFormatBoolean

indicates if the numFmtId should be applied

Returns:

  • (Boolean)


75
76
77
# File 'lib/axlsx/stylesheet/xf.rb', line 75

def applyNumberFormat
  @applyNumberFormat
end

#applyProtectionBoolean

Indicates if the protection options should be applied

Returns:

  • (Boolean)


95
96
97
# File 'lib/axlsx/stylesheet/xf.rb', line 95

def applyProtection
  @applyProtection
end

#borderIdInteger

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

Returns:

  • (Integer)


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

def borderId
  @borderId
end

#fillIdInteger

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

Returns:

  • (Integer)


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

def fillId
  @fillId
end

#fontIdInteger

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

Returns:

  • (Integer)


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

def fontId
  @fontId
end

#numFmtIdInteger

id of the numFmt to apply to this style

Returns:

  • (Integer)


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

def numFmtId
  @numFmtId
end

#pivotButtonBoolean

indicates if the cell has a pivot table drop down button

Returns:

  • (Boolean)


71
72
73
# File 'lib/axlsx/stylesheet/xf.rb', line 71

def pivotButton
  @pivotButton
end

#protectionCellProtection

The cell protection for this style

Returns:

See Also:



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

def protection
  @protection
end

#quotePrefixBoolean

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

Returns:

  • (Boolean)


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

def quotePrefix
  @quotePrefix
end

#xfIdInteger

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

Returns:

  • (Integer)


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

def xfId
  @xfId
end

Instance Method Details

#to_xml_string(str = +'')) ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


190
191
192
193
194
195
196
197
# File 'lib/axlsx/stylesheet/xf.rb', line 190

def to_xml_string(str = +'')
  str << '<xf '
  serialized_attributes str
  str << '>'
  alignment.to_xml_string(str) if alignment
  protection.to_xml_string(str) if protection
  str << '</xf>'
end