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
  # There are more elements in the dLbls spec that allow for
3
5
  # customizations and formatting. For now, I am just implementing the
@@ -36,7 +38,7 @@ module Axlsx
36
38
  [:show_legend_key, :show_val, :show_cat_name,
37
39
  :show_ser_name, :show_percent, :show_bubble_size,
38
40
  :show_leader_lines].each do |attr|
39
- self.send("#{attr}=", false)
41
+ send(:"#{attr}=", false)
40
42
  end
41
43
  end
42
44
 
@@ -49,7 +51,7 @@ module Axlsx
49
51
  # @see d_lbl_pos= for a list of allowed values
50
52
  # @return [Symbol]
51
53
  def d_lbl_pos
52
- return unless [Pie3DChart, LineChart].include? @chart_type
54
+ return unless [PieChart, Pie3DChart, LineChart].include? @chart_type
53
55
 
54
56
  @d_lbl_pos ||= :bestFit
55
57
  end
@@ -61,7 +63,7 @@ module Axlsx
61
63
  # The default is :bestFit
62
64
  # @param [Symbol] label_position the postion you want to use.
63
65
  def d_lbl_pos=(label_position)
64
- return unless [Pie3DChart, LineChart].include? @chart_type
66
+ return unless [PieChart, Pie3DChart, LineChart].include? @chart_type
65
67
 
66
68
  Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position
67
69
  @d_lbl_pos = label_position
@@ -69,21 +71,21 @@ module Axlsx
69
71
 
70
72
  # serializes the data labels
71
73
  # @return [String]
72
- def to_xml_string(str = '')
74
+ def to_xml_string(str = +'')
73
75
  validate_attributes_for_chart_type
74
76
  str << '<c:dLbls>'
75
77
  instance_vals = Axlsx.instance_values_for(self)
76
78
  %w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
77
- next unless instance_vals.keys.include?(key) && instance_vals[key] != nil
79
+ next unless instance_vals.key?(key) && !instance_vals[key].nil?
78
80
 
79
- str << "<c:#{Axlsx::camel(key, false)} val='#{instance_vals[key]}' />"
81
+ str << "<c:#{Axlsx.camel(key, false)} val='#{instance_vals[key]}' />"
80
82
  end
81
83
  str << '</c:dLbls>'
82
84
  end
83
85
 
84
- # nills out d_lbl_pos and show_leader_lines as these attributes, while valid in the spec actually chrash excel for any chart type other than pie charts.
86
+ # nills out d_lbl_pos and show_leader_lines as these attributes, while valid in the spec actually crash Excel for any chart type other than pie charts.
85
87
  def validate_attributes_for_chart_type
86
- return if [Pie3DChart, LineChart].include? @chart_type
88
+ return if [PieChart, Pie3DChart, LineChart].include? @chart_type
87
89
 
88
90
  @d_lbl_pos = nil
89
91
  @show_leader_lines = nil
