caxlsx 3.4.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -1
  3. data/README.md +9 -11
  4. data/Rakefile +7 -5
  5. data/examples/generate.rb +3 -1
  6. data/lib/axlsx/content_type/abstract_content_type.rb +12 -4
  7. data/lib/axlsx/content_type/content_type.rb +8 -6
  8. data/lib/axlsx/content_type/default.rb +7 -2
  9. data/lib/axlsx/content_type/override.rb +7 -2
  10. data/lib/axlsx/doc_props/app.rb +95 -26
  11. data/lib/axlsx/doc_props/core.rb +8 -6
  12. data/lib/axlsx/drawing/area_chart.rb +10 -8
  13. data/lib/axlsx/drawing/area_series.rb +20 -12
  14. data/lib/axlsx/drawing/ax_data_source.rb +2 -0
  15. data/lib/axlsx/drawing/axes.rb +6 -4
  16. data/lib/axlsx/drawing/axis.rb +42 -22
  17. data/lib/axlsx/drawing/bar_3D_chart.rb +14 -12
  18. data/lib/axlsx/drawing/bar_chart.rb +13 -11
  19. data/lib/axlsx/drawing/bar_series.rb +20 -9
  20. data/lib/axlsx/drawing/bubble_chart.rb +6 -4
  21. data/lib/axlsx/drawing/bubble_series.rb +8 -6
  22. data/lib/axlsx/drawing/cat_axis.rb +29 -12
  23. data/lib/axlsx/drawing/chart.rb +46 -20
  24. data/lib/axlsx/drawing/d_lbls.rb +10 -8
  25. data/lib/axlsx/drawing/drawing.rb +59 -56
  26. data/lib/axlsx/drawing/graphic_frame.rb +6 -4
  27. data/lib/axlsx/drawing/hyperlink.rb +19 -8
  28. data/lib/axlsx/drawing/line_3D_chart.rb +7 -5
  29. data/lib/axlsx/drawing/line_chart.rb +10 -8
  30. data/lib/axlsx/drawing/line_series.rb +20 -12
  31. data/lib/axlsx/drawing/marker.rb +24 -7
  32. data/lib/axlsx/drawing/num_data.rb +9 -7
  33. data/lib/axlsx/drawing/num_data_source.rb +9 -7
  34. data/lib/axlsx/drawing/num_val.rb +7 -5
  35. data/lib/axlsx/drawing/one_cell_anchor.rb +13 -5
  36. data/lib/axlsx/drawing/pic.rb +26 -15
  37. data/lib/axlsx/drawing/picture_locking.rb +3 -1
  38. data/lib/axlsx/drawing/pie_3D_chart.rb +6 -4
  39. data/lib/axlsx/drawing/pie_chart.rb +36 -0
  40. data/lib/axlsx/drawing/pie_series.rb +23 -9
  41. data/lib/axlsx/drawing/scaling.rb +25 -9
  42. data/lib/axlsx/drawing/scatter_chart.rb +7 -5
  43. data/lib/axlsx/drawing/scatter_series.rb +14 -12
  44. data/lib/axlsx/drawing/ser_axis.rb +13 -5
  45. data/lib/axlsx/drawing/series.rb +13 -5
  46. data/lib/axlsx/drawing/series_title.rb +6 -4
  47. data/lib/axlsx/drawing/str_data.rb +7 -5
  48. data/lib/axlsx/drawing/str_val.rb +6 -4
  49. data/lib/axlsx/drawing/title.rb +13 -14
  50. data/lib/axlsx/drawing/two_cell_anchor.rb +4 -2
  51. data/lib/axlsx/drawing/val_axis.rb +4 -2
  52. data/lib/axlsx/drawing/view_3D.rb +16 -8
  53. data/lib/axlsx/drawing/vml_drawing.rb +18 -16
  54. data/lib/axlsx/drawing/vml_shape.rb +24 -22
  55. data/lib/axlsx/package.rb +73 -67
  56. data/lib/axlsx/rels/relationship.rb +21 -6
  57. data/lib/axlsx/rels/relationships.rb +6 -4
  58. data/lib/axlsx/stylesheet/border.rb +15 -4
  59. data/lib/axlsx/stylesheet/border_pr.rb +19 -6
  60. data/lib/axlsx/stylesheet/cell_alignment.rb +41 -10
  61. data/lib/axlsx/stylesheet/cell_protection.rb +12 -3
  62. data/lib/axlsx/stylesheet/cell_style.rb +33 -8
  63. data/lib/axlsx/stylesheet/color.rb +15 -7
  64. data/lib/axlsx/stylesheet/dxf.rb +34 -9
  65. data/lib/axlsx/stylesheet/fill.rb +7 -2
  66. data/lib/axlsx/stylesheet/font.rb +65 -17
  67. data/lib/axlsx/stylesheet/gradient_fill.rb +12 -4
  68. data/lib/axlsx/stylesheet/gradient_stop.rb +14 -5
  69. data/lib/axlsx/stylesheet/num_fmt.rb +14 -10
  70. data/lib/axlsx/stylesheet/pattern_fill.rb +18 -5
  71. data/lib/axlsx/stylesheet/styles.rb +124 -82
  72. data/lib/axlsx/stylesheet/table_style.rb +19 -6
  73. data/lib/axlsx/stylesheet/table_style_element.rb +15 -4
  74. data/lib/axlsx/stylesheet/table_styles.rb +14 -5
  75. data/lib/axlsx/stylesheet/xf.rb +73 -18
  76. data/lib/axlsx/util/accessors.rb +10 -6
  77. data/lib/axlsx/util/buffered_zip_output_stream.rb +60 -0
  78. data/lib/axlsx/util/constants.rb +117 -104
  79. data/lib/axlsx/util/mime_type_utils.rb +3 -5
  80. data/lib/axlsx/util/options_parser.rb +3 -1
  81. data/lib/axlsx/util/serialized_attributes.rb +42 -17
  82. data/lib/axlsx/util/simple_typed_list.rb +47 -47
  83. data/lib/axlsx/util/storage.rb +11 -10
  84. data/lib/axlsx/util/validators.rb +101 -41
  85. data/lib/axlsx/util/zip_command.rb +10 -10
  86. data/lib/axlsx/version.rb +3 -1
  87. data/lib/axlsx/workbook/defined_name.rb +6 -4
  88. data/lib/axlsx/workbook/defined_names.rb +4 -2
  89. data/lib/axlsx/workbook/shared_strings_table.rb +8 -6
  90. data/lib/axlsx/workbook/workbook.rb +94 -79
  91. data/lib/axlsx/workbook/workbook_view.rb +3 -1
  92. data/lib/axlsx/workbook/workbook_views.rb +4 -2
  93. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +65 -8
  94. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +11 -5
  95. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +11 -7
  96. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +51 -0
  97. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +56 -0
  98. data/lib/axlsx/workbook/worksheet/border_creator.rb +5 -3
  99. data/lib/axlsx/workbook/worksheet/break.rb +3 -1
  100. data/lib/axlsx/workbook/worksheet/cell.rb +83 -64
  101. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +31 -27
  102. data/lib/axlsx/workbook/worksheet/cfvo.rb +11 -3
  103. data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -1
  104. data/lib/axlsx/workbook/worksheet/col.rb +5 -3
  105. data/lib/axlsx/workbook/worksheet/col_breaks.rb +6 -4
  106. data/lib/axlsx/workbook/worksheet/color_scale.rb +12 -10
  107. data/lib/axlsx/workbook/worksheet/cols.rb +4 -2
  108. data/lib/axlsx/workbook/worksheet/comment.rb +8 -6
  109. data/lib/axlsx/workbook/worksheet/comments.rb +6 -4
  110. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +16 -5
  111. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +73 -16
  112. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +4 -2
  113. data/lib/axlsx/workbook/worksheet/data_bar.rb +14 -13
  114. data/lib/axlsx/workbook/worksheet/data_validation.rb +69 -28
  115. data/lib/axlsx/workbook/worksheet/data_validations.rb +4 -2
  116. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +7 -5
  117. data/lib/axlsx/workbook/worksheet/dimension.rb +4 -2
  118. data/lib/axlsx/workbook/worksheet/header_footer.rb +4 -2
  119. data/lib/axlsx/workbook/worksheet/icon_set.rb +38 -9
  120. data/lib/axlsx/workbook/worksheet/merged_cells.rb +6 -6
  121. data/lib/axlsx/workbook/worksheet/outline_pr.rb +6 -2
  122. data/lib/axlsx/workbook/worksheet/page_margins.rb +39 -11
  123. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +7 -4
  124. data/lib/axlsx/workbook/worksheet/page_setup.rb +34 -9
  125. data/lib/axlsx/workbook/worksheet/pane.rb +17 -9
  126. data/lib/axlsx/workbook/worksheet/pivot_table.rb +20 -19
  127. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +8 -6
  128. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +3 -1
  129. data/lib/axlsx/workbook/worksheet/print_options.rb +3 -1
  130. data/lib/axlsx/workbook/worksheet/protected_range.rb +3 -1
  131. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +6 -4
  132. data/lib/axlsx/workbook/worksheet/rich_text.rb +3 -1
  133. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +46 -24
  134. data/lib/axlsx/workbook/worksheet/row.rb +11 -9
  135. data/lib/axlsx/workbook/worksheet/row_breaks.rb +7 -5
  136. data/lib/axlsx/workbook/worksheet/selection.rb +15 -7
  137. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +6 -2
  138. data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
  139. data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +6 -2
  140. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +8 -4
  141. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +11 -9
  142. data/lib/axlsx/workbook/worksheet/sheet_view.rb +38 -15
  143. data/lib/axlsx/workbook/worksheet/table.rb +9 -7
  144. data/lib/axlsx/workbook/worksheet/table_style_info.rb +4 -2
  145. data/lib/axlsx/workbook/worksheet/tables.rb +4 -2
  146. data/lib/axlsx/workbook/worksheet/worksheet.rb +56 -39
  147. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +4 -2
  148. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +8 -2
  149. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +7 -5
  150. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +5 -3
  151. data/lib/axlsx.rb +56 -42
  152. data/lib/caxlsx.rb +3 -1
  153. metadata +39 -71
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # A relationship defines a reference between package parts.
3
5
  # @note Packages automatically manage relationships.
