caxlsx 3.3.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +87 -11
  3. data/README.md +43 -16
  4. data/Rakefile +5 -11
  5. data/examples/generate.rb +3 -1
  6. data/lib/axlsx/content_type/abstract_content_type.rb +15 -10
  7. data/lib/axlsx/content_type/content_type.rb +8 -10
  8. data/lib/axlsx/content_type/default.rb +7 -6
  9. data/lib/axlsx/content_type/override.rb +6 -5
  10. data/lib/axlsx/doc_props/app.rb +96 -32
  11. data/lib/axlsx/doc_props/core.rb +9 -12
  12. data/lib/axlsx/drawing/area_chart.rb +16 -17
  13. data/lib/axlsx/drawing/area_series.rb +23 -18
  14. data/lib/axlsx/drawing/ax_data_source.rb +4 -7
  15. data/lib/axlsx/drawing/axes.rb +11 -10
  16. data/lib/axlsx/drawing/axis.rb +83 -36
  17. data/lib/axlsx/drawing/bar_3D_chart.rb +30 -21
  18. data/lib/axlsx/drawing/bar_chart.rb +29 -20
  19. data/lib/axlsx/drawing/bar_series.rb +23 -18
  20. data/lib/axlsx/drawing/bubble_chart.rb +9 -10
  21. data/lib/axlsx/drawing/bubble_series.rb +11 -12
  22. data/lib/axlsx/drawing/cat_axis.rb +38 -28
  23. data/lib/axlsx/drawing/chart.rb +52 -30
  24. data/lib/axlsx/drawing/d_lbls.rb +36 -32
  25. data/lib/axlsx/drawing/drawing.rb +61 -62
  26. data/lib/axlsx/drawing/graphic_frame.rb +6 -7
  27. data/lib/axlsx/drawing/hyperlink.rb +22 -14
  28. data/lib/axlsx/drawing/line_3D_chart.rb +15 -17
  29. data/lib/axlsx/drawing/line_chart.rb +16 -17
  30. data/lib/axlsx/drawing/line_series.rb +23 -18
  31. data/lib/axlsx/drawing/marker.rb +29 -16
  32. data/lib/axlsx/drawing/num_data.rb +13 -16
  33. data/lib/axlsx/drawing/num_data_source.rb +11 -13
  34. data/lib/axlsx/drawing/num_val.rb +10 -11
  35. data/lib/axlsx/drawing/one_cell_anchor.rb +16 -10
  36. data/lib/axlsx/drawing/pic.rb +68 -24
  37. data/lib/axlsx/drawing/picture_locking.rb +6 -7
  38. data/lib/axlsx/drawing/pie_3D_chart.rb +9 -12
  39. data/lib/axlsx/drawing/pie_chart.rb +36 -0
  40. data/lib/axlsx/drawing/pie_series.rb +26 -17
  41. data/lib/axlsx/drawing/scaling.rb +26 -13
  42. data/lib/axlsx/drawing/scatter_chart.rb +10 -11
  43. data/lib/axlsx/drawing/scatter_series.rb +17 -18
  44. data/lib/axlsx/drawing/ser_axis.rb +22 -19
  45. data/lib/axlsx/drawing/series.rb +14 -8
  46. data/lib/axlsx/drawing/series_title.rb +6 -6
  47. data/lib/axlsx/drawing/str_data.rb +10 -13
  48. data/lib/axlsx/drawing/str_val.rb +8 -9
  49. data/lib/axlsx/drawing/title.rb +23 -27
  50. data/lib/axlsx/drawing/two_cell_anchor.rb +9 -9
  51. data/lib/axlsx/drawing/val_axis.rb +7 -8
  52. data/lib/axlsx/drawing/view_3D.rb +38 -30
  53. data/lib/axlsx/drawing/vml_drawing.rb +19 -20
  54. data/lib/axlsx/drawing/vml_shape.rb +25 -26
  55. data/lib/axlsx/package.rb +134 -99
  56. data/lib/axlsx/rels/relationship.rb +42 -30
  57. data/lib/axlsx/rels/relationships.rb +9 -10
  58. data/lib/axlsx/stylesheet/border.rb +16 -8
  59. data/lib/axlsx/stylesheet/border_pr.rb +24 -12
  60. data/lib/axlsx/stylesheet/cell_alignment.rb +44 -21
  61. data/lib/axlsx/stylesheet/cell_protection.rb +13 -7
  62. data/lib/axlsx/stylesheet/cell_style.rb +36 -15
  63. data/lib/axlsx/stylesheet/color.rb +23 -14
  64. data/lib/axlsx/stylesheet/dxf.rb +36 -15
  65. data/lib/axlsx/stylesheet/fill.rb +7 -6
  66. data/lib/axlsx/stylesheet/font.rb +71 -22
  67. data/lib/axlsx/stylesheet/gradient_fill.rb +16 -10
  68. data/lib/axlsx/stylesheet/gradient_stop.rb +14 -6
  69. data/lib/axlsx/stylesheet/num_fmt.rb +15 -14
  70. data/lib/axlsx/stylesheet/pattern_fill.rb +20 -8
  71. data/lib/axlsx/stylesheet/styles.rb +167 -118
  72. data/lib/axlsx/stylesheet/table_style.rb +20 -10
  73. data/lib/axlsx/stylesheet/table_style_element.rb +16 -8
  74. data/lib/axlsx/stylesheet/table_styles.rb +16 -11
  75. data/lib/axlsx/stylesheet/theme.rb +163 -0
  76. data/lib/axlsx/stylesheet/xf.rb +78 -25
  77. data/lib/axlsx/util/accessors.rb +13 -11
  78. data/lib/axlsx/util/buffered_zip_output_stream.rb +64 -0
  79. data/lib/axlsx/util/constants.rb +133 -110
  80. data/lib/axlsx/util/mime_type_utils.rb +75 -5
  81. data/lib/axlsx/util/options_parser.rb +4 -3
  82. data/lib/axlsx/util/serialized_attributes.rb +47 -23
  83. data/lib/axlsx/util/simple_typed_list.rb +77 -64
  84. data/lib/axlsx/util/storage.rb +38 -41
  85. data/lib/axlsx/util/uri_utils.rb +70 -0
  86. data/lib/axlsx/util/validators.rb +111 -48
  87. data/lib/axlsx/util/zip_command.rb +10 -12
  88. data/lib/axlsx/version.rb +3 -2
  89. data/lib/axlsx/workbook/defined_name.rb +13 -9
  90. data/lib/axlsx/workbook/defined_names.rb +5 -4
  91. data/lib/axlsx/workbook/shared_strings_table.rb +13 -14
  92. data/lib/axlsx/workbook/workbook.rb +152 -120
  93. data/lib/axlsx/workbook/workbook_view.rb +9 -12
  94. data/lib/axlsx/workbook/workbook_views.rb +5 -5
  95. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +87 -15
  96. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +16 -10
  97. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +28 -25
  98. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +51 -0
  99. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +54 -0
  100. data/lib/axlsx/workbook/worksheet/border_creator.rb +34 -29
  101. data/lib/axlsx/workbook/worksheet/break.rb +4 -5
  102. data/lib/axlsx/workbook/worksheet/cell.rb +125 -78
  103. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +33 -29
  104. data/lib/axlsx/workbook/worksheet/cfvo.rb +13 -5
  105. data/lib/axlsx/workbook/worksheet/cfvos.rb +5 -5
  106. data/lib/axlsx/workbook/worksheet/col.rb +32 -19
  107. data/lib/axlsx/workbook/worksheet/col_breaks.rb +9 -8
  108. data/lib/axlsx/workbook/worksheet/color_scale.rb +16 -16
  109. data/lib/axlsx/workbook/worksheet/cols.rb +10 -8
  110. data/lib/axlsx/workbook/worksheet/comment.rb +14 -13
  111. data/lib/axlsx/workbook/worksheet/comments.rb +11 -13
  112. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +19 -9
  113. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +75 -22
  114. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +8 -8
  115. data/lib/axlsx/workbook/worksheet/data_bar.rb +29 -30
  116. data/lib/axlsx/workbook/worksheet/data_validation.rb +73 -33
  117. data/lib/axlsx/workbook/worksheet/data_validations.rb +8 -9
  118. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +8 -8
  119. data/lib/axlsx/workbook/worksheet/dimension.rb +10 -7
  120. data/lib/axlsx/workbook/worksheet/header_footer.rb +5 -4
  121. data/lib/axlsx/workbook/worksheet/icon_set.rb +40 -12
  122. data/lib/axlsx/workbook/worksheet/merged_cells.rb +11 -11
  123. data/lib/axlsx/workbook/worksheet/outline_pr.rb +7 -4
  124. data/lib/axlsx/workbook/worksheet/page_margins.rb +41 -13
  125. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +7 -6
  126. data/lib/axlsx/workbook/worksheet/page_setup.rb +153 -131
  127. data/lib/axlsx/workbook/worksheet/pane.rb +34 -26
  128. data/lib/axlsx/workbook/worksheet/pivot_table.rb +78 -29
  129. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +12 -13
  130. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +6 -5
  131. data/lib/axlsx/workbook/worksheet/print_options.rb +4 -2
  132. data/lib/axlsx/workbook/worksheet/protected_range.rb +6 -5
  133. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +13 -11
  134. data/lib/axlsx/workbook/worksheet/rich_text.rb +6 -6
  135. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +66 -28
  136. data/lib/axlsx/workbook/worksheet/row.rb +34 -23
  137. data/lib/axlsx/workbook/worksheet/row_breaks.rb +9 -8
  138. data/lib/axlsx/workbook/worksheet/selection.rb +22 -16
  139. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +11 -7
  140. data/lib/axlsx/workbook/worksheet/sheet_data.rb +7 -7
  141. data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +23 -19
  142. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +12 -8
  143. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +22 -21
  144. data/lib/axlsx/workbook/worksheet/sheet_view.rb +71 -55
  145. data/lib/axlsx/workbook/worksheet/table.rb +13 -13
  146. data/lib/axlsx/workbook/worksheet/table_style_info.rb +8 -6
  147. data/lib/axlsx/workbook/worksheet/tables.rb +8 -6
  148. data/lib/axlsx/workbook/worksheet/worksheet.rb +120 -79
  149. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +13 -11
  150. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +11 -4
  151. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +12 -10
  152. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +9 -7
  153. data/lib/axlsx.rb +120 -60
  154. data/lib/caxlsx.rb +3 -2
  155. metadata +42 -75
