Class: Axlsx::Dxf

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

Overview

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

See Also:

Constant Summary collapse

CHILD_ELEMENTS =

The order in which the child elements is put in the XML seems to be important for Excel

[:font, :numFmt, :fill, :alignment, :border, :protection]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) ⇒ Dxf

Creates a new Xf object

Parameters:

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

    a customizable set of options

Options Hash (options):



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

def initialize(options = {})
  parse_options options
end

Instance Attribute Details

#alignmentCellAlignment

The cell alignment for this style

Returns:

See Also:



15
16
17
# File 'lib/axlsx/stylesheet/dxf.rb', line 15

def alignment
  @alignment
end

#borderBorder

the border to be used in this style

Returns:



36
37
38
# File 'lib/axlsx/stylesheet/dxf.rb', line 36

def border
  @border
end

#fillFill

the child fill to be used in this style

Returns:



32
33
34
# File 'lib/axlsx/stylesheet/dxf.rb', line 32

def fill
  @fill
end

#fontFont

the child font to be used for this style

Returns:



28
29
30
# File 'lib/axlsx/stylesheet/dxf.rb', line 28

def font
  @font
end

#numFmtNumFmt

the child NumFmt to be used to this style

Returns:



24
25
26
# File 'lib/axlsx/stylesheet/dxf.rb', line 24

def numFmt
  @numFmt
end

#protectionCellProtection

The cell protection for this style

Returns:

See Also:



20
21
22
# File 'lib/axlsx/stylesheet/dxf.rb', line 20

def protection
  @protection
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


65
66
67
68
69
70
71
72
73
# File 'lib/axlsx/stylesheet/dxf.rb', line 65

def to_xml_string(str = '')
  str << '<dxf>'
  # Dxf elements have no attributes. All of the instance variables
  # are child elements.
  CHILD_ELEMENTS.each do |element|
    self.send(element).to_xml_string(str) if self.send(element)
  end
  str << '</dxf>'
end