@@ -41,7 +43,7 @@ module Axlsx
41
43
  end
42
44
 
43
45
  # The id of the relationship (eg. "rId123"). Most instances get their own unique id.
44
- # However, some instances need to share the same id – see {#should_use_same_id_as?}
46
+ # However, some instances need to share the same id – see {#ids_cache_key}
45
47
  # for details.
46
48
  # @return [String]
47
49
  attr_reader :Id
@@ -90,20 +92,33 @@ module Axlsx
90
92
  end
91
93
 
92
94
  # @see Target
93
- def Target=(v) Axlsx::validate_string v; @Target = v end
95
+ def Target=(v)
96
+ Axlsx.validate_string v
97
+ @Target = v
98
+ end
99
+
94
100
  # @see Type
95
- def Type=(v) Axlsx::validate_relationship_type v; @Type = v end
101
+ def Type=(v)
102
+ Axlsx.validate_relationship_type v
103
+ @Type = v
104
+ end
96
105
 
97
106
  # @see TargetMode
98
- def TargetMode=(v) RestrictionValidator.validate 'Relationship.TargetMode', [:External, :Internal], v; @TargetMode = v; end
107
+ def TargetMode=(v)
108
+ RestrictionValidator.validate 'Relationship.TargetMode', [:External, :Internal], v
109
+ @TargetMode = v
110
+ end
99
111
 