@@ -1,8 +1,8 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
4
  # This class details a border used in Office Open XML spreadsheet styles.
4
5
  class Border
5
-
6
6
  include Axlsx::SerializedAttributes
7
7
  include Axlsx::OptionsParser
8
8
 
@@ -21,7 +21,7 @@ module Axlsx
21
21
  #
22
22
  # @note The recommended way to manage borders is with Style#add_style
23
23
  # @see Style#add_style
24
- def initialize(options={})
24
+ def initialize(options = {})
25
25
  @prs = SimpleTypedList.new BorderPr
26
26
  parse_options options
27
27
  end
@@ -43,20 +43,29 @@ module Axlsx
43
43
  attr_reader :prs
44
44
 
45
45
  # @see diagonalUp
46
- def diagonal_up=(v) Axlsx::validate_boolean v; @diagonal_up = v end
46
+ def diagonal_up=(v)
47
+ Axlsx.validate_boolean v
48
+ @diagonal_up = v
49
+ end
47
50
  alias :diagonalUp= :diagonal_up=
48
51
 
49
52
  # @see diagonalDown
50
- def diagonal_down=(v) Axlsx::validate_boolean v; @diagonal_down = v end
53
+ def diagonal_down=(v)
54
+ Axlsx.validate_boolean v
55
+ @diagonal_down = v
56
+ end
51
57
  alias :diagonalDown= :diagonal_down=