@@ -1,53 +1,56 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
- require 'axlsx/drawing/d_lbls.rb'
3
- require 'axlsx/drawing/title.rb'
4
- require 'axlsx/drawing/series_title.rb'
5
- require 'axlsx/drawing/series.rb'
6
- require 'axlsx/drawing/pie_series.rb'
7
- require 'axlsx/drawing/bar_series.rb'
8
- require 'axlsx/drawing/line_series.rb'
9
- require 'axlsx/drawing/scatter_series.rb'
10
- require 'axlsx/drawing/bubble_series.rb'
11
- require 'axlsx/drawing/area_series.rb'
12
-
13
- require 'axlsx/drawing/scaling.rb'
14
- require 'axlsx/drawing/axis.rb'
15
-
16
- require 'axlsx/drawing/str_val.rb'
17
- require 'axlsx/drawing/num_val.rb'
18
- require 'axlsx/drawing/str_data.rb'
19
- require 'axlsx/drawing/num_data.rb'
20
- require 'axlsx/drawing/num_data_source.rb'
21
- require 'axlsx/drawing/ax_data_source.rb'
22
-
23
- require 'axlsx/drawing/ser_axis.rb'
24
- require 'axlsx/drawing/cat_axis.rb'
25
- require 'axlsx/drawing/val_axis.rb'
26
- require 'axlsx/drawing/axes.rb'
27
-
28
- require 'axlsx/drawing/marker.rb'
29
-
30
- require 'axlsx/drawing/one_cell_anchor.rb'
31
- require 'axlsx/drawing/two_cell_anchor.rb'
32
- require 'axlsx/drawing/graphic_frame.rb'
33
-
34
- require 'axlsx/drawing/view_3D.rb'
35
- require 'axlsx/drawing/chart.rb'
36
- require 'axlsx/drawing/pie_3D_chart.rb'
37
- require 'axlsx/drawing/bar_3D_chart.rb'
38
- require 'axlsx/drawing/bar_chart.rb'
39
- require 'axlsx/drawing/line_chart.rb'
40
- require 'axlsx/drawing/line_3D_chart.rb'
41
- require 'axlsx/drawing/scatter_chart.rb'
42
- require 'axlsx/drawing/bubble_chart.rb'
43
- require 'axlsx/drawing/area_chart.rb'
44
-
45
- require 'axlsx/drawing/picture_locking.rb'
46
- require 'axlsx/drawing/pic.rb'
47
- require 'axlsx/drawing/hyperlink.rb'
48
-
49
- require 'axlsx/drawing/vml_drawing.rb'
50
- require 'axlsx/drawing/vml_shape.rb'
4
+ require 'axlsx/drawing/d_lbls'
5
+ require 'axlsx/drawing/title'
6
+ require 'axlsx/drawing/series_title'
7
+ require 'axlsx/drawing/series'
8
+ require 'axlsx/drawing/pie_series'
9
+ require 'axlsx/drawing/bar_series'
10
+ require 'axlsx/drawing/line_series'
11
+ require 'axlsx/drawing/scatter_series'
12
+ require 'axlsx/drawing/bubble_series'
13
+ require 'axlsx/drawing/area_series'
14
+
15
+ require 'axlsx/drawing/scaling'
16
+ require 'axlsx/drawing/axis'
17
+
18
+ require 'axlsx/drawing/str_val'
19
+ require 'axlsx/drawing/num_val'
20
+ require 'axlsx/drawing/str_data'
21
+ require 'axlsx/drawing/num_data'
22
+ require 'axlsx/drawing/num_data_source'
23
+ require 'axlsx/drawing/ax_data_source'
24
+
25
+ require 'axlsx/drawing/ser_axis'
26
+ require 'axlsx/drawing/cat_axis'
27
+ require 'axlsx/drawing/val_axis'
28
+ require 'axlsx/drawing/axes'
29
+
30
+ require 'axlsx/drawing/marker'
31
+
32
+ require 'axlsx/drawing/one_cell_anchor'
33
+ require 'axlsx/drawing/two_cell_anchor'
34
+ require 'axlsx/drawing/graphic_frame'
35
+
36
+ require 'axlsx/drawing/view_3D'
37
+ require 'axlsx/drawing/chart'
38
+ require 'axlsx/drawing/pie_3D_chart'
39
+ require 'axlsx/drawing/pie_chart'
40
+ require 'axlsx/drawing/bar_3D_chart'
41
+ require 'axlsx/drawing/bar_chart'
42
+ require 'axlsx/drawing/line_chart'
43
+ require 'axlsx/drawing/line_3D_chart'
44
+ require 'axlsx/drawing/scatter_chart'
45
+ require 'axlsx/drawing/bubble_chart'
46
+ require 'axlsx/drawing/area_chart'
47
+
48
+ require 'axlsx/drawing/picture_locking'
49
+ require 'axlsx/drawing/pic'
50
+ require 'axlsx/drawing/hyperlink'
51
+
52
+ require 'axlsx/drawing/vml_drawing'
53
+ require 'axlsx/drawing/vml_shape'
51
54
 
52
55
  # A Drawing is a canvas for charts and images. Each worksheet has a single drawing that manages anchors.
53
56
  # The anchors reference the charts or images via graphical frames. This is not a trivial relationship so please do follow the advice in the note.