100
112
  # serialize relationship
101
113
  # @param [String] str
102
114
  # @return [String]
103
- def to_xml_string(str = '')
115
+ def to_xml_string(str = +'')
104
116
  h = Axlsx.instance_values_for(self).reject { |k, _| k == "source_obj" }
105
117
  str << '<Relationship '
106
- str << (h.map { |key, value| '' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"' }.join(' '))
118
+ h.each_with_index do |key_value, index|
119
+ str << ' ' unless index.zero?
120
+ str << key_value.first.to_s << '="' << Axlsx.coder.encode(key_value.last.to_s) << '"'
121
+ end
107
122
  str << '/>'
108
123
  end
109
124
 
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
- require 'axlsx/rels/relationship.rb'
4
+ require 'axlsx/rels/relationship'
3
5
 
4
6
  # Relationships are a collection of Relations that define how package parts are related.
5
7
  # @note The package automatically manages releationships.
6
8
  class Relationships < SimpleTypedList
7
9
  # Creates a new Relationships collection based on SimpleTypedList
8
10
  def initialize
9
- super Relationship
11
+ super(Relationship)
10
12
  end
11
13
 
12
14
  # The relationship instance for the given source object, or nil if none exists.
@@ -19,9 +21,9 @@ module Axlsx
19
21
  # serialize relationships
20
22
  # @param [String] str
21
23
  # @return [String]
22
- def to_xml_string(str = '')
24
+ def to_xml_string(str = +'')
23
25
  str << '<?xml version="1.0" encoding="UTF-8"?>'
24
- str << ('<Relationships xmlns="' << RELS_R << '">')
26
+ str << '<Relationships xmlns="' << RELS_R << '">'
25
27
  each { |rel| rel.to_xml_string(str) }
26
28
  str << '</Relationships>'
27
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # This class details a border used in Office Open XML spreadsheet styles.
3
5
  class Border
@@ -41,20 +43,29 @@ module Axlsx
41
43
  attr_reader :prs
42
44
 
43
45
  # @see diagonalUp
44
- 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
45
50
  alias :diagonalUp= :diagonal_up=
46
51
 
47
52
  # @see diagonalDown
48
- 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
49
57
  alias :diagonalDown= :diagonal_down=
50
58
 
51
59
  # @see outline
52
- def outline=(v) Axlsx::validate_boolean v; @outline = v end
60
+ def outline=(v)
61
+ Axlsx.validate_boolean v
62
+ @outline = v
63
+ end
53
64
 
54
65
  # Serializes the object
55
66
  # @param [String] str
56
67
  # @return [String]
57
- def to_xml_string(str = '')
68
+ def to_xml_string(str = +'')
58
69
  str << '<border '
59
70
  serialized_attributes str
60
71
  str << '>'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # A border part.
3
5
  class BorderPr
@@ -51,19 +53,30 @@ module Axlsx
51
53
  end
52
54
 
53
55
  # @see name
54
- def name=(v) RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v; @name = v end
56
+ def name=(v)
57
+ RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v
58
+ @name = v
59
+ end
60
+
55
61
  # @see color
56
- def color=(v) DataTypeValidator.validate(:color, Color, v); @color = v end
62
+ def color=(v)
63
+ DataTypeValidator.validate(:color, Color, v)
64
+ @color = v
65
+ end
66
+
57
67
  # @see style
58
- 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
68
+ def style=(v)
69
+ RestrictionValidator.validate "BorderPr.style", [:none, :thin, :medium, :dashed, :dotted, :thick, :double, :hair, :mediumDashed, :dashDot, :mediumDashDot, :dashDotDot, :mediumDashDotDot, :slantDashDot], v
70
+ @style = v
71
+ end
59
72
 
60
73
  # Serializes the object
61
74
  # @param [String] str
62
75
  # @return [String]
63
- def to_xml_string(str = '')
64
- str << ('<' << @name.to_s << ' style="' << @style.to_s << '">')
76
+ def to_xml_string(str = +'')
77
+ str << '<' << @name.to_s << ' style="' << @style.to_s << '">'
65
78
  @color.to_xml_string(str) if @color.is_a?(Color)
66
- str << ('</' << @name.to_s << '>')
79
+ str << '</' << @name.to_s << '>'
67
80
  end
68
81
  end
69
82
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # CellAlignment stores information about the cell alignment of a style Xf Object.
3
5
  # @note Using Styles#add_style is the recommended way to manage cell alignment.
@@ -84,40 +86,69 @@ module Axlsx
84
86
  alias :readingOrder :reading_order
85
87
 
86
88
  # @see horizontal
87
- 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
+
88
94
  # @see vertical
89
- 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
+
90
100
  # @see textRotation
91
- 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
92
105
  alias :textRotation= :text_rotation=
93
106
 
94
107
  # @see wrapText
95
- 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
96
112
  alias :wrapText= :wrap_text=
97
113
 
98
114
  # @see indent
99
- 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
100
119
 
101
120
  # @see relativeIndent
102
- 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
103
125
  alias :relativeIndent= :relative_indent=
104
126
 
105
127
  # @see justifyLastLine
106
- 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
107
132
  alias :justifyLastLine= :justify_last_line=
108
133
 
109
134
  # @see shrinkToFit
110
- 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
111
139
  alias :shrinkToFit= :shrink_to_fit=
112
140
 
113
141
  # @see readingOrder
114
- 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
115
146
  alias :readingOrder= :reading_order=
116
147
 
117
148
  # Serializes the object
118
149
  # @param [String] str
119
150
  # @return [String]
120
- def to_xml_string(str = '')
151
+ def to_xml_string(str = +'')
121
152
  serialized_tag('alignment', str)
122
153
  end
123
154
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # CellProtection stores information about locking or hiding cells in spreadsheet.
3
5
  # @note Using Styles#add_style is the recommended way to manage cell protection.
@@ -24,14 +26,21 @@ module Axlsx
24
26
  end
25
27
 
26
28
  # @see hidden
27
- 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
+
28
34
  # @see locked
29
- def locked=(v) Axlsx::validate_boolean v; @locked = v end
35
+ def locked=(v)
36
+ Axlsx.validate_boolean v
37
+ @locked = v
38
+ end
30
39
 
31
40
  # Serializes the object
32
41
  # @param [String] str
33
42
  # @return [String]
34
- def to_xml_string(str = '')
43
+ def to_xml_string(str = +'')
35
44
  serialized_tag('protection', str)
36
45
  end
37
46
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # CellStyle defines named styles that reference defined formatting records and can be used in your worksheet.
3
5
  # @note Using Styles#add_style is the recommended way to manage cell styling.
@@ -37,7 +39,7 @@ module Axlsx
37
39
  # @return [Integer]
38
40
  attr_reader :iLevel
39
41
 
40
- # 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
41
43
  # @return [Boolean]
42
44
  attr_reader :hidden
43
45
 
@@ -46,22 +48,45 @@ module Axlsx
46
48
  attr_reader :customBuiltin
47
49
 
48
50
  # @see name
49
- def name=(v) Axlsx::validate_string v; @name = v end
51
+ def name=(v)
52
+ Axlsx.validate_string v
53
+ @name = v
54
+ end
55
+
50
56
  # @see xfId
51
- 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
+
52
62
  # @see builtinId
53
- 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
+
54
68
  # @see iLivel
55
- 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
+
56
74
  # @see hidden
57
- 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
+
58
80
  # @see customBuiltin
59
- def customBuiltin=(v) Axlsx::validate_boolean v; @customBuiltin = v end
81
+ def customBuiltin=(v)
82
+ Axlsx.validate_boolean v
83
+ @customBuiltin = v
84
+ end
60
85
 
61
86
  # Serializes the object
62
87
  # @param [String] str
63
88
  # @return [String]
64
- def to_xml_string(str = '')
89
+ def to_xml_string(str = +'')
65
90
  serialized_tag('cellStyle', str)
66
91
  end
67
92
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The color class represents a color used for borders, fills an fonts
3
5
  class Color
@@ -45,21 +47,27 @@ module Axlsx
45
47
  attr_reader :tint
46
48
 
47
49
  # @see auto
48
- def auto=(v) Axlsx::validate_boolean v; @auto = v end
50
+ def auto=(v)
51
+ Axlsx.validate_boolean v
52
+ @auto = v
53
+ end
49
54
 
50
55
  # @see color
51
56
  def rgb=(v)
52
- Axlsx::validate_string(v)
57
+ Axlsx.validate_string(v)
53
58
  v = v.upcase
54
- v = v * 3 if v.size == 2
59
+ v *= 3 if v.size == 2
55
60
  v = v.rjust(8, 'FF')
56
- 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)
57
62
 
58
63
  @rgb = v
59
64
  end
60
65
 
61
66
  # @see tint
62
- def tint=(v) Axlsx::validate_float v; @tint = v end
67
+ def tint=(v)
68
+ Axlsx.validate_float v
69
+ @tint = v
70
+ end
63
71
 
64
72
  # This version does not support themes
65
73
  # def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
@@ -70,8 +78,8 @@ module Axlsx
70
78
  # Serializes the object
71
79
  # @param [String] str
72
80
  # @return [String]
73
- def to_xml_string(str = '', tag_name = 'color')
74
- serialized_tag('' + tag_name + '', str)
81
+ def to_xml_string(str = +'', tag_name = 'color')
82
+ serialized_tag(tag_name.to_s, str)
75
83
  end
76
84
  end
77
85
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
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
3
5
  # @see Styles#add_style
@@ -6,7 +8,7 @@ module Axlsx
6
8
 
7
9
  # The order in which the child elements is put in the XML seems to
8
10
  # be important for Excel
9
- CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection]
11
+ CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection].freeze
10
12
  # does not support extList (ExtensionList)
