axlsx 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +70 -0
- data/lib/axlsx.rb~ +67 -0
- data/lib/axlsx/content_type/content_type.rb~ +20 -0
- data/lib/axlsx/content_type/default.rb~ +32 -0
- data/lib/axlsx/content_type/override.rb~ +30 -0
- data/lib/axlsx/doc_props/app.rb~ +127 -0
- data/lib/axlsx/doc_props/core.rb~ +25 -0
- data/lib/axlsx/drawing/axis.rb~ +0 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb~ +64 -0
- data/lib/axlsx/drawing/bar_series.rb~ +92 -0
- data/lib/axlsx/drawing/cat_axis.rb~ +32 -0
- data/lib/axlsx/drawing/chart.rb~ +0 -0
- data/lib/axlsx/drawing/drawing.rb~ +102 -0
- data/lib/axlsx/drawing/graphic_frame.rb~ +40 -0
- data/lib/axlsx/drawing/marker.rb~ +50 -0
- data/lib/axlsx/drawing/pie_3D_chart.rb~ +132 -0
- data/lib/axlsx/drawing/pie_series.rb~ +0 -0
- data/lib/axlsx/drawing/scaling.rb~ +0 -0
- data/lib/axlsx/drawing/series.rb~ +114 -0
- data/lib/axlsx/drawing/title.rb~ +69 -0
- data/lib/axlsx/drawing/two_cell_anchor.rb~ +70 -0
- data/lib/axlsx/drawing/val_axis.rb~ +34 -0
- data/lib/axlsx/drawing/view_3D.rb~ +21 -0
- data/lib/axlsx/package.rb +3 -3
- data/lib/axlsx/package.rb~ +181 -0
- data/lib/axlsx/rels/relationship.rb~ +18 -0
- data/lib/axlsx/rels/relationships.rb~ +23 -0
- data/lib/axlsx/stylesheet/border.rb~ +24 -0
- data/lib/axlsx/stylesheet/border_pr.rb~ +64 -0
- data/lib/axlsx/stylesheet/cell_alignment.rb~ +93 -0
- data/lib/axlsx/stylesheet/cell_protection.rb~ +16 -0
- data/lib/axlsx/stylesheet/cell_style.rb~ +61 -0
- data/lib/axlsx/stylesheet/color.rb~ +56 -0
- data/lib/axlsx/stylesheet/fill.rb~ +31 -0
- data/lib/axlsx/stylesheet/font.rb~ +33 -0
- data/lib/axlsx/stylesheet/gradient_fill.rb~ +70 -0
- data/lib/axlsx/stylesheet/gradient_stop.rb~ +15 -0
- data/lib/axlsx/stylesheet/num_fmt.rb~ +60 -0
- data/lib/axlsx/stylesheet/pattern_fill.rb~ +63 -0
- data/lib/axlsx/stylesheet/styles.rb~ +279 -0
- data/lib/axlsx/stylesheet/table_style.rb~ +43 -0
- data/lib/axlsx/stylesheet/table_style_element.rb~ +66 -0
- data/lib/axlsx/stylesheet/table_styles.rb~ +36 -0
- data/lib/axlsx/stylesheet/xf.rb~ +37 -0
- data/lib/axlsx/util/constants.rb +1 -1
- data/lib/axlsx/util/constants.rb~ +187 -0
- data/lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~ +61 -0
- data/lib/axlsx/util/simple_typed_list.rb~ +79 -0
- data/lib/axlsx/util/validators.rb +3 -3
- data/lib/axlsx/util/validators.rb~ +132 -0
- data/lib/axlsx/util/xml_escape.rb~ +6 -0
- data/lib/axlsx/workbook/workbook.rb +1 -0
- data/lib/axlsx/workbook/workbook.rb~ +130 -0
- data/lib/axlsx/workbook/worksheet/cell.rb~ +185 -0
- data/lib/axlsx/workbook/worksheet/row.rb +4 -4
- data/lib/axlsx/workbook/worksheet/row.rb~ +92 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +3 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb~ +194 -0
- data/lib/schema/dc.xsd~ +118 -0
- data/lib/schema/dcterms.xsd~ +331 -0
- data/lib/schema/opc-coreProperties.xsd~ +50 -0
- data/test/drawing/tc_bar_3D_chart.rb +1 -1
- data/test/drawing/tc_bar_3D_chart.rb~ +62 -0
- data/test/drawing/tc_chart.rb +1 -1
- data/test/drawing/tc_chart.rb~ +1 -0
- data/test/drawing/tc_pie_3D_chart.rb +1 -1
- data/test/drawing/tc_pie_3D_chart.rb~ +3 -28
- data/test/drawing/tc_title.rb +1 -1
- data/test/drawing/tc_title.rb~ +16 -19
- data/test/drawing/tc_two_cell_anchor.rb +1 -1
- data/test/drawing/tc_two_cell_anchor.rb~ +16 -14
- data/test/tc_package.rb +1 -1
- data/test/workbook/worksheet/tc_row.rb +1 -1
- data/test/workbook/worksheet/tc_row.rb~ +30 -0
- data/test/workbook/worksheet/tc_worksheet.rb +3 -3
- data/test/workbook/worksheet/tc_worksheet.rb~ +85 -0
- metadata +84 -102
@@ -0,0 +1,18 @@
|
|
1
|
+
module Axlsx
|
2
|
+
class Relationship
|
3
|
+
attr_accessor :Target, :Type
|
4
|
+
def initialize(type, target)
|
5
|
+
self.Target=target
|
6
|
+
self.Type=type
|
7
|
+
end
|
8
|
+
|
9
|
+
def Target=(v) Axlsx::validate_string v; @Target = v end
|
10
|
+
def Type=(v) Axlsx::validate_relationship_type v; @Type = v end
|
11
|
+
|
12
|
+
def to_xml(xml, rId)
|
13
|
+
h = self.instance_values
|
14
|
+
h[:Id] = rId
|
15
|
+
xml.Relationship(h)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# Relationships are a collection of Relations that define how package parts are related.
|
3
|
+
# @note The package automatically manages releationships.
|
4
|
+
class Relationships < SimpleTypedList
|
5
|
+
|
6
|
+
# Creates a new Relationships collection based on SimpleTypedList
|
7
|
+
def initialize
|
8
|
+
super Relationship
|
9
|
+
end
|
10
|
+
|
11
|
+
# Serializes the relationships document.
|
12
|
+
# @return [String]
|
13
|
+
def to_xml()
|
14
|
+
builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
|
15
|
+
xml.Relationships(:xmlns => Axlsx::RELS_R) {
|
16
|
+
each_with_index { |rel, index| rel.to_xml(xml, "rId#{index+1}") }
|
17
|
+
}
|
18
|
+
end
|
19
|
+
builder.to_xml
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Axlsx
|
2
|
+
class Border
|
3
|
+
attr_accessor :diagonalUp, :diagonalDown, :outline
|
4
|
+
attr_reader :prs
|
5
|
+
def initialize(options={})
|
6
|
+
@prs = SimpleTypedList.new BorderPr
|
7
|
+
options.each do |o|
|
8
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def diagonalUp=(v) Axlsx::validate_boolean v; @diagonalUp = v end
|
13
|
+
def diagonalDown=(v) Axlsx::validate_boolean v; @diagonalDown = v end
|
14
|
+
def outline=(v) Axlsx::validate_boolean v; @outline = v end
|
15
|
+
|
16
|
+
def to_xml(xml)
|
17
|
+
xml.border(self.instance_values.select{ |k,v| [:diagonalUp, :diagonalDown, :outline].include? k }) {
|
18
|
+
[:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal].each do |k|
|
19
|
+
@prs.select { |pr| pr.name == k }.each { |pr| pr.to_xml(xml) }
|
20
|
+
end
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# A border part.
|
3
|
+
class BorderPr
|
4
|
+
|
5
|
+
# @return [Color] The color of this border part.
|
6
|
+
attr_accessor :color
|
7
|
+
|
8
|
+
# @return [Symbol] The syle of this border part.
|
9
|
+
# @note
|
10
|
+
# The following are allowed
|
11
|
+
# :none
|
12
|
+
# :thin
|
13
|
+
# :medium
|
14
|
+
# :dashed
|
15
|
+
# :dotted
|
16
|
+
# :thick
|
17
|
+
# :double
|
18
|
+
# :hair
|
19
|
+
# :mediumDashed
|
20
|
+
# :dashDot
|
21
|
+
# :mediumDashDot
|
22
|
+
# :dashDotDot
|
23
|
+
# :mediumDashDotDot
|
24
|
+
# :slantDashDot
|
25
|
+
attr_accessor :style
|
26
|
+
|
27
|
+
# @return [Symbol] The name of this border part
|
28
|
+
# @note
|
29
|
+
# The following are allowed
|
30
|
+
# :start
|
31
|
+
# :end
|
32
|
+
# :left
|
33
|
+
# :right
|
34
|
+
# :top
|
35
|
+
# :bottom
|
36
|
+
# :diagonal
|
37
|
+
# :vertical
|
38
|
+
# :horizontal
|
39
|
+
attr_accessor :name
|
40
|
+
|
41
|
+
# Creates a new Border Part Object
|
42
|
+
# @option options [Color] color
|
43
|
+
# @option options [Symbol] name
|
44
|
+
# @option options [Symbol] style
|
45
|
+
# @see Axlsx::Border
|
46
|
+
def initialize(options={})
|
47
|
+
options.each do |o|
|
48
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def name=(v) RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v; @name = v end
|
53
|
+
def color=(v) DataTypeValidator.validate(:color, Color, v); @color = v end
|
54
|
+
def style=(v) RestrictionValidator.validate "BorderPr.style", [:none, :thin, :medium, :dashed, :dotted, :thick, :double, :hair, :mediumDashed, :dashDot, :mediumDashDot, :dashDotDot, :mediumDashDotDot, :slantDashDot], v; @style = v end
|
55
|
+
|
56
|
+
# Serializes the border part
|
57
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
58
|
+
def to_xml(xml)
|
59
|
+
xml.send(@name, :style=>@style) {
|
60
|
+
@color.to_xml(xml) if @color.is_a? Color
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# CellAlignment stores information about the cell alignment of a style Xf Object.
|
3
|
+
# @note Using Styles#add_style is the recommended way to manage cell alignment.
|
4
|
+
# @see Styles#add_style
|
5
|
+
class CellAlignment
|
6
|
+
# The horizontal alignment of the cell.
|
7
|
+
# @note
|
8
|
+
# The horizontal cell alignement style must be one of
|
9
|
+
# :general
|
10
|
+
# :left
|
11
|
+
# :center
|
12
|
+
# :right
|
13
|
+
# :fill
|
14
|
+
# :justify
|
15
|
+
# :centerContinuous
|
16
|
+
# :distributed
|
17
|
+
# @return [Symbol]
|
18
|
+
attr_accessor :horizontal
|
19
|
+
|
20
|
+
# The vertical alignment of the cell.
|
21
|
+
# @note
|
22
|
+
# The vertical cell allingment style must be one of the following:
|
23
|
+
# :top
|
24
|
+
# :center
|
25
|
+
# :bottom
|
26
|
+
# :justify
|
27
|
+
# :distributed
|
28
|
+
# @return [Symbol]
|
29
|
+
attr_accessor :vertical
|
30
|
+
|
31
|
+
# The textRotation of the cell.
|
32
|
+
# @return [Integer]
|
33
|
+
attr_accessor :textRotation
|
34
|
+
|
35
|
+
# Indicate if the text of the cell should wrap
|
36
|
+
# @return [Boolean]
|
37
|
+
attr_accessor :wrapText
|
38
|
+
|
39
|
+
# The amount of indent
|
40
|
+
# @return [Integer]
|
41
|
+
attr_accessor :indent
|
42
|
+
|
43
|
+
# The amount of relativeIndent
|
44
|
+
# @return [Integer]
|
45
|
+
attr_accessor :relativeIndent
|
46
|
+
|
47
|
+
# Indicate if the last line should be justified.
|
48
|
+
# @return [Boolean]
|
49
|
+
attr_accessor :justifyLastLine
|
50
|
+
|
51
|
+
# Indicate if the text should be shrunk to the fit in the cell.
|
52
|
+
# @return [Boolean]
|
53
|
+
attr_accessor :shrinkToFit
|
54
|
+
|
55
|
+
# The reading order of the text
|
56
|
+
# @return [Integer]
|
57
|
+
attr_accessor :readingOrder
|
58
|
+
|
59
|
+
# Create a new cell_alignment object
|
60
|
+
# @option options [Symbol] horizontal
|
61
|
+
# @option options [Symbol] vertical
|
62
|
+
# @option options [Integer] textRotation
|
63
|
+
# @option options [Boolean] wrapText
|
64
|
+
# @option options [Integer] indent
|
65
|
+
# @option options [Integer] relativeIndent
|
66
|
+
# @option options [Boolean] justifyLastLine
|
67
|
+
# @option options [Boolean] shrinkToFit
|
68
|
+
# @option options [Integer] readingOrder
|
69
|
+
def initialize(options={})
|
70
|
+
options.each do |o|
|
71
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
|
76
|
+
def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
|
77
|
+
def textRotation=(v) Axlsx::validate_unsigned_int v; @textRotation = v end
|
78
|
+
def wrapText=(v) Axlsx::validate_boolean v; @wrapText = v end
|
79
|
+
def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
|
80
|
+
def relativeIndent=(v) Axlsx::validate_int v; @relativeIndent = v end
|
81
|
+
def justifyLastLine=(v) Axlsx::validate_boolean v; @justifyLastLine = v end
|
82
|
+
def shrinkToFit=(v) Axlsx::validate_boolean v; @shrinkToFit = v end
|
83
|
+
def readingOrder=(v) Axlsx::validate_insigned_int v; @readingOrder = v end
|
84
|
+
|
85
|
+
# Serializes the cell alignment
|
86
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
87
|
+
# @return [String]
|
88
|
+
def to_xml(xml)
|
89
|
+
xml.alignment(self.instance_values)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Axlsx
|
2
|
+
|
3
|
+
class CellProtection
|
4
|
+
attr_accessor :hidden, :locked
|
5
|
+
def initialize(options={})
|
6
|
+
options.each do |o|
|
7
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
8
|
+
end
|
9
|
+
end
|
10
|
+
def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
|
11
|
+
def locked=(v) Axlsx::validate_boolean v; @locked = v end
|
12
|
+
def to_xml(xml)
|
13
|
+
xml.protection(self.instance_values)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# CellStyle defines named styles that reference defined formatting records and can be used in your worksheet.
|
3
|
+
# @note Using Styles#add_style is the recommended way to manage cell styling.
|
4
|
+
# @see Styles#add_style
|
5
|
+
class CellStyle
|
6
|
+
# The name of this cell style
|
7
|
+
# @return [String]
|
8
|
+
attr_accessor :name
|
9
|
+
|
10
|
+
# The formatting record id this named style utilizes
|
11
|
+
# @return [Integer]
|
12
|
+
# @see Axlsx::Xf
|
13
|
+
attr_accessor :xfId
|
14
|
+
|
15
|
+
# The buildinId to use when this named style is applied
|
16
|
+
# @return [Integer]
|
17
|
+
# @see Axlsx::NumFmt
|
18
|
+
attr_accessor :builtinId
|
19
|
+
|
20
|
+
# Determines if this formatting is for an outline style, and what level of the outline it is to be applied to.
|
21
|
+
# @return [Integer]
|
22
|
+
attr_accessor :iLevel
|
23
|
+
|
24
|
+
# Determines if this named style should show in the list of styles when using excel
|
25
|
+
# @return [Boolean]
|
26
|
+
attr_accessor :hidden
|
27
|
+
|
28
|
+
# Indicates that the build in style reference has been customized.
|
29
|
+
# @return [Boolean]
|
30
|
+
attr_accessor :customBuiltin
|
31
|
+
|
32
|
+
# Creats a new CellStyle object
|
33
|
+
# @option options [String] name
|
34
|
+
# @option options [Integer] xfId
|
35
|
+
# @option options [Integer] buildinId
|
36
|
+
# @option options [Integer] iLevel
|
37
|
+
# @option options [Boolean] hidden
|
38
|
+
# @option options [Boolean] customBuiltIn
|
39
|
+
def initialize(options={})
|
40
|
+
raise ArgumentError, "Support for extLst has not been implimented" if options[:extLst]
|
41
|
+
options.each do |o|
|
42
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def name=(v) Axlsx::validate_string v; @name = v end
|
47
|
+
def xfId=(v) Axlsx::validate_unsigned_int v; @xfId = v end
|
48
|
+
def builtinId=(v) Axlsx::validate_unsigned_int v; @builtinId = v end
|
49
|
+
def iLevel=(v) Axlsx::validate_unsigned_int v; @iLevel = v end
|
50
|
+
def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
|
51
|
+
def customBuiltin=(v) Axlsx::validate_boolean v; @customBuiltin = v end
|
52
|
+
|
53
|
+
# Serializes the cell style
|
54
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
55
|
+
# @return [String]
|
56
|
+
def to_xml(xml)
|
57
|
+
xml.cellStyle(self.instance_values)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# The color class represents a color used for borders, fills an fonts
|
3
|
+
class Color
|
4
|
+
# Determines if the color is system color dependant
|
5
|
+
# @return [Boolean]
|
6
|
+
attr_accessor :auto
|
7
|
+
|
8
|
+
# Backwards compatability color index
|
9
|
+
# return [Integer]
|
10
|
+
#attr_accessor :indexed
|
11
|
+
|
12
|
+
# The color as defined in rgb terms.
|
13
|
+
# @note
|
14
|
+
# rgb colors need to conform to ST_UnsignedIntHex. That basically means put 'FF' before you color
|
15
|
+
# @example rgb colors
|
16
|
+
# "FF000000" is black
|
17
|
+
# "FFFFFFFF" is white
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :rgb
|
20
|
+
|
21
|
+
# no support for theme just yet
|
22
|
+
# @return [Integer]
|
23
|
+
#attr_accessor :theme
|
24
|
+
|
25
|
+
# The tint value.
|
26
|
+
# @note valid values are between -1.0 and 1.0
|
27
|
+
# @return [Float]
|
28
|
+
attr_accessor :tint
|
29
|
+
|
30
|
+
# Creates a new Color object
|
31
|
+
# @option options [Boolean] auto
|
32
|
+
# @option options [String] rgb
|
33
|
+
# @option options [Float] tint
|
34
|
+
def initialize(options={})
|
35
|
+
options.each do |o|
|
36
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def auto=(v) Axlsx::validate_boolean v; @auto = v end
|
41
|
+
def rgb=(v) Axlsx::validate_string v; @rgb = v end
|
42
|
+
def tint=(v) Axlsx::validate_float v; @tint = v end
|
43
|
+
|
44
|
+
# This version does not support themes
|
45
|
+
# def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
|
46
|
+
|
47
|
+
# Indexed colors are for backward compatability which I am choosing not to support
|
48
|
+
# def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end
|
49
|
+
|
50
|
+
|
51
|
+
# Serializes the color
|
52
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
53
|
+
# @return [String]
|
54
|
+
def to_xml(xml) xml.color(self.instance_values) end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# The Fill is a formatting object that manages the background color, and pattern for cells.
|
3
|
+
# @note The recommended way to manage styles in your workbook is to use Styles#add_style.
|
4
|
+
# @see Styles#add_style
|
5
|
+
# @see PatternFill
|
6
|
+
# @see GradientFill
|
7
|
+
class Fill
|
8
|
+
|
9
|
+
# The type of fill
|
10
|
+
# @return [PatternFill, GradientFill]
|
11
|
+
attr_reader :fill_type
|
12
|
+
|
13
|
+
# Creates a new Fill object
|
14
|
+
# @param [PatternFill, GradientFill] fill_type
|
15
|
+
# @raise [ArgumentError] if the fill_type parameter is not a PatternFill or a GradientFill instance
|
16
|
+
def initialize(fill_type)
|
17
|
+
self.fill_type = fill_type
|
18
|
+
end
|
19
|
+
|
20
|
+
# Serializes the fill
|
21
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
22
|
+
# @return [String]
|
23
|
+
def to_xml(xml)
|
24
|
+
xml.fill { @fill_type.to_xml(xml) }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def fill_type=(v) DataTypeValidator.validate "Fill.fill_type", [PatternFill, GradientFill], v; @fill_type = v; end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Axlsx
|
2
|
+
|
3
|
+
|
4
|
+
class Font
|
5
|
+
attr_accessor :name, :charset, :family, :b, :i, :strike, :outline, :shadow, :condense, :extend, :color, :sz
|
6
|
+
def initialize(options={})
|
7
|
+
options.each do |o|
|
8
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
#there must be a cleaner way to do this....
|
12
|
+
def name=(v) Axlsx::validate_string v; @name = v end
|
13
|
+
def charset=(v) Axlsx::validate_unsigned_int v; @charset = v end
|
14
|
+
def family=(v) Axlsx::validate_unsigned_int v; @family = v end
|
15
|
+
def b=(v) Axlsx::validate_boolean v; @b = v end
|
16
|
+
def i=(v) Axlsx::validate_boolean v; @i = v end
|
17
|
+
def strike=(v) Axlsx::validate_boolean v; @strike = v end
|
18
|
+
def outline=(v) Axlsx::validate_boolean v; @outline = v end
|
19
|
+
def shadow=(v) Axlsx::validate_boolean v; @shadow = v end
|
20
|
+
def condense=(v) Axlsx::validate_boolean v; @condense = v end
|
21
|
+
def extend=(v) Axlsx::validate_boolean v; @extend = v end
|
22
|
+
def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color=v end
|
23
|
+
def sz=(v) Axlsx::validate_unsigned_int v; @sz=v end
|
24
|
+
|
25
|
+
def to_xml(xml)
|
26
|
+
xml.font {
|
27
|
+
self.instance_values.each do |k, v|
|
28
|
+
v.is_a?(Color) ? v.to_xml(xml) : xml.send(k, {:val => v})
|
29
|
+
end
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Axlsx
|
3
|
+
# A GradientFill defines the color and positioning for gradiant cell fill.
|
4
|
+
# @see Open Office XML Part 1 §18.8.24
|
5
|
+
class GradientFill
|
6
|
+
|
7
|
+
# The type of gradient.
|
8
|
+
# @note
|
9
|
+
# valid options are
|
10
|
+
# :linear
|
11
|
+
# :path
|
12
|
+
# @return [Symbol]
|
13
|
+
attr_accessor :type
|
14
|
+
|
15
|
+
# Angle of the linear gradient
|
16
|
+
# @return [Float]
|
17
|
+
attr_accessor :degree
|
18
|
+
|
19
|
+
# Percentage format left
|
20
|
+
# @return [Float]
|
21
|
+
attr_accessor :left
|
22
|
+
|
23
|
+
# Percentage format right
|
24
|
+
# @return [Float]
|
25
|
+
attr_accessor :right
|
26
|
+
|
27
|
+
# Percentage format top
|
28
|
+
# @return [Float]
|
29
|
+
attr_accessor :top
|
30
|
+
|
31
|
+
# Percentage format bottom
|
32
|
+
# @return [Float]
|
33
|
+
attr_accessor :bottom
|
34
|
+
|
35
|
+
# Collection of stop objects
|
36
|
+
# @return [SimpleTypedList]
|
37
|
+
attr_reader :stop
|
38
|
+
|
39
|
+
# Creates a new GradientFill object
|
40
|
+
# @option options [Symbol] type
|
41
|
+
# @option options [Float] degree
|
42
|
+
# @option options [Float] left
|
43
|
+
# @option options [Float] right
|
44
|
+
# @option options [Float] top
|
45
|
+
# @option options [Float] bottom
|
46
|
+
def initialize(options={})
|
47
|
+
options[:type] ||= :linear
|
48
|
+
options.each do |o|
|
49
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
50
|
+
end
|
51
|
+
@stop = SimpleTypedList.new GradientStop
|
52
|
+
end
|
53
|
+
|
54
|
+
def type=(v) Axlsx::validate_gradient_type v; @type = v end
|
55
|
+
def degree=(v) Axlsx::validate_float v; @degree = v end
|
56
|
+
def left=(v) DataTypeValidator.validate "GradientFill.left", Float, v, lambda { |v| v >= 0 && v <= 1}; @left = v end
|
57
|
+
def right=(v) DataTypeValidator.validate "GradientFill.right", Float, v, lambda { |v| v >= 0 && v <= 1}; @right = v end
|
58
|
+
def top=(v) DataTypeValidator.validate "GradientFill.top", Float, v, lambda { |v| v >= 0 && v <= 1}; @top = v end
|
59
|
+
def bottom=(v) DataTypeValidator.validate "GradientFill.bottom", Float, v, lambda { |v| v >= 0 && v <= 1}; @bottom= v end
|
60
|
+
|
61
|
+
# Serializes the gradientFill
|
62
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
63
|
+
# @return [String]
|
64
|
+
def to_xml(xml)
|
65
|
+
xml.gradientFill(self.instance_values.reject { |k,v| k.to_sym == :stop }) {
|
66
|
+
@stop.each { |s| s.to_xml(xml) }
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|