1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# frozen_string_literal: true
module Axlsx
# 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 Styles#add_style
class Dxf
include Axlsx::OptionsParser
# The order in which the child elements is put in the XML seems to
# be important for Excel
CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection].freeze
# does not support extList (ExtensionList)
# The cell alignment for this style
# @return [CellAlignment]
# @see CellAlignment
attr_reader :alignment
# The cell protection for this style
# @return [CellProtection]
# @see CellProtection
attr_reader :protection
# the child NumFmt to be used to this style
# @return [NumFmt]
attr_reader :numFmt
# the child font to be used for this style
# @return [Font]
attr_reader :font
# the child fill to be used in this style
# @return [Fill]
attr_reader :fill
# the border to be used in this style
# @return [Border]
attr_reader :border
# Creates a new Xf object
# @option options [Border] border
# @option options [NumFmt] numFmt
# @option options [Fill] fill
# @option options [Font] font
# @option options [CellAlignment] alignment
# @option options [CellProtection] protection
def initialize(options = {})
parse_options options
end
# @see Dxf#alignment
def alignment=(v) DataTypeValidator.validate "Dxf.alignment", CellAlignment, v; @alignment = v end
# @see protection
def protection=(v) DataTypeValidator.validate "Dxf.protection", CellProtection, v; @protection = v end
# @see numFmt
def numFmt=(v) DataTypeValidator.validate "Dxf.numFmt", NumFmt, v; @numFmt = v end
# @see font
def font=(v) DataTypeValidator.validate "Dxf.font", Font, v; @font = v end
# @see border
def border=(v) DataTypeValidator.validate "Dxf.border", Border, v; @border = v end
# @see fill
def fill=(v) DataTypeValidator.validate "Dxf.fill", Fill, v; @fill = v end
# Serializes the object
# @param [String] str
# @return [String]
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
end
end
|