11
13
 
12
14
  # The cell alignment for this style
@@ -47,27 +49,50 @@ module Axlsx
47
49
  end
48
50
 
49
51
  # @see Dxf#alignment
50
- 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
+
51
57
  # @see protection
52
- 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
+
53
63
  # @see numFmt
54
- 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
+
55
69
  # @see font
56
- 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
+
57
75
  # @see border
58
- 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
+
59
81
  # @see fill
60
- 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
61
86
 
62
87
  # Serializes the object
63
88
  # @param [String] str
64
89
  # @return [String]
65
- def to_xml_string(str = '')
90
+ def to_xml_string(str = +'')
66
91
  str << '<dxf>'
67
92
  # Dxf elements have no attributes. All of the instance variables
68
93
  # are child elements.
69
94
  CHILD_ELEMENTS.each do |element|
70
- self.send(element).to_xml_string(str) if self.send(element)
95
+ send(element).to_xml_string(str) if send(element)
71
96
  end
72
97
  str << '</dxf>'
73
98
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The Fill is a formatting object that manages the background color, and pattern for cells.
3
5
  # @note The recommended way to manage styles in your workbook is to use Styles#add_style.
@@ -19,13 +21,16 @@ module Axlsx
19
21
  # Serializes the object
20
22
  # @param [String] str