52
58
 
53
59
  # @see outline
54
- def outline=(v) Axlsx::validate_boolean v; @outline = v end
60
+ def outline=(v)
61
+ Axlsx.validate_boolean v
62
+ @outline = v
63
+ end
55
64
 
56
65
  # Serializes the object
57
66
  # @param [String] str
58
67
  # @return [String]
59
- def to_xml_string(str = '')
68
+ def to_xml_string(str = +'')
60
69
  str << '<border '
61
70
  serialized_attributes str
62
71
  str << '>'
@@ -68,6 +77,5 @@ module Axlsx
68
77
  end
69
78
  str << '</border>'
70
79
  end
71
-
72
80
  end
73
81
  end
@@ -1,12 +1,14 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
4
  # A border part.
4
5
  class BorderPr
5
6
  include Axlsx::OptionsParser
7
+
6
8
  # @return [Color] The color of this border part.
7
9
  attr_reader :color
8
10
 
9
- # @return [Symbol] The syle of this border part.
11
+ # @return [Symbol] The style of this border part.
10
12
  # @note
11
13
  # The following are allowed
12
14
  # :none
@@ -44,28 +46,38 @@ module Axlsx
44
46
  # @option options [Symbol] name
45
47
  # @option options [Symbol] style
46
48
  # @see Axlsx::Border
