axlsx 1.0.11 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/.yardopts +4 -0
  2. data/README.md +7 -4
  3. data/examples/example.rb +6 -4
  4. data/examples/example.rb~ +112 -0
  5. data/lib/schema/dc.xsd~ +118 -0
  6. data/lib/schema/dcterms.xsd~ +331 -0
  7. data/lib/schema/opc-coreProperties.xsd~ +50 -0
  8. metadata +43 -193
  9. data/Gemfile +0 -3
  10. data/Gemfile.lock +0 -29
  11. data/axlsx.gemspec +0 -42
  12. data/doc/Axlsx.html +0 -2718
  13. data/doc/Axlsx/App.html +0 -2640
  14. data/doc/Axlsx/Axis.html +0 -1075
  15. data/doc/Axlsx/Bar3DChart.html +0 -1182
  16. data/doc/Axlsx/BarSeries.html +0 -711
  17. data/doc/Axlsx/Border.html +0 -779
  18. data/doc/Axlsx/BorderPr.html +0 -709
  19. data/doc/Axlsx/CatAxis.html +0 -769
  20. data/doc/Axlsx/CatAxisData.html +0 -397
  21. data/doc/Axlsx/Cell.html +0 -3187
  22. data/doc/Axlsx/CellAlignment.html +0 -1247
  23. data/doc/Axlsx/CellProtection.html +0 -565
  24. data/doc/Axlsx/CellStyle.html +0 -949
  25. data/doc/Axlsx/Chart.html +0 -1692
  26. data/doc/Axlsx/Color.html +0 -670
  27. data/doc/Axlsx/ContentType.html +0 -335
  28. data/doc/Axlsx/Core.html +0 -465
  29. data/doc/Axlsx/DataTypeValidator.html +0 -324
  30. data/doc/Axlsx/Default.html +0 -565
  31. data/doc/Axlsx/Drawing.html +0 -1264
  32. data/doc/Axlsx/Fill.html +0 -460
  33. data/doc/Axlsx/Font.html +0 -1554
  34. data/doc/Axlsx/GradientFill.html +0 -1026
  35. data/doc/Axlsx/GradientStop.html +0 -526
  36. data/doc/Axlsx/GraphicFrame.html +0 -642
  37. data/doc/Axlsx/Line3DChart.html +0 -1004
  38. data/doc/Axlsx/LineSeries.html +0 -605
  39. data/doc/Axlsx/Marker.html +0 -857
  40. data/doc/Axlsx/NumFmt.html +0 -562
  41. data/doc/Axlsx/OneCellAnchor.html +0 -982
  42. data/doc/Axlsx/Override.html +0 -552
  43. data/doc/Axlsx/Package.html +0 -825
  44. data/doc/Axlsx/Parser.html +0 -549
  45. data/doc/Axlsx/PatternFill.html +0 -681
  46. data/doc/Axlsx/Pic.html +0 -1701
  47. data/doc/Axlsx/PictureLocking.html +0 -1159
  48. data/doc/Axlsx/Pie3DChart.html +0 -489
  49. data/doc/Axlsx/PieSeries.html +0 -710
  50. data/doc/Axlsx/RegexValidator.html +0 -268
  51. data/doc/Axlsx/Relationship.html +0 -554
  52. data/doc/Axlsx/Relationships.html +0 -338
  53. data/doc/Axlsx/RestrictionValidator.html +0 -300
  54. data/doc/Axlsx/Row.html +0 -916
  55. data/doc/Axlsx/Scaling.html +0 -742
  56. data/doc/Axlsx/SerAxis.html +0 -641
  57. data/doc/Axlsx/Series.html +0 -813
  58. data/doc/Axlsx/SeriesTitle.html +0 -290
  59. data/doc/Axlsx/Styles.html +0 -1754
  60. data/doc/Axlsx/TableStyle.html +0 -705
  61. data/doc/Axlsx/TableStyleElement.html +0 -677
  62. data/doc/Axlsx/TableStyles.html +0 -594
  63. data/doc/Axlsx/Title.html +0 -543
  64. data/doc/Axlsx/TwoCellAnchor.html +0 -973
  65. data/doc/Axlsx/ValAxis.html +0 -538
  66. data/doc/Axlsx/ValAxisData.html +0 -321
  67. data/doc/Axlsx/View3D.html +0 -973
  68. data/doc/Axlsx/Workbook.html +0 -1630
  69. data/doc/Axlsx/Worksheet.html +0 -2682
  70. data/doc/Axlsx/Xf.html +0 -1780
  71. data/doc/_index.html +0 -649
  72. data/doc/class_list.html +0 -47
  73. data/doc/css/common.css +0 -1
  74. data/doc/css/full_list.css +0 -55
  75. data/doc/css/style.css +0 -322
  76. data/doc/file.LICENSE.html +0 -91
  77. data/doc/file.README.html +0 -338
  78. data/doc/file_list.html +0 -52
  79. data/doc/frames.html +0 -13
  80. data/doc/index.html +0 -338
  81. data/doc/js/app.js +0 -205
  82. data/doc/js/full_list.js +0 -167
  83. data/doc/js/jquery.js +0 -16
  84. data/doc/method_list.html +0 -3502
  85. data/doc/top-level-namespace.html +0 -103
  86. data/lib/axlsx.rb +0 -54
  87. data/lib/axlsx/content_type/content_type.rb +0 -23
  88. data/lib/axlsx/content_type/default.rb +0 -37
  89. data/lib/axlsx/content_type/override.rb +0 -37
  90. data/lib/axlsx/doc_props/app.rb +0 -178
  91. data/lib/axlsx/doc_props/core.rb +0 -34
  92. data/lib/axlsx/drawing/axis.rb +0 -90
  93. data/lib/axlsx/drawing/bar_3D_chart.rb +0 -128
  94. data/lib/axlsx/drawing/bar_series.rb +0 -64
  95. data/lib/axlsx/drawing/cat_axis.rb +0 -63
  96. data/lib/axlsx/drawing/cat_axis_data.rb +0 -35
  97. data/lib/axlsx/drawing/chart.rb +0 -179
  98. data/lib/axlsx/drawing/drawing.rb +0 -137
  99. data/lib/axlsx/drawing/graphic_frame.rb +0 -52
  100. data/lib/axlsx/drawing/line_3D_chart.rb +0 -106
  101. data/lib/axlsx/drawing/line_series.rb +0 -46
  102. data/lib/axlsx/drawing/marker.rb +0 -61
  103. data/lib/axlsx/drawing/one_cell_anchor.rb +0 -89
  104. data/lib/axlsx/drawing/pic.rb +0 -153
  105. data/lib/axlsx/drawing/picture_locking.rb +0 -72
  106. data/lib/axlsx/drawing/pie_3D_chart.rb +0 -41
  107. data/lib/axlsx/drawing/pie_series.rb +0 -56
  108. data/lib/axlsx/drawing/scaling.rb +0 -59
  109. data/lib/axlsx/drawing/ser_axis.rb +0 -45
  110. data/lib/axlsx/drawing/series.rb +0 -71
  111. data/lib/axlsx/drawing/series_title.rb +0 -22
  112. data/lib/axlsx/drawing/title.rb +0 -61
  113. data/lib/axlsx/drawing/two_cell_anchor.rb +0 -76
  114. data/lib/axlsx/drawing/val_axis.rb +0 -34
  115. data/lib/axlsx/drawing/val_axis_data.rb +0 -28
  116. data/lib/axlsx/drawing/view_3D.rb +0 -85
  117. data/lib/axlsx/package.rb +0 -214
  118. data/lib/axlsx/rels/relationship.rb +0 -44
  119. data/lib/axlsx/rels/relationships.rb +0 -25
  120. data/lib/axlsx/stylesheet/border.rb +0 -57
  121. data/lib/axlsx/stylesheet/border_pr.rb +0 -68
  122. data/lib/axlsx/stylesheet/cell_alignment.rb +0 -105
  123. data/lib/axlsx/stylesheet/cell_protection.rb +0 -36
  124. data/lib/axlsx/stylesheet/cell_style.rb +0 -65
  125. data/lib/axlsx/stylesheet/color.rb +0 -69
  126. data/lib/axlsx/stylesheet/fill.rb +0 -32
  127. data/lib/axlsx/stylesheet/font.rb +0 -139
  128. data/lib/axlsx/stylesheet/gradient_fill.rb +0 -76
  129. data/lib/axlsx/stylesheet/gradient_stop.rb +0 -33
  130. data/lib/axlsx/stylesheet/num_fmt.rb +0 -63
  131. data/lib/axlsx/stylesheet/pattern_fill.rb +0 -66
  132. data/lib/axlsx/stylesheet/styles.rb +0 -298
  133. data/lib/axlsx/stylesheet/table_style.rb +0 -47
  134. data/lib/axlsx/stylesheet/table_style_element.rb +0 -71
  135. data/lib/axlsx/stylesheet/table_styles.rb +0 -39
  136. data/lib/axlsx/stylesheet/xf.rb +0 -138
  137. data/lib/axlsx/util/constants.rb +0 -216
  138. data/lib/axlsx/util/parser.rb +0 -43
  139. data/lib/axlsx/util/simple_typed_list.rb +0 -160
  140. data/lib/axlsx/util/validators.rb +0 -132
  141. data/lib/axlsx/version.rb +0 -4
  142. data/lib/axlsx/workbook/workbook.rb +0 -160
  143. data/lib/axlsx/workbook/worksheet/cell.rb +0 -340
  144. data/lib/axlsx/workbook/worksheet/row.rb +0 -107
  145. data/lib/axlsx/workbook/worksheet/worksheet.rb +0 -278