21
23
  # @return [String]
22
- def to_xml_string(str = '')
24
+ def to_xml_string(str = +'')
23
25
  str << '<fill>'
24
26
  @fill_type.to_xml_string(str)
25
27
  str << '</fill>'
26
28
  end
27
29
 
28
30
  # @see fill_type
29
- def fill_type=(v) DataTypeValidator.validate "Fill.fill_type", [PatternFill, GradientFill], v; @fill_type = v; end
31
+ def fill_type=(v)
32
+ DataTypeValidator.validate "Fill.fill_type", [PatternFill, GradientFill], v
33
+ @fill_type = v
34
+ end
30
35
  end
31
36
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The Font class details a font instance for use in styling cells.
3
5
  # @note The recommended way to manage fonts, and other styles is Styles#add_style
@@ -110,46 +112,92 @@ module Axlsx
110
112
  attr_reader :sz
111
113
 
112
114
  # @see name
113
- def name=(v) Axlsx::validate_string v; @name = v end
115
+ def name=(v)
116
+ Axlsx.validate_string v
117
+ @name = v
118
+ end
119
+
114
120
  # @see charset
115
- def charset=(v) Axlsx::validate_unsigned_int v; @charset = v end
121
+ def charset=(v)
122
+ Axlsx.validate_unsigned_int v
123
+ @charset = v
124
+ end
125
+
116
126
  # @see family