47
- def initialize(options={})
49
+ def initialize(options = {})
48
50
  parse_options(options)
49
- #options.each do |o|
51
+ # options.each do |o|
50
52
  # self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
51
- #end
53
+ # end
52
54
  end
53
55
 
54
56
  # @see name
55
- def name=(v) RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v; @name = v end
57
+ def name=(v)
58
+ RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v
59
+ @name = v
60
+ end
61
+
56
62
  # @see color
57
- def color=(v) DataTypeValidator.validate(:color, Color, v); @color = v end
63
+ def color=(v)
64
+ DataTypeValidator.validate(:color, Color, v)
65
+ @color = v
66
+ end
67
+
58
68
  # @see style
59
- 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
69
+ def style=(v)
70
+ RestrictionValidator.validate "BorderPr.style", [:none, :thin, :medium, :dashed, :dotted, :thick, :double, :hair, :mediumDashed, :dashDot, :mediumDashDot, :dashDotDot, :mediumDashDotDot, :slantDashDot], v
71
+ @style = v
72
+ end
60
73
 
61
74
  # Serializes the object
62
75
  # @param [String] str
63
76
  # @return [String]
64
- def to_xml_string(str = '')
65
- str << ('<' << @name.to_s << ' style="' << @style.to_s << '">')
77
+ def to_xml_string(str = +'')
78
+ str << '<' << @name.to_s << ' style="' << @style.to_s << '">'
66
79
  @color.to_xml_string(str) if @color.is_a?(Color)
67
- str << ('</' << @name.to_s << '>')
80
+ str << '</' << @name.to_s << '>'
68
81
  end
69
-
70
82
  end
71
83
  end
@@ -1,16 +1,13 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
-
4
-
5
4
  # CellAlignment stores information about the cell alignment of a style Xf Object.
6
5
  # @note Using Styles#add_style is the recommended way to manage cell alignment.
7
6
  # @see Styles#add_style
8
7
  class CellAlignment
9
-
10
-
11
8
  include Axlsx::SerializedAttributes
12
9
  include Axlsx::OptionsParser
13
-
10
+
14
11
  serializable_attributes :horizontal, :vertical, :text_rotation, :wrap_text, :indent, :relative_indent, :justify_last_line, :shrink_to_fit, :reading_order
15
12
  # Create a new cell_alignment object
16
13
  # @option options [Symbol] horizontal
@@ -22,15 +19,13 @@ module Axlsx
22
19
  # @option options [Boolean] justify_last_line