@@ -106,15 +109,15 @@ module Axlsx
106
109
  # An array of hyperlink objects associated with this drawings images
107
110
  # @return [Array]
108
111
  def hyperlinks
109
- links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) }
110
- links.map { |a| a.hyperlink }
112
+ links = images.select { |a| a.hyperlink.is_a?(Hyperlink) }
113
+ links.map(&:hyperlink)
111
114
  end
112
115
 
113
116
  # An array of image objects that are associated with this drawing's anchors
114
117
  # @return [Array]
115
118
  def images
116
119
  images = @anchors.select { |a| a.object.is_a?(Pic) }
117
- images.map { |a| a.object }
120
+ images.map(&:object)
118
121
  end
119
122
 
120
123
  # The index of this drawing in the owning workbooks's drawings collection.
@@ -126,14 +129,14 @@ module Axlsx
126
129
  # The part name for this drawing
127
130
  # @return [String]
128
131
  def pn
129
- "#{DRAWING_PN % (index + 1)}"
132
+ format(DRAWING_PN, index + 1)
130
133
  end
131
134
 
132
135
  # The relational part name for this drawing
133
136
  # #NOTE This should be rewritten to return an Axlsx::Relationship object.
134
137
  # @return [String]
135
138
  def rels_pn
136
- "#{DRAWING_RELS_PN % (index + 1)}"
139
+ format(DRAWING_RELS_PN, index + 1)
137
140
  end
138
141
 
139
142
  # A list of objects this drawing holds.
@@ -153,9 +156,9 @@ module Axlsx
153
156
  # Serializes the object
154
157
  # @param [String] str
155
158
  # @return [String]
156
- def to_xml_string(str = '')
159
+ def to_xml_string(str = +'')
157
160
  str << '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
158
- str << ('<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">')
161
+ str << '<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">'
159
162
  anchors.each { |anchor| anchor.to_xml_string(str) }
160
163
  str << '</xdr:wsDr>'
161
164
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # A graphic frame defines a container for a chart object
3
5
  # @note The recommended way to manage charts is Worksheet#add_chart
@@ -29,11 +31,11 @@ module Axlsx
29
31
  # Serializes the object
30
32
  # @param [String] str
31
33
  # @return [String]
32
- def to_xml_string(str = '')
34
+ def to_xml_string(str = +'')
33
35
  # macro attribute should be optional!
34
36
  str << '<xdr:graphicFrame>'
35
37
  str << '<xdr:nvGraphicFramePr>'
36
- str << ('<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>')
38
+ str << '<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>'
37
39
  str << '<xdr:cNvGraphicFramePr/>'
38
40
  str << '</xdr:nvGraphicFramePr>'
39
41
  str << '<xdr:xfrm>'
@@ -41,8 +43,8 @@ module Axlsx
41
43
  str << '<a:ext cx="0" cy="0"/>'
42
44
  str << '</xdr:xfrm>'
43
45
  str << '<a:graphic>'
44
- str << ('<a:graphicData uri="' << XML_NS_C << '">')
45
- str << ('<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="' << rId << '"/>')
46
+ str << '<a:graphicData uri="' << XML_NS_C << '">'
47
+ str << '<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="' << rId << '"/>'
46
48
  str << '</a:graphicData>'
47
49
  str << '</a:graphic>'
48
50
  str << '</xdr:graphicFrame>'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # a hyperlink object adds an action to an image when clicked so that when the image is clicked the link is fecthed.
3
5
  # @note using the hyperlink option when calling add_image on a drawing object is the recommended way to manage hyperlinks
@@ -13,7 +15,7 @@ module Axlsx
13
15
  # @option options [String] tgtFrame Target frame for opening hyperlink
14
16
  # @option options [String] invalidUrl supposedly use to store the href when we know it is an invalid resource.
15
17
  # @option options [String] href the target resource this hyperlink links to. This is actually stored on the relationship.
16
- # @option options [String] action A string that can be used to perform specific actions. For excel please see this reference: http://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
18
+ # @option options [String] action A string that can be used to perform specific actions. For Excel please see this reference: https://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
17
19
  # @option options [Boolean] endSnd terminate any sound events when processing this link