@@ -1,44 +0,0 @@
1
- module Axlsx
2
- # A relationship defines a reference between package parts.
3
- # @note Packages automatcially manage relationships.
4
- class Relationship
5
-
6
- # The location of the relationship target
7
- # @return [String]
8
- attr_reader :Target
9
-
10
- # The type of relationship
11
- # @note Supported types are defined as constants in Axlsx:
12
- # @see XML_NS_R
13
- # @see TABLE_R
14
- # @see WORKBOOK_R
15
- # @see WORKSHEET_R
16
- # @see APP_R
17
- # @see RELS_R
18
- # @see CORE_R
19
- # @see STYLES_R
20
- # @see CHART_R
21
- # @see DRAWING_R
22
- # @return [String]
23
- attr_reader :Type
24
- def initialize(type, target)
25
- self.Target=target
26
- self.Type=type
27
- end
28
-
29
- # @see Target
30
- def Target=(v) Axlsx::validate_string v; @Target = v end
31
- # @see Type
32
- def Type=(v) Axlsx::validate_relationship_type v; @Type = v end
33
-
34
- # Serializes the relationship
35
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
36
- # @param [String] rId the reference id of the object.
37
- # @return [String]
38
- def to_xml(xml, rId)
39
- h = self.instance_values
40
- h[:Id] = rId
41
- xml.Relationship(h)
42
- end
43
- end
44
- end
@@ -1,25 +0,0 @@
1
- module Axlsx
2
- require 'axlsx/rels/relationship.rb'
3
-
4
- # Relationships are a collection of Relations that define how package parts are related.
5
- # @note The package automatically manages releationships.
6
- class Relationships < SimpleTypedList
7
-
8
- # Creates a new Relationships collection based on SimpleTypedList
9
- def initialize
10
- super Relationship
11
- end
12
-
13
- # Serializes the relationships document.
14
- # @return [String]
15
- def to_xml()
16
- builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
17
- xml.Relationships(:xmlns => Axlsx::RELS_R) {
18
- each_with_index { |rel, index| rel.to_xml(xml, "rId#{index+1}") }
19
- }
20
- end
21
- builder.to_xml
22
- end
23
-
24
- end
25
- end
@@ -1,57 +0,0 @@
1
- module Axlsx
2
- # This class details a border used in Office Open XML spreadsheet styles.
3
- class Border
4
-
5
- # @return [Boolean] The diagonal up property for the border that indicates if the border should include a diagonal line from the bottom left to the top right of the cell.
6
- attr_reader :diagonalUp
7
-
8
- # @return [Boolean] The diagonal down property for the border that indicates if the border should include a diagonal line from the top left to the top right of the cell.
9
- attr_reader :diagonalDown
10
-
11
- # @return [Boolean] The outline property for the border indicating that top, left, right and bottom borders should only be applied to the outside border of a range of cells.
12
- attr_reader :outline
13
-
14
- # @return [SimpleTypedList] A list of BorderPr objects for this border.
15
- attr_reader :prs
16
-
17
- # Creates a new Border object
18
- # @option options [Boolean] diagonalUp
19
- # @option options [Boolean] diagonalDown
20
- # @option options [Boolean] outline
21
- # @example Making a border
22
- # p = Package.new
23
- # red_border = Border.new
24
- # [:left, :right, :top, :bottom].each do |item|
25
- # red_border.prs << BorderPr.new(:name=>item, :style=>:thin, :color=>Color.new(:rgb=>"FFFF0000")) #
26
- # end
27
- # # this sets red_border to be the index for the created border.
28
- # red_border = p.workbook.styles.@borders << red_border
29
- # #used in row creation as follows. This will add a red border to each of the cells in the row.
30
- # p.workbook.add_worksheet.rows << :values=>[1,2,3] :style=>red_border
31
- def initialize(options={})
32
- @prs = SimpleTypedList.new BorderPr
33
- options.each do |o|
34
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
35
- end
36
- end
37
-
38
- # @see diagonalUp
39
- def diagonalUp=(v) Axlsx::validate_boolean v; @diagonalUp = v end
40
- # @see diagonalDown
41
- def diagonalDown=(v) Axlsx::validate_boolean v; @diagonalDown = v end
42
- # @see outline
43
- def outline=(v) Axlsx::validate_boolean v; @outline = v end
44
-
45
- # Serializes the border element
46
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
47
- def to_xml(xml)
48
- xml.border(self.instance_values.select{ |k,v| [:diagonalUp, :diagonalDown, :outline].include? k }) {
49
- [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal].each do |k|
50
- @prs.select { |pr| pr.name == k }.each do |part|
51
- part.to_xml(xml)
52
- end
53
- end
54
- }
55
- end
56
- end
57
- end
@@ -1,68 +0,0 @@
1
- module Axlsx
2
- # A border part.
3
- class BorderPr
4
-
5
- # @return [Color] The color of this border part.
6
- attr_reader :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_reader :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_reader :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
- # @see name
53
- def name=(v) RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v; @name = v end
54
- # @see color
55
- def color=(v) DataTypeValidator.validate(:color, Color, v); @color = v end
56
- # @see style
57
- 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
58
-
59
- # Serializes the border part
60
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
61
- # @return [String]
62
- def to_xml(xml)
63
- xml.send(@name, :style => @style) {
64
- @color.to_xml(xml) if @color.is_a? Color
65
- }
66
- end
67
- end
68
- end
@@ -1,105 +0,0 @@
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_reader :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_reader :vertical
30
-
31
- # The textRotation of the cell.
32
- # @return [Integer]
33
- attr_reader :textRotation
34
-
35
- # Indicate if the text of the cell should wrap
36
- # @return [Boolean]
37
- attr_reader :wrapText
38
-
39
- # The amount of indent
40
- # @return [Integer]
41
- attr_reader :indent
42
-
43
- # The amount of relativeIndent
44
- # @return [Integer]
45
- attr_reader :relativeIndent
46
-
47
- # Indicate if the last line should be justified.
48
- # @return [Boolean]
49
- attr_reader :justifyLastLine
50
-
51
- # Indicate if the text should be shrunk to the fit in the cell.
52
- # @return [Boolean]
53
- attr_reader :shrinkToFit
54
-
55
- # The reading order of the text
56
- # 0 Context Dependent
57
- # 1 Left-to-Right
58
- # 2 Right-to-Left
59
- # @return [Integer]
60
- attr_reader :readingOrder
61
-
62
- # Create a new cell_alignment object
63
- # @option options [Symbol] horizontal
64
- # @option options [Symbol] vertical
65
- # @option options [Integer] textRotation
66
- # @option options [Boolean] wrapText
67
- # @option options [Integer] indent
68
- # @option options [Integer] relativeIndent
69
- # @option options [Boolean] justifyLastLine
70
- # @option options [Boolean] shrinkToFit
71
- # @option options [Integer] readingOrder
72
- def initialize(options={})
73
- options.each do |o|
74
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
75
- end
76
- end
77
-
78
- # @see horizontal
79
- def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
80
- # @see vertical
81
- def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
82
- # @see textRotation
83
- def textRotation=(v) Axlsx::validate_unsigned_int v; @textRotation = v end
84
- # @see wrapText
85
- def wrapText=(v) Axlsx::validate_boolean v; @wrapText = v end
86
- # @see indent
87
- def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
88
- # @see relativeIndent
89
- def relativeIndent=(v) Axlsx::validate_int v; @relativeIndent = v end
90
- # @see justifyLastLine
91
- def justifyLastLine=(v) Axlsx::validate_boolean v; @justifyLastLine = v end
92
- # @see shrinkToFit
93
- def shrinkToFit=(v) Axlsx::validate_boolean v; @shrinkToFit = v end
94
- # @see readingOrder
95
- def readingOrder=(v) Axlsx::validate_unsigned_int v; @readingOrder = v end
96
-
97
- # Serializes the cell alignment
98
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
99
- # @return [String]
100
- def to_xml(xml)
101
- xml.alignment(self.instance_values)
102
- end
103
-
104
- end
105
- end
@@ -1,36 +0,0 @@
1
- module Axlsx
2
- # CellProtection stores information about locking or hiding cells in spreadsheet.
3
- # @note Using Styles#add_style is the recommended way to manage cell protection.
4
- # @see Styles#add_style
5
- class CellProtection
6
-
7
- # specifies locking for cells that have the style containing this protection
8
- # @return [Boolean]
9
- attr_reader :hidden
10
-
11
- # specifies if the cells that have the style containing this protection
12
- # @return [Boolean]
13
- attr_reader :locked
14
-
15
- # Creates a new CellProtection
16
- # @option options [Boolean] hidden value for hidden protection
17
- # @option options [Boolean] locked value for locked protection
18
- def initialize(options={})
19
- options.each do |o|
20
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
21
- end
22
- end
23
-
24
- # @see hidden
25
- def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
26
- # @see locked
27
- def locked=(v) Axlsx::validate_boolean v; @locked = v end
28
-
29
- # Serializes the cell protection
30
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
31
- # @return [String]
32
- def to_xml(xml)
33
- xml.protection(self.instance_values)
34
- end
35
- end
36
- end
@@ -1,65 +0,0 @@
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_reader :name
9
-
10
- # The formatting record id this named style utilizes
11
- # @return [Integer]
12
- # @see Axlsx::Xf
13
- attr_reader :xfId
14
-
15
- # The buildinId to use when this named style is applied
16
- # @return [Integer]
17
- # @see Axlsx::NumFmt
18
- attr_reader :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_reader :iLevel
23
-
24
- # Determines if this named style should show in the list of styles when using excel
25
- # @return [Boolean]
26
- attr_reader :hidden
27
-
28
- # Indicates that the build in style reference has been customized.
29
- # @return [Boolean]
30
- attr_reader :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
- options.each do |o|
41
- self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
42
- end
43
- end
44
- # @see name
45
- def name=(v) Axlsx::validate_string v; @name = v end
46
- # @see xfId
47
- def xfId=(v) Axlsx::validate_unsigned_int v; @xfId = v end
48
- # @see builtinId
49
- def builtinId=(v) Axlsx::validate_unsigned_int v; @builtinId = v end
50
- # @see iLivel
51
- def iLevel=(v) Axlsx::validate_unsigned_int v; @iLevel = v end
52
- # @see hidden
53
- def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
54
- # @see customBuiltin
55
- def customBuiltin=(v) Axlsx::validate_boolean v; @customBuiltin = v end
56
-
57
- # Serializes the cell style
58
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
59
- # @return [String]
60
- def to_xml(xml)
61
- xml.cellStyle(self.instance_values)
62
- end
63
- end
64
-
65
- end
@@ -1,69 +0,0 @@
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_reader :auto
7
-
8
- # The color as defined in rgb terms.
9
- # @note
10
- # rgb colors need to conform to ST_UnsignedIntHex. That basically means put 'FF' before you color
11
- # When assigning the rgb value the behavior is much like CSS selectors and can use shorthand versions as follows:
12
- # If you provide a two character value it will be repeated for each r, g, b assignment
13
- # If you provide data that is not 2 characters in length, and is less than 8 characters it will be padded with "F"
14
- # @example
15
- # Color.new :rgb => "FF000000"
16
- # => #<Axlsx::Color:0x102106b68 @rgb="FF000000">
17
- # Color.new :rgb => "0A"
18
- # => #<Axlsx::Color:0x102106b68 @rgb="FF0A0A0A">
19
- # Color.new :rgb => "00BB"
20
- # => #<Axlsx::Color:0x102106b68 @rgb="FFFF00BB">
21
- # @return [String]
22
- attr_reader :rgb
23
-
24
- # no support for theme just yet
25
- # @return [Integer]
26
- #attr_reader :theme
27
-
28
- # The tint value.
29
- # @note valid values are between -1.0 and 1.0
30
- # @return [Float]
31
- attr_reader :tint
32
-
33
- # Creates a new Color object
34
- # @option options [Boolean] auto
35
- # @option options [String] rgb
36
- # @option options [Float] tint
37
- def initialize(options={})
38
- @rgb = "FF000000"
39
- options.each do |o|
40
- self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
41
- end
42
- end
43
- # @see auto
44
- def auto=(v) Axlsx::validate_boolean v; @auto = v end
45
- # @see color
46
- def rgb=(v)
47
- Axlsx::validate_string(v)
48
- v.upcase!
49
- v = v * 3 if v.size == 2
50
- v = v.rjust(8, 'FF')
51
- raise ArgumentError, "Invalid color rgb value: #{v}." unless v.match(/[0-9A-F]{8}/)
52
- @rgb = v
53
- end
54
- # @see tint
55
- def tint=(v) Axlsx::validate_float v; @tint = v end
56
-
57
- # This version does not support themes
58
- # def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
59
-
60
- # Indexed colors are for backward compatability which I am choosing not to support
61
- # def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end
62
-
63
-
64
- # Serializes the color
65
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
66
- # @return [String]
67
- def to_xml(xml) xml.color(self.instance_values) end
68
- end
69
- end