23
20
  # @option options [Boolean] shrink_to_fit
24
21
  # @option options [Integer] reading_order
25
- def initialize(options={})
22
+ def initialize(options = {})
26
23
  parse_options options
27
24
  end
28
25
 
29
-
30
-
31
26
  # The horizontal alignment of the cell.
32
27
  # @note
33
- # The horizontal cell alignement style must be one of
28
+ # The horizontal cell alignment style must be one of
34
29
  # :general
35
30
  # :left
36
31
  # :center
@@ -91,42 +86,70 @@ module Axlsx
91
86
  alias :readingOrder :reading_order
92
87
 
93
88
  # @see horizontal
94
- def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
89
+ def horizontal=(v)
90
+ Axlsx.validate_horizontal_alignment v
91
+ @horizontal = v
92
+ end
93
+
95
94
  # @see vertical
96
- def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
95
+ def vertical=(v)
96
+ Axlsx.validate_vertical_alignment v
97
+ @vertical = v
98
+ end
99
+
97
100
  # @see textRotation
98
- def text_rotation=(v) Axlsx::validate_unsigned_int v; @text_rotation = v end
101
+ def text_rotation=(v)
102
+ Axlsx.validate_unsigned_int v
103
+ @text_rotation = v
104
+ end
99
105
  alias :textRotation= :text_rotation=
100
106
 
101
107
  # @see wrapText
102
- def wrap_text=(v) Axlsx::validate_boolean v; @wrap_text = v end
108
+ def wrap_text=(v)
109
+ Axlsx.validate_boolean v
110
+ @wrap_text = v
111
+ end
103
112
  alias :wrapText= :wrap_text=
104
113
 
105
114
  # @see indent
106
- def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
115
+ def indent=(v)
116
+ Axlsx.validate_unsigned_int v
117
+ @indent = v
118
+ end
107
119
 
108
120
  # @see relativeIndent
109
- def relative_indent=(v) Axlsx::validate_int v; @relative_indent = v end
121
+ def relative_indent=(v)
122
+ Axlsx.validate_int v
123
+ @relative_indent = v
124
+ end
110
125
  alias :relativeIndent= :relative_indent=
111
126
 
112
127
  # @see justifyLastLine
113
- def justify_last_line=(v) Axlsx::validate_boolean v; @justify_last_line = v end
128
+ def justify_last_line=(v)
129
+ Axlsx.validate_boolean v
130
+ @justify_last_line = v
131
+ end
114
132
  alias :justifyLastLine= :justify_last_line=
115
133
 
116
134
  # @see shrinkToFit
117
- def shrink_to_fit=(v) Axlsx::validate_boolean v; @shrink_to_fit = v end
135
+ def shrink_to_fit=(v)
136
+ Axlsx.validate_boolean v
137
+ @shrink_to_fit = v
138
+ end
118
139
  alias :shrinkToFit= :shrink_to_fit=
119
140
 
120
141
  # @see readingOrder
121
- def reading_order=(v) Axlsx::validate_unsigned_int v; @reading_order = v end
142
+ def reading_order=(v)
143
+ Axlsx.validate_unsigned_int v
144
+ @reading_order = v
145
+ end
122
146
  alias :readingOrder= :reading_order=
123
147
 
124
148
  # Serializes the object
125
149
  # @param [String] str
126
150
  # @return [String]
127
- def to_xml_string(str = '')
151
+ def to_xml_string(str = +'')
128
152
  serialized_tag('alignment', str)
129
153
  end
130
-
131
154
  end
132
155
  end
@@ -1,10 +1,10 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
4
  # CellProtection stores information about locking or hiding cells in spreadsheet.
4
5
  # @note Using Styles#add_style is the recommended way to manage cell protection.
5
6
  # @see Styles#add_style
6
7
  class CellProtection
7
-
8
8
  include Axlsx::OptionsParser
9
9
  include Axlsx::SerializedAttributes
10
10
 