18
20
  # @option options [Boolean] history include this link in the list of visited links for the applications history.
19
21
  # @option options [Boolean] highlightClick indicate that the link has already been visited.
@@ -38,7 +40,7 @@ module Axlsx
38
40
  alias :invalidUrl :invalid_url
39
41
  alias :invalidUrl= :invalid_url=
40
42
 
41
- # An action to take when the link is clicked. The specification says "This can be used to specify a slide to be navigated to or a script of code to be run." but in most cases you will not need to do anything with this. MS does reserve a few interesting strings. @see http://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
43
+ # An action to take when the link is clicked. The specification says "This can be used to specify a slide to be navigated to or a script of code to be run." but in most cases you will not need to do anything with this. MS does reserve a few interesting strings. @see https://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
42
44
  # @return [String]
43
45
  attr_accessor :action
44
46
 
@@ -50,7 +52,10 @@ module Axlsx
50
52
  # @see endSnd
51
53
  # @param [Boolean] v The boolean value indicating the termination of playing sounds on click
52
54
  # @return [Boolean]
53
- def end_snd=(v) Axlsx::validate_boolean(v); @end_snd = v end
55
+ def end_snd=(v)
56
+ Axlsx.validate_boolean(v)
57
+ @end_snd = v
58
+ end
54
59
  alias :endSnd= :end_snd=
55
60
 
56
61
  # indicates that the link has already been clicked.
@@ -60,7 +65,10 @@ module Axlsx
60
65
 
61
66
  # @see highlightClick
62
67
  # @param [Boolean] v The value to assign
63
- def highlight_click=(v) Axlsx::validate_boolean(v); @highlight_click = v end
68
+ def highlight_click=(v)
69
+ Axlsx.validate_boolean(v)
70
+ @highlight_click = v
71
+ end
64
72
  alias :highlightClick= :highlight_click=
65
73
 
66
74
  # From the specs: Specifies whether to add this URI to the history when navigating to it. This allows for the viewing of this presentation without the storing of history information on the viewing machine. If this attribute is omitted, then a value of 1 or true is assumed.
@@ -69,7 +77,10 @@ module Axlsx
69
77
 
70
78
  # @see history
71
79
  # param [Boolean] v The value to assing
72
- def history=(v) Axlsx::validate_boolean(v); @history = v end
80
+ def history=(v)
81
+ Axlsx.validate_boolean(v)
82
+ @history = v
83
+ end
73
84
 
74
85
  # From the specs: Specifies the target frame that is to be used when opening this hyperlink. When the hyperlink is activated this attribute is used to determine if a new window is launched for viewing or if an existing one can be used. If this attribute is omitted, than a new window is opened.
75
86
  # @return [String]
@@ -84,14 +95,14 @@ module Axlsx
84
95
  # The relationship object for this hyperlink.
85
96
  # @return [Relationship]
86
97
  def relationship
87
- Relationship.new(self, HYPERLINK_R, href, :target_mode => :External)
98
+ Relationship.new(self, HYPERLINK_R, href, target_mode: :External)
88
99
  end
89
100
 
90
101
  # Serializes the object
91
102
  # @param [String] str
92
103
  # @return [String]