117
- def family=(v) Axlsx::validate_unsigned_int v; @family = v end
127
+ def family=(v)
128
+ Axlsx.validate_unsigned_int v
129
+ @family = v
130
+ end
131
+
118
132
  # @see b
119
- def b=(v) Axlsx::validate_boolean v; @b = v end
133
+ def b=(v)
134
+ Axlsx.validate_boolean v
135
+ @b = v
136
+ end
137
+
120
138
  # @see i
121
- def i=(v) Axlsx::validate_boolean v; @i = v end
139
+ def i=(v)
140
+ Axlsx.validate_boolean v
141
+ @i = v
142
+ end
122
143
 
123
144
  # @see u
124
145
  def u=(v)
125
- v = :single if (v == true || v == 1 || v == :true || v == 'true')
126
- v = :none if (v == false || v == 0 || v == :false || v == 'false')
127
- Axlsx::validate_cell_u v
146
+ v = :single if v == true || v == 1 || v == :true || v == 'true'
147
+ v = :none if v == false || v == 0 || v == :false || v == 'false'
148
+ Axlsx.validate_cell_u v
128
149
  @u = v
129
150
  end
130
151
 
131
152
  # @see strike
132
- def strike=(v) Axlsx::validate_boolean v; @strike = v end
153
+ def strike=(v)
154
+ Axlsx.validate_boolean v
155
+ @strike = v
156
+ end
157
+
133
158
  # @see outline