@@ -21,21 +21,27 @@ module Axlsx
21
21
  # Creates a new CellProtection
22
22
  # @option options [Boolean] hidden value for hidden protection
23
23
  # @option options [Boolean] locked value for locked protection
24
- def initialize(options={})
24
+ def initialize(options = {})
25
25
  parse_options options
26
26
  end
27
27
 
28
28
  # @see hidden
29
- def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
29
+ def hidden=(v)
30
+ Axlsx.validate_boolean v
31
+ @hidden = v
32
+ end
33
+
30
34
  # @see locked
31
- def locked=(v) Axlsx::validate_boolean v; @locked = v end
35
+ def locked=(v)
36
+ Axlsx.validate_boolean v
37
+ @locked = v
38
+ end
32
39
 
33
40
  # Serializes the object
34
41
  # @param [String] str
35
42
  # @return [String]
36
- def to_xml_string(str = '')
43
+ def to_xml_string(str = +'')
37
44
  serialized_tag('protection', str)
38
45
  end
39
-
40
46
  end
41
47
  end
@@ -1,21 +1,21 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
4
  # CellStyle defines named styles that reference defined formatting records and can be used in your worksheet.
4
5
  # @note Using Styles#add_style is the recommended way to manage cell styling.
5
6
  # @see Styles#add_style
6
7
  class CellStyle
7
-
8
8
  include Axlsx::OptionsParser
9
9
  include Axlsx::SerializedAttributes
10
10
 
11
- # Creats a new CellStyle object
11
+ # Creates a new CellStyle object
12
12
  # @option options [String] name
13
13
  # @option options [Integer] xfId
14
14
  # @option options [Integer] buildinId
15
15
  # @option options [Integer] iLevel
16
16
  # @option options [Boolean] hidden
17
17
  # @option options [Boolean] customBuiltIn
18
- def initialize(options={})
18
+ def initialize(options = {})
19
19
  parse_options options
20
20
  end
21
21
 
@@ -39,7 +39,7 @@ module Axlsx
39
39
  # @return [Integer]
40
40
  attr_reader :iLevel
41
41
 
42
- # Determines if this named style should show in the list of styles when using excel
42
+ # Determines if this named style should show in the list of styles when using Excel
43
43
  # @return [Boolean]
44
44
  attr_reader :hidden
45
45
 
@@ -47,26 +47,47 @@ module Axlsx
47
47
  # @return [Boolean]
48
48
  attr_reader :customBuiltin
49
49
 
50
- # @see name
51
- def name=(v) Axlsx::validate_string v; @name = v end
50
+ # @see name
51
+ def name=(v)
52
+ Axlsx.validate_string v
53
+ @name = v
54
+ end
55
+
52
56
  # @see xfId
53
- def xfId=(v) Axlsx::validate_unsigned_int v; @xfId = v end
57
+ def xfId=(v)
58
+ Axlsx.validate_unsigned_int v
59
+ @xfId = v
60
+ end
61
+
54
62
  # @see builtinId
55
- def builtinId=(v) Axlsx::validate_unsigned_int v; @builtinId = v end
63
+ def builtinId=(v)
64
+ Axlsx.validate_unsigned_int v
65
+ @builtinId = v
66
+ end
67
+
56
68
  # @see iLivel
57
- def iLevel=(v) Axlsx::validate_unsigned_int v; @iLevel = v end
69
+ def iLevel=(v)
70
+ Axlsx.validate_unsigned_int v
71
+ @iLevel = v
72
+ end
73
+
58
74
  # @see hidden
59
- def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
75
+ def hidden=(v)
76
+ Axlsx.validate_boolean v
77
+ @hidden = v
78
+ end
79
+
60
80
  # @see customBuiltin
61
- def customBuiltin=(v) Axlsx::validate_boolean v; @customBuiltin = v end
81
+ def customBuiltin=(v)
82
+ Axlsx.validate_boolean v
83
+ @customBuiltin = v
84
+ end
62
85
 