93
- def to_xml_string(str = '')
94
- serialized_tag 'a:hlinkClick', str, { :'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R }
104
+ def to_xml_string(str = +'')
105
+ serialized_tag 'a:hlinkClick', str, { 'r:id': relationship.Id, 'xmlns:r': XML_NS_R }
95
106
  end
96
107
  end
97
108
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The Line3DChart is a three dimentional line chart (who would have guessed?) that you can add to your worksheet.
3
5
  # @example Creating a chart
@@ -24,7 +26,7 @@ module Axlsx
24
26
  alias :gapDepth :gap_depth
25
27
 
26
28
  # validation regex for gap amount percent
27
- GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
29
+ GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/.freeze
28
30
 
29
31
  # the category axis
30
32
  # @return [Axis]
@@ -40,7 +42,7 @@ module Axlsx
40
42
  # @see View3D
41
43
  def initialize(frame, options = {})
42
44
  @gap_depth = nil
43
- @view_3D = View3D.new({ :r_ang_ax => 1 }.merge(options))
45
+ @view_3D = View3D.new({ r_ang_ax: 1 }.merge(options))
44
46
  super(frame, options)
45
47
  axes.add_axis :ser_axis, SerAxis
46
48
  end
@@ -48,16 +50,16 @@ module Axlsx
48
50
  # @see gapDepth
49
51
  def gap_depth=(v)
50
52
  RegexValidator.validate "Line3DChart.gapWidth", GAP_AMOUNT_PERCENT, v
51
- @gap_depth = (v)
53
+ @gap_depth = v
52
54
  end
53
55
  alias :gapDepth= :gap_depth=
54
56
 
55
57
  # Serializes the object
56
58
  # @param [String] str
57
59
  # @return [String]
58
- def to_xml_string(str = '')
60
+ def to_xml_string(str = +'')
59
61
  super(str) do
60
- str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil?
62
+ str << '<c:gapDepth val="' << @gap_depth.to_s << '"/>' unless @gap_depth.nil?
61
63
  end
62
64
  end
63
65
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The LineChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet.
3
5
  # @example Creating a chart
@@ -61,7 +63,7 @@ module Axlsx
61
63
  # chart based on the actual class type and not a fixed node name.
62
64
  # @return [String]
63
65
  def node_name
64
- path = self.class.to_s
66
+ path = self.class.name
65
67
  if i = path.rindex('::')
66
68
  path = path[(i + 2)..-1]
67
69
  end
@@ -72,16 +74,16 @@ module Axlsx
72
74
  # Serializes the object
73
75
  # @param [String] str
74
76
  # @return [String]
75
- def to_xml_string(str = '')
77
+ def to_xml_string(str = +'')
76
78
  super(str) do
77
- str << ("<c:" << node_name << ">")
78
- str << ('<c:grouping val="' << grouping.to_s << '"/>')
79
- str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
79
+ str << "<c:" << node_name << ">"
80
+ str << '<c:grouping val="' << grouping.to_s << '"/>'
81
+ str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
80
82
  @series.each { |ser| ser.to_xml_string(str) }
81
83
  @d_lbls.to_xml_string(str) if @d_lbls
82
84
  yield if block_given?
83
- axes.to_xml_string(str, :ids => true)
84
- str << ("</c:" << node_name << ">")
85
+ axes.to_xml_string(str, ids: true)
86
+ str << "</c:" << node_name << ">"
85
87
  axes.to_xml_string(str)
86
88
  end
87
89
  end
@@ -90,7 +92,7 @@ module Axlsx
90
92
  # axis.
91
93
  # @return [Axes]
92
94
  def axes
93
- @axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)
95
+ @axes ||= Axes.new(cat_axis: CatAxis, val_axis: ValAxis)
94
96
  end
95
97
  end
96
98
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # A LineSeries defines the title, data and labels for line charts
3
5
  # @note The recommended way to manage series is to use Chart#add_series
@@ -35,11 +37,11 @@ module Axlsx
35
37
  # @param [Chart] chart
36
38
  def initialize(chart, options = {})
37
39
  @show_marker = false
38
- @marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
40
+ @marker_symbol = options[:marker_symbol] || :default
39
41
  @smooth = false
40
42
  @labels, @data = nil, nil
41
43
  super(chart, options)
42
- @labels = AxDataSource.new(:data => options[:labels]) unless options[:labels].nil?
44
+ @labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?
43
45
  @data = NumDataSource.new(options) unless options[:data].nil?
44
46
  end
45
47
 
@@ -50,34 +52,34 @@ module Axlsx
50
52
 
51
53
  # @see show_marker
52
54
  def show_marker=(v)
53
- Axlsx::validate_boolean(v)
55
+ Axlsx.validate_boolean(v)
54
56
  @show_marker = v
55
57
  end
56
58
 
57
59
  # @see marker_symbol