134
- def outline=(v) Axlsx::validate_boolean v; @outline = v end
159
+ def outline=(v)
160
+ Axlsx.validate_boolean v
161
+ @outline = v
162
+ end
163
+
135
164
  # @see shadow
136
- def shadow=(v) Axlsx::validate_boolean v; @shadow = v end
165
+ def shadow=(v)
166
+ Axlsx.validate_boolean v
167
+ @shadow = v
168
+ end
169
+
137
170
  # @see condense
138
- def condense=(v) Axlsx::validate_boolean v; @condense = v end
171
+ def condense=(v)
172
+ Axlsx.validate_boolean v
173
+ @condense = v
174
+ end
175
+
139
176
  # @see extend
140
- def extend=(v) Axlsx::validate_boolean v; @extend = v end
177
+ def extend=(v)
178
+ Axlsx.validate_boolean v
179
+ @extend = v
180
+ end
181
+
141
182
  # @see color
142
- def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color = v end
183
+ def color=(v)
184
+ DataTypeValidator.validate "Font.color", Color, v
185
+ @color = v
186
+ end
187
+
143
188
  # @see sz
144
- def sz=(v) Axlsx::validate_unsigned_int v; @sz = v end
189
+ def sz=(v)
190
+ Axlsx.validate_unsigned_int v
191
+ @sz = v
192
+ end
145
193
 
146
194
  # Serializes the object
147
195
  # @param [String] str
148
196
  # @return [String]
149
- def to_xml_string(str = '')
197
+ def to_xml_string(str = +'')
150
198
  str << '<font>'
151
199
  Axlsx.instance_values_for(self).each do |k, v|
152
- v.is_a?(Color) ? v.to_xml_string(str) : (str << ('<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>'))
200
+ v.is_a?(Color) ? v.to_xml_string(str) : (str << '<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>')
153
201
  end
154
202
  str << '</font>'
155
203
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # A GradientFill defines the color and positioning for gradiant cell fill.
3
5
  # @see Open Office XML Part 1 §18.8.24
@@ -53,10 +55,16 @@ module Axlsx
53
55
  attr_reader :stop
54
56
 
55
57
  # @see type
56
- def type=(v) Axlsx::validate_gradient_type v; @type = v end
58
+ def type=(v)
59
+ Axlsx.validate_gradient_type v
60
+ @type = v
61
+ end
57
62
 
58
63
  # @see degree
59
- def degree=(v) Axlsx::validate_float v; @degree = v end
64
+ def degree=(v)
65
+ Axlsx.validate_float v
66
+ @degree = v
67
+ end
60
68
 
61
69
  # @see left
62
70
  def left=(v)
@@ -84,13 +92,13 @@ module Axlsx
84
92
 
85
93
  # validates that the value provided is between 0.0 and 1.0
86
94
  def validate_format_percentage(name, value)
87
- DataTypeValidator.validate name, Float, value, lambda { |arg| arg >= 0.0 && arg <= 1.0 }
95
+ DataTypeValidator.validate name, Float, value, ->(arg) { arg >= 0.0 && arg <= 1.0 }
88
96
  end
89
97
 
90
98
  # Serializes the object
91
99
  # @param [String] str
92
100
  # @return [String]
93
- def to_xml_string(str = '')
101
+ def to_xml_string(str = +'')
94
102
  str << '<gradientFill '
95
103
  serialized_attributes str
96
104
  str << '>'