63
86
  # Serializes the object
64
87
  # @param [String] str
65
88
  # @return [String]
66
- def to_xml_string(str = '')
89
+ def to_xml_string(str = +'')
67
90
  serialized_tag('cellStyle', str)
68
91
  end
69
-
70
92
  end
71
-
72
93
  end
@@ -1,8 +1,8 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
4
  # The color class represents a color used for borders, fills an fonts
4
5
  class Color
5
-
6
6
  include Axlsx::OptionsParser
7
7
  include Axlsx::SerializedAttributes
8
8
 
@@ -10,14 +10,14 @@ module Axlsx
10
10
  # @option options [Boolean] auto
11
11
  # @option options [String] rgb
12
12
  # @option options [Float] tint
13
- def initialize(options={})
13
+ def initialize(options = {})
14
14
  @rgb = "FF000000"
15
15
  parse_options options
16
16
  end
17
17
 
18
18
  serializable_attributes :auto, :rgb, :tint
19
19
 
20
- # Determines if the color is system color dependant
20
+ # Determines if the color is system color dependent
21
21
  # @return [Boolean]
22
22
  attr_reader :auto
23
23
 
@@ -39,38 +39,47 @@ module Axlsx
39
39
 
40
40
  # no support for theme just yet
41
41
  # @return [Integer]
42
- #attr_reader :theme
42
+ # attr_reader :theme
43
43
 
44
44
  # The tint value.
45
45
  # @note valid values are between -1.0 and 1.0
46
46
  # @return [Float]
47
47
  attr_reader :tint
48
48
 
49
- # @see auto
50
- def auto=(v) Axlsx::validate_boolean v; @auto = v end
49
+ # @see auto
50
+ def auto=(v)
51
+ Axlsx.validate_boolean v
52
+ @auto = v
53
+ end
54
+
51
55
  # @see color
52
56
  def rgb=(v)
53
- Axlsx::validate_string(v)
57
+ Axlsx.validate_string(v)
54
58
  v = v.upcase
55
- v = v * 3 if v.size == 2
59
+ v *= 3 if v.size == 2
56
60
  v = v.rjust(8, 'FF')
57
- raise ArgumentError, "Invalid color rgb value: #{v}." unless v.match(/[0-9A-F]{8}/)
61
+ raise ArgumentError, "Invalid color rgb value: #{v}." unless /[0-9A-F]{8}/.match?(v)
62
+
58
63
  @rgb = v
59
64
  end
65
+
60
66
  # @see tint
61
- def tint=(v) Axlsx::validate_float v; @tint = v end
67
+ def tint=(v)
68
+ Axlsx.validate_float v
69
+ @tint = v
70
+ end
62
71
 
63
72
  # This version does not support themes
64
73
  # def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
65
74
 
66
- # Indexed colors are for backward compatability which I am choosing not to support
75
+ # Indexed colors are for backward compatibility which I am choosing not to support
67
76
  # def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end
68
77
 
69
78
  # Serializes the object
70
79
  # @param [String] str
71
80
  # @return [String]
72
- def to_xml_string(str = '', tag_name = 'color')
73
- serialized_tag('' + tag_name + '', str)
81
+ def to_xml_string(str = +'', tag_name = 'color')
82
+ serialized_tag(tag_name.to_s, str)
74
83
  end
75
84
  end
76
85
  end
@@ -1,15 +1,15 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
4
  # 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
4
5
  # @see Styles#add_style
5
6
  class Dxf
6
-
7
7
  include Axlsx::OptionsParser
8
8
 
9
9
  # The order in which the child elements is put in the XML seems to
10
10
  # be important for Excel
11
- CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection]
12
- #does not support extList (ExtensionList)
11
+ CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection].freeze
12
+ # does not support extList (ExtensionList)
13
13
 
14
14
  # The cell alignment for this style
15
15
  # @return [CellAlignment]
@@ -44,36 +44,57 @@ module Axlsx
44
44
  # @option options [Font] font