58
60
  def marker_symbol=(v)
59
- Axlsx::validate_marker_symbol(v)
61
+ Axlsx.validate_marker_symbol(v)
60
62
  @marker_symbol = v
61
63
  end
62
64
 
63
65
  # @see smooth
64
66
  def smooth=(v)
65
- Axlsx::validate_boolean(v)
67
+ Axlsx.validate_boolean(v)
66
68
  @smooth = v
67
69
  end
68
70
 
69
71
  # Serializes the object
70
72
  # @param [String] str
71
73
  # @return [String]
72
- def to_xml_string(str = '')
74
+ def to_xml_string(str = +'')
73
75
  super(str) do
74
76
  if color
75
77
  str << '<c:spPr><a:solidFill>'
76
- str << ('<a:srgbClr val="' << color << '"/>')
78
+ str << '<a:srgbClr val="' << color << '"/>'
77
79
  str << '</a:solidFill>'
78
80
  str << '<a:ln w="28800">'
79
81
  str << '<a:solidFill>'
80
- str << ('<a:srgbClr val="' << color << '"/>')
82
+ str << '<a:srgbClr val="' << color << '"/>'
81
83
  str << '</a:solidFill>'
82
84
  str << '</a:ln>'
83
85
  str << '<a:round/>'
@@ -87,21 +89,27 @@ module Axlsx
87
89
  if !@show_marker
88
90
  str << '<c:marker><c:symbol val="none"/></c:marker>'
89
91
  elsif @marker_symbol != :default
90
- str << '<c:marker><c:symbol val="' + @marker_symbol.to_s + '"/></c:marker>'
92
+ str << '<c:marker><c:symbol val="' << @marker_symbol.to_s << '"/></c:marker>'
91
93
  end
92
94
 
93
95
  @labels.to_xml_string(str) unless @labels.nil?
94
96
  @data.to_xml_string(str) unless @data.nil?
95
- str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>')
97
+ str << '<c:smooth val="' << (smooth ? '1' : '0') << '"/>'
96
98
  end
97
99
  end
98
100
 
99
101
  private
100
102
 
101
103
  # assigns the data for this series
102
- def data=(v) DataTypeValidator.validate "Series.data", [NumDataSource], v; @data = v; end
104
+ def data=(v)
105
+ DataTypeValidator.validate "Series.data", [NumDataSource], v
106
+ @data = v
107
+ end
103
108
 
104
109
  # assigns the labels for this series
105
- def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
110
+ def labels=(v)
111
+ DataTypeValidator.validate "Series.labels", [AxDataSource], v
112
+ @labels = v
113
+ end
106
114
  end
107
115
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The Marker class defines a point in the worksheet that drawing anchors attach to.
3
5
  # @note The recommended way to manage markers is Worksheet#add_chart Markers are created for a two cell anchor based on the :start and :end options.
@@ -32,13 +34,28 @@ module Axlsx
32
34
  attr_reader :rowOff
33
35
 
34
36
  # @see col
35
- def col=(v) Axlsx::validate_unsigned_int v; @col = v end
37
+ def col=(v)
38
+ Axlsx.validate_unsigned_int v
39
+ @col = v
40
+ end
41
+
36
42
  # @see colOff
37
- def colOff=(v) Axlsx::validate_int v; @colOff = v end
43
+ def colOff=(v)
44
+ Axlsx.validate_int v
45
+ @colOff = v
46
+ end
47
+
38
48
  # @see row
39
- def row=(v) Axlsx::validate_unsigned_int v; @row = v end
49
+ def row=(v)
50
+ Axlsx.validate_unsigned_int v
51
+ @row = v
52
+ end
53
+
40
54
  # @see rowOff
41
- def rowOff=(v) Axlsx::validate_int v; @rowOff = v end
55
+ def rowOff=(v)
56
+ Axlsx.validate_int v
57
+ @rowOff = v
58
+ end
42
59
 
43
60
  # shortcut to set the column, row position for this marker
44
61
  # @param col the column for the marker, a Cell object or a string reference like "B7"
@@ -54,9 +71,9 @@ module Axlsx
54
71
  # Serializes the object
55
72
  # @param [String] str
56
73
  # @return [String]
57
- def to_xml_string(str = '')
74
+ def to_xml_string(str = +'')
58
75
  [:col, :colOff, :row, :rowOff].each do |k|
59
- str << ('<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>')
76
+ str << '<xdr:' << k.to_s << '>' << send(k).to_s << '</xdr:' << k.to_s << '>'
60
77
  end
61
78
  end
62
79
 
@@ -66,7 +83,7 @@ module Axlsx
66
83
  # @see Chart#start_at
67
84
  def parse_coord_args(x, y = 0)
68
85
  if x.is_a?(String)
69
- x, y = *Axlsx::name_to_indices(x)
86
+ x, y = *Axlsx.name_to_indices(x)
70
87
  end
71
88
  if x.is_a?(Cell)
72
89
  x, y = *x.pos
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # This class specifies data for a particular data point. It is used for both numCache and numLit object
3
5
  class NumData
@@ -23,25 +25,25 @@ module Axlsx
23
25
  @tag_name = values.first.is_a?(Cell) ? :numCache : :numLit
24
26
  values.each do |value|
25
27
  value = value.is_formula? ? 0 : value.value if value.is_a?(Cell)
26
- @pt << NumVal.new(:v => value)
28
+ @pt << NumVal.new(v: value)
27
29
  end
28
30
  end
29
31
 
30
32
  # @see format_code
31
33
  def format_code=(v = 'General')
32
- Axlsx::validate_string(v)
34
+ Axlsx.validate_string(v)
33
35
  @format_code = v
34
36
  end
35
37
 
36
38
  # serialize the object
37
- def to_xml_string(str = "")
38
- str << ('<c:' << @tag_name.to_s << '>')
39
- str << ('<c:formatCode>' << format_code.to_s << '</c:formatCode>')
40
- str << ('<c:ptCount val="' << @pt.size.to_s << '"/>')
39
+ def to_xml_string(str = +'')
40
+ str << '<c:' << @tag_name.to_s << '>'
41
+ str << '<c:formatCode>' << format_code.to_s << '</c:formatCode>'
42
+ str << '<c:ptCount val="' << @pt.size.to_s << '"/>'
41
43
  @pt.each_with_index do |num_val, index|
42
44
  num_val.to_xml_string index, str
43
45
  end
44
- str << ('</c:' << @tag_name.to_s << '>')
46
+ str << '</c:' << @tag_name.to_s << '>'
45
47
  end
46
48
  end
47
49
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # A numeric data source for use by charts.
3
5
  class NumDataSource
@@ -15,7 +17,7 @@ module Axlsx
15
17
  @f = nil
16
18
  @data = @data_type.new(options)
17
19
  if options[:data] && options[:data].first.is_a?(Cell)
18
- @f = Axlsx::cell_range(options[:data])
20
+ @f = Axlsx.cell_range(options[:data])
19
21
  end
20
22
  parse_options options
21
23
  end
@@ -42,17 +44,17 @@ module Axlsx
42
44
 
43
45
  # serialize the object
44
46
  # @param [String] str
45
- def to_xml_string(str = "")
46
- str << ('<c:' << tag_name.to_s << '>')
47
+ def to_xml_string(str = +'')
48
+ str << '<c:' << tag_name.to_s << '>'
47
49
  if @f
48
- str << ('<c:' << @ref_tag_name.to_s << '>')
49
- str << ('<c:f>' << @f.to_s << '</c:f>')
50
+ str << '<c:' << @ref_tag_name.to_s << '>'
51
+ str << '<c:f>' << @f.to_s << '</c:f>'
50
52
  end
51
53
  @data.to_xml_string str
52
54
  if @f
53
- str << ('</c:' << @ref_tag_name.to_s << '>')
55
+ str << '</c:' << @ref_tag_name.to_s << '>'
54
56
  end
55
- str << ('</c:' << tag_name.to_s << '>')
57
+ str << '</c:' << tag_name.to_s << '>'
56
58
  end
57
59
  end
58
60
  end