45
45
  # @option options [CellAlignment] alignment
46
46
  # @option options [CellProtection] protection
47
- def initialize(options={})
47
+ def initialize(options = {})
48
48
  parse_options options
49
49
  end
50
50
 
51
51
  # @see Dxf#alignment
52
- def alignment=(v) DataTypeValidator.validate "Dxf.alignment", CellAlignment, v; @alignment = v end
52
+ def alignment=(v)
53
+ DataTypeValidator.validate "Dxf.alignment", CellAlignment, v
54
+ @alignment = v
55
+ end
56
+
53
57
  # @see protection
54
- def protection=(v) DataTypeValidator.validate "Dxf.protection", CellProtection, v; @protection = v end
58
+ def protection=(v)
59
+ DataTypeValidator.validate "Dxf.protection", CellProtection, v
60
+ @protection = v
61
+ end
62
+
55
63
  # @see numFmt
56
- def numFmt=(v) DataTypeValidator.validate "Dxf.numFmt", NumFmt, v; @numFmt = v end
64
+ def numFmt=(v)
65
+ DataTypeValidator.validate "Dxf.numFmt", NumFmt, v
66
+ @numFmt = v
67
+ end
68
+
57
69
  # @see font
58
- def font=(v) DataTypeValidator.validate "Dxf.font", Font, v; @font = v end
70
+ def font=(v)
71
+ DataTypeValidator.validate "Dxf.font", Font, v
72
+ @font = v
73
+ end
74
+
59
75
  # @see border
60
- def border=(v) DataTypeValidator.validate "Dxf.border", Border, v; @border = v end
76
+ def border=(v)
77
+ DataTypeValidator.validate "Dxf.border", Border, v
78
+ @border = v
79
+ end
80
+
61
81
  # @see fill
62
- def fill=(v) DataTypeValidator.validate "Dxf.fill", Fill, v; @fill = v end
82
+ def fill=(v)
83
+ DataTypeValidator.validate "Dxf.fill", Fill, v
84
+ @fill = v
85
+ end
63
86
 
64
87
  # Serializes the object
65
88
  # @param [String] str
66
89
  # @return [String]
67
- def to_xml_string(str = '')
90
+ def to_xml_string(str = +'')
68
91
  str << '<dxf>'
69
92
  # Dxf elements have no attributes. All of the instance variables
70
93
  # are child elements.
71
94
  CHILD_ELEMENTS.each do |element|
72
- self.send(element).to_xml_string(str) if self.send(element)
95
+ send(element).to_xml_string(str) if send(element)
73
96
  end
74
97
  str << '</dxf>'
75
98
  end
76
-
77
99
  end
78
-
79
100
  end
@@ -1,4 +1,5 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
4
  # The Fill is a formatting object that manages the background color, and pattern for cells.
4
5
  # @note The recommended way to manage styles in your workbook is to use Styles#add_style.
@@ -6,7 +7,6 @@ module Axlsx
6
7
  # @see PatternFill
7
8
  # @see GradientFill
8
9
  class Fill
9
-
10
10
  # The type of fill
11
11
  # @return [PatternFill, GradientFill]
12
12
  attr_reader :fill_type
@@ -21,15 +21,16 @@ module Axlsx
21
21
  # Serializes the object
22
22
  # @param [String] str
23
23
  # @return [String]
24
- def to_xml_string(str = '')
24
+ def to_xml_string(str = +'')
25
25
  str << '<fill>'
26
26
  @fill_type.to_xml_string(str)
27
27
  str << '</fill>'
28
28
  end
29
29
 
30
30
  # @see fill_type
31
- def fill_type=(v) DataTypeValidator.validate "Fill.fill_type", [PatternFill, GradientFill], v; @fill_type = v; end
32
-
33
-
31
+ def fill_type=(v)
32
+ DataTypeValidator.validate "Fill.fill_type", [PatternFill, GradientFill], v
33
+ @fill_type = v
34
+ end
34
35
  end
35
36
  end