write_xlsx 1.10.0 → 1.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -0
  3. data/Changes +9 -0
  4. data/README.md +2 -2
  5. data/examples/autofilter.rb +1 -1
  6. data/examples/chart_area.rb +12 -12
  7. data/examples/chart_bar.rb +12 -12
  8. data/examples/chart_clustered.rb +12 -12
  9. data/examples/chart_column.rb +12 -12
  10. data/examples/chart_combined.rb +25 -25
  11. data/examples/chart_data_labels.rb +99 -99
  12. data/examples/chart_data_table.rb +25 -25
  13. data/examples/chart_data_tools.rb +50 -50
  14. data/examples/chart_doughnut.rb +29 -29
  15. data/examples/chart_gauge.rb +18 -18
  16. data/examples/chart_line.rb +32 -32
  17. data/examples/chart_pareto.rb +16 -16
  18. data/examples/chart_pie.rb +17 -17
  19. data/examples/chart_radar.rb +38 -38
  20. data/examples/chart_scatter.rb +12 -12
  21. data/examples/chart_secondary_axis.rb +13 -13
  22. data/examples/chart_stock.rb +12 -12
  23. data/examples/chart_styles.rb +5 -5
  24. data/examples/colors.rb +11 -11
  25. data/examples/comments2.rb +15 -15
  26. data/examples/conditional_format.rb +74 -74
  27. data/examples/data_validate.rb +64 -64
  28. data/examples/date_time.rb +3 -3
  29. data/examples/demo.rb +14 -14
  30. data/examples/diag_border.rb +6 -6
  31. data/examples/dynamic_arrays.rb +2 -2
  32. data/examples/formats.rb +10 -10
  33. data/examples/hyperlink1.rb +4 -4
  34. data/examples/ignore_errors.rb +2 -2
  35. data/examples/indent.rb +2 -2
  36. data/examples/macros.rb +4 -4
  37. data/examples/merge1.rb +1 -1
  38. data/examples/merge2.rb +9 -9
  39. data/examples/merge3.rb +5 -5
  40. data/examples/merge4.rb +20 -20
  41. data/examples/merge5.rb +18 -18
  42. data/examples/merge6.rb +7 -7
  43. data/examples/outline.rb +1 -1
  44. data/examples/outline_collapsed.rb +1 -1
  45. data/examples/panes.rb +4 -4
  46. data/examples/properties.rb +9 -9
  47. data/examples/protection.rb +2 -2
  48. data/examples/rich_strings.rb +6 -6
  49. data/examples/shape1.rb +7 -7
  50. data/examples/shape2.rb +16 -16
  51. data/examples/shape3.rb +5 -5
  52. data/examples/shape4.rb +7 -7
  53. data/examples/shape5.rb +7 -7
  54. data/examples/shape6.rb +7 -7
  55. data/examples/shape7.rb +10 -10
  56. data/examples/shape8.rb +10 -10
  57. data/examples/shape_all.rb +4 -4
  58. data/examples/sparklines1.rb +11 -11
  59. data/examples/sparklines2.rb +76 -76
  60. data/examples/tables.rb +87 -87
  61. data/examples/watermark.rb +1 -1
  62. data/lib/write_xlsx/chart/bar.rb +4 -4
  63. data/lib/write_xlsx/chart/line.rb +1 -1
  64. data/lib/write_xlsx/chart/radar.rb +2 -2
  65. data/lib/write_xlsx/chart/scatter.rb +4 -4
  66. data/lib/write_xlsx/chart/series.rb +27 -27
  67. data/lib/write_xlsx/chart/stock.rb +5 -5
  68. data/lib/write_xlsx/chart.rb +30 -30
  69. data/lib/write_xlsx/colors.rb +19 -19
  70. data/lib/write_xlsx/package/conditional_format.rb +18 -7
  71. data/lib/write_xlsx/package/table.rb +33 -24
  72. data/lib/write_xlsx/shape.rb +5 -5
  73. data/lib/write_xlsx/sheets.rb +1 -1
  74. data/lib/write_xlsx/sparkline.rb +286 -286
  75. data/lib/write_xlsx/utility.rb +32 -31
  76. data/lib/write_xlsx/version.rb +1 -1
  77. data/lib/write_xlsx/workbook.rb +20 -20
  78. data/lib/write_xlsx/worksheet/cell_data.rb +1 -1
  79. data/lib/write_xlsx/worksheet/data_validation.rb +13 -1
  80. data/lib/write_xlsx/worksheet.rb +486 -246
  81. metadata +3 -3
@@ -14,7 +14,7 @@ require 'write_xlsx'
14
14
 
15
15
  workbook = WriteXLSX.new('chart_data_labels.xlsx')
16
16
  worksheet = workbook.add_worksheet
17
- bold = workbook.add_format(:bold => 1)
17
+ bold = workbook.add_format(bold: 1)
18
18
 
19
19
  # Add the worksheet data that the charts will refer to.
20
20
  headings = %w[Number Data Text]
@@ -33,23 +33,23 @@ worksheet.write('A2', data)
33
33
  #
34
34
 
35
35
  # Create a Column chart.
36
- chart1 = workbook.add_chart(:type => 'column', :embedded => 1)
36
+ chart1 = workbook.add_chart(type: 'column', embedded: 1)
37
37
 
38
38
  # Configure the data series and add the data labels.
39
39
  chart1.add_series(
40
- :categories => '=Sheet1!$A$2:$A$7',
41
- :values => '=Sheet1!$B$2:$B$7',
42
- :data_labels => { :value => 1 }
40
+ categories: '=Sheet1!$A$2:$A$7',
41
+ values: '=Sheet1!$B$2:$B$7',
42
+ data_labels: { value: 1 }
43
43
  )
44
44
 
45
45
  # Add a chart title.
46
- chart1.set_title(:name => 'Chart with standard data labels')
46
+ chart1.set_title(name: 'Chart with standard data labels')
47
47
 
48
48
  # Turn off the chart legend.
49
- chart1.set_legend(:none => 1)
49
+ chart1.set_legend(none: 1)
50
50
 
51
51
  # Insert the chart into the worksheet (with an offset).
52
- worksheet.insert_chart('D2', chart1, { :x_offset => 25, :y_offset => 10 })
52
+ worksheet.insert_chart('D2', chart1, { x_offset: 25, y_offset: 10 })
53
53
 
54
54
  #######################################################################
55
55
  #
@@ -57,23 +57,23 @@ worksheet.insert_chart('D2', chart1, { :x_offset => 25, :y_offset => 10 })
57
57
  #
58
58
 
59
59
  # Create a Column chart.
60
- chart2 = workbook.add_chart(:type => 'column', :embedded => 1)
60
+ chart2 = workbook.add_chart(type: 'column', embedded: 1)
61
61
 
62
62
  # Configure the data series and add the data labels.
63
63
  chart2.add_series(
64
- :categories => '=Sheet1!$A$2:$A$7',
65
- :values => '=Sheet1!$B$2:$B$7',
66
- :data_labels => { :value => 1, :category => 1 }
64
+ categories: '=Sheet1!$A$2:$A$7',
65
+ values: '=Sheet1!$B$2:$B$7',
66
+ data_labels: { value: 1, category: 1 }
67
67
  )
68
68
 
69
69
  # Add a chart title.
70
- chart2.set_title(:name => 'Category and Value data labels')
70
+ chart2.set_title(name: 'Category and Value data labels')
71
71
 
72
72
  # Turn off the chart legend.
73
- chart2.set_legend(:none => 1)
73
+ chart2.set_legend(none: 1)
74
74
 
75
75
  # Insert the chart into the worksheet (with an offset).
76
- worksheet.insert_chart('D18', chart2, { :x_offset => 25, :y_offset => 10 })
76
+ worksheet.insert_chart('D18', chart2, { x_offset: 25, y_offset: 10 })
77
77
 
78
78
  #######################################################################
79
79
  #
@@ -81,26 +81,26 @@ worksheet.insert_chart('D18', chart2, { :x_offset => 25, :y_offset => 10 })
81
81
  #
82
82
 
83
83
  # Create a Column chart.
84
- chart3 = workbook.add_chart(:type => 'column', :embedded => 1)
84
+ chart3 = workbook.add_chart(type: 'column', embedded: 1)
85
85
 
86
86
  # Configure the data series and add the data labels.
87
87
  chart3.add_series(
88
- :categories => '=Sheet1!$A$2:$A$7',
89
- :values => '=Sheet1!$B$2:$B$7',
90
- :data_labels => { :value => 1,
91
- :font => { :bold => 1,
92
- :color => 'red',
93
- :rotation => -30 } }
88
+ categories: '=Sheet1!$A$2:$A$7',
89
+ values: '=Sheet1!$B$2:$B$7',
90
+ data_labels: { value: 1,
91
+ font: { bold: 1,
92
+ color: 'red',
93
+ rotation: -30 } }
94
94
  )
95
95
 
96
96
  # Add a chart title.
97
- chart3.set_title(:name => 'Data labels with user defined font')
97
+ chart3.set_title(name: 'Data labels with user defined font')
98
98
 
99
99
  # Turn off the chart legend.
100
- chart3.set_legend(:none => 1)
100
+ chart3.set_legend(none: 1)
101
101
 
102
102
  # Insert the chart into the worksheet (with an offset).
103
- worksheet.insert_chart('D34', chart3, { :x_offset => 25, :y_offset => 10 })
103
+ worksheet.insert_chart('D34', chart3, { x_offset: 25, y_offset: 10 })
104
104
 
105
105
  #######################################################################
106
106
  #
@@ -108,27 +108,27 @@ worksheet.insert_chart('D34', chart3, { :x_offset => 25, :y_offset => 10 })
108
108
  #
109
109
 
110
110
  # Create a Column chart.
111
- chart4 = workbook.add_chart(:type => 'column', :embedded => 1)
111
+ chart4 = workbook.add_chart(type: 'column', embedded: 1)
112
112
 
113
113
  # Configure the data series and add the data labels.
114
114
  chart4.add_series(
115
- :categories => '=Sheet1!$A$2:$A$7',
116
- :values => '=Sheet1!$B$2:$B$7',
117
- :data_labels => {
118
- :value => 1,
119
- :border => { :color => 'red' },
120
- :fill => { :color => 'yellow' }
115
+ categories: '=Sheet1!$A$2:$A$7',
116
+ values: '=Sheet1!$B$2:$B$7',
117
+ data_labels: {
118
+ value: 1,
119
+ border: { color: 'red' },
120
+ fill: { color: 'yellow' }
121
121
  }
122
122
  )
123
123
 
124
124
  # Add a chart title.
125
- chart4.set_title(:name => 'Data labels with formatting')
125
+ chart4.set_title(name: 'Data labels with formatting')
126
126
 
127
127
  # Turn off the chart legend.
128
- chart4.set_legend(:none => 1)
128
+ chart4.set_legend(none: 1)
129
129
 
130
130
  # Insert the chart into the worksheet (with an offset).
131
- worksheet.insert_chart('D50', chart4, { :x_offset => 25, :y_offset => 10 })
131
+ worksheet.insert_chart('D50', chart4, { x_offset: 25, y_offset: 10 })
132
132
 
133
133
  #######################################################################
134
134
  #
@@ -136,33 +136,33 @@ worksheet.insert_chart('D50', chart4, { :x_offset => 25, :y_offset => 10 })
136
136
  #
137
137
 
138
138
  # Create a Column chart.
139
- chart5 = workbook.add_chart(:type => 'column', :embedded => 1)
139
+ chart5 = workbook.add_chart(type: 'column', embedded: 1)
140
140
 
141
141
  # Some custom labels.
142
142
  custom_labels = [
143
- { :value => 'Amy' },
144
- { :value => 'Bea' },
145
- { :value => 'Eva' },
146
- { :value => 'Fay' },
147
- { :value => 'Liv' },
148
- { :value => 'Una' }
143
+ { value: 'Amy' },
144
+ { value: 'Bea' },
145
+ { value: 'Eva' },
146
+ { value: 'Fay' },
147
+ { value: 'Liv' },
148
+ { value: 'Una' }
149
149
  ]
150
150
 
151
151
  # Configure the data series and add the data labels.
152
152
  chart5.add_series(
153
- :categories => '=Sheet1!$A$2:$A$7',
154
- :values => '=Sheet1!$B$2:$B$7',
155
- :data_labels => { :value => 1, :custom => custom_labels }
153
+ categories: '=Sheet1!$A$2:$A$7',
154
+ values: '=Sheet1!$B$2:$B$7',
155
+ data_labels: { value: 1, custom: custom_labels }
156
156
  )
157
157
 
158
158
  # Add a chart title.
159
- chart5.set_title(:name => 'Chart with custom string data labels')
159
+ chart5.set_title(name: 'Chart with custom string data labels')
160
160
 
161
161
  # Turn off the chart legend.
162
- chart5.set_legend(:none => 1)
162
+ chart5.set_legend(none: 1)
163
163
 
164
164
  # Insert the chart into the worksheet (with an offset).
165
- worksheet.insert_chart('D66', chart5, { :x_offset => 25, :y_offset => 10 })
165
+ worksheet.insert_chart('D66', chart5, { x_offset: 25, y_offset: 10 })
166
166
 
167
167
  #######################################################################
168
168
  #
@@ -170,33 +170,33 @@ worksheet.insert_chart('D66', chart5, { :x_offset => 25, :y_offset => 10 })
170
170
  #
171
171
 
172
172
  # Create a Column chart.
173
- chart6 = workbook.add_chart(:type => 'column', :embedded => 1)
173
+ chart6 = workbook.add_chart(type: 'column', embedded: 1)
174
174
 
175
175
  # Some custom labels.
176
176
  custom_labels = [
177
- { :value => '=Sheet1!$C$2' },
178
- { :value => '=Sheet1!$C$3' },
179
- { :value => '=Sheet1!$C$4' },
180
- { :value => '=Sheet1!$C$5' },
181
- { :value => '=Sheet1!$C$6' },
182
- { :value => '=Sheet1!$C$7' }
177
+ { value: '=Sheet1!$C$2' },
178
+ { value: '=Sheet1!$C$3' },
179
+ { value: '=Sheet1!$C$4' },
180
+ { value: '=Sheet1!$C$5' },
181
+ { value: '=Sheet1!$C$6' },
182
+ { value: '=Sheet1!$C$7' }
183
183
  ]
184
184
 
185
185
  # Configure the data series and add the data labels.
186
186
  chart6.add_series(
187
- :categories => '=Sheet1!$A$2:$A$7',
188
- :values => '=Sheet1!$B$2:$B$7',
189
- :data_labels => { :value => 1, :custom => custom_labels }
187
+ categories: '=Sheet1!$A$2:$A$7',
188
+ values: '=Sheet1!$B$2:$B$7',
189
+ data_labels: { value: 1, custom: custom_labels }
190
190
  )
191
191
 
192
192
  # Add a chart title.
193
- chart6.set_title(:name => 'Chart with custom data labels from cells')
193
+ chart6.set_title(name: 'Chart with custom data labels from cells')
194
194
 
195
195
  # Turn off the chart legend.
196
- chart6.set_legend(:none => 1)
196
+ chart6.set_legend(none: 1)
197
197
 
198
198
  # Insert the chart into the worksheet (with an offset).
199
- worksheet.insert_chart('D82', chart6, { :x_offset => 25, :y_offset => 10 })
199
+ worksheet.insert_chart('D82', chart6, { x_offset: 25, y_offset: 10 })
200
200
 
201
201
  #######################################################################
202
202
  #
@@ -204,32 +204,32 @@ worksheet.insert_chart('D82', chart6, { :x_offset => 25, :y_offset => 10 })
204
204
  #
205
205
 
206
206
  # Create a Column chart.
207
- chart7 = workbook.add_chart(:type => 'column', :embedded => 1)
207
+ chart7 = workbook.add_chart(type: 'column', embedded: 1)
208
208
 
209
209
  # Some custom labels. The nil items will get the default value.
210
210
  # We also set a font for the custom items as an extra example.
211
211
  custom_labels = [
212
- { :value => '=Sheet1!$C$2', :font => { :color => 'red' } },
212
+ { value: '=Sheet1!$C$2', font: { color: 'red' } },
213
213
  nil,
214
- { :value => '=Sheet1!$C$4', :font => { :color => 'red' } },
215
- { :value => '=Sheet1!$C$5', :font => { :color => 'red' } }
214
+ { value: '=Sheet1!$C$4', font: { color: 'red' } },
215
+ { value: '=Sheet1!$C$5', font: { color: 'red' } }
216
216
  ]
217
217
 
218
218
  # Configure the data series and add the data labels.
219
219
  chart7.add_series(
220
- :categories => '=Sheet1!$A$2:$A$7',
221
- :values => '=Sheet1!$B$2:$B$7',
222
- :data_labels => { :value => 1, :custom => custom_labels }
220
+ categories: '=Sheet1!$A$2:$A$7',
221
+ values: '=Sheet1!$B$2:$B$7',
222
+ data_labels: { value: 1, custom: custom_labels }
223
223
  )
224
224
 
225
225
  # Add a chart title.
226
- chart7.set_title(:name => 'Mixed custom and default data labels')
226
+ chart7.set_title(name: 'Mixed custom and default data labels')
227
227
 
228
228
  # Turn off the chart legend.
229
- chart7.set_legend(:none => 1)
229
+ chart7.set_legend(none: 1)
230
230
 
231
231
  # Insert the chart into the worksheet (with an offset).
232
- worksheet.insert_chart('D98', chart7, { :x_offset => 25, :y_offset => 10 })
232
+ worksheet.insert_chart('D98', chart7, { x_offset: 25, y_offset: 10 })
233
233
 
234
234
  #######################################################################
235
235
  #
@@ -237,34 +237,34 @@ worksheet.insert_chart('D98', chart7, { :x_offset => 25, :y_offset => 10 })
237
237
  #
238
238
 
239
239
  # Create a Column chart.
240
- chart8 = workbook.add_chart(:type => 'column', :embedded => 1)
240
+ chart8 = workbook.add_chart(type: 'column', embedded: 1)
241
241
 
242
242
  # Some deleted custom labels and defaults (nil). This allows us to
243
243
  # highlight certain values such as the minimum and maximum.
244
244
  custom_labels = [
245
- { :delete => 1 },
245
+ { delete: 1 },
246
246
  nil,
247
- { :delete => 1 },
248
- { :delete => 1 },
247
+ { delete: 1 },
248
+ { delete: 1 },
249
249
  nil,
250
- { :delete => 1 }
250
+ { delete: 1 }
251
251
  ]
252
252
 
253
253
  # Configure the data series and add the data labels.
254
254
  chart8.add_series(
255
- :categories => '=Sheet1!$A$2:$A$7',
256
- :values => '=Sheet1!$B$2:$B$7',
257
- :data_labels => { :value => 1, :custom => custom_labels }
255
+ categories: '=Sheet1!$A$2:$A$7',
256
+ values: '=Sheet1!$B$2:$B$7',
257
+ data_labels: { value: 1, custom: custom_labels }
258
258
  )
259
259
 
260
260
  # Add a chart title.
261
- chart8.set_title(:name => 'Chart with deleted data labels')
261
+ chart8.set_title(name: 'Chart with deleted data labels')
262
262
 
263
263
  # Turn off the chart legend.
264
- chart8.set_legend(:none => 1)
264
+ chart8.set_legend(none: 1)
265
265
 
266
266
  # Insert the chart into the worksheet (with an offset).
267
- worksheet.insert_chart('D114', chart8, { :x_offset => 25, :y_offset => 10 })
267
+ worksheet.insert_chart('D114', chart8, { x_offset: 25, y_offset: 10 })
268
268
 
269
269
  #######################################################################
270
270
  #
@@ -272,37 +272,37 @@ worksheet.insert_chart('D114', chart8, { :x_offset => 25, :y_offset => 10 })
272
272
  #
273
273
 
274
274
  # Create a Column chart.
275
- chart9 = workbook.add_chart(:type => 'column', :embedded => 1)
275
+ chart9 = workbook.add_chart(type: 'column', embedded: 1)
276
276
 
277
277
  # Some custom labels.
278
278
  custom_labels = [
279
- { :value => 'Amy', :border => { :color => 'blue' } },
280
- { :value => 'Bea' },
281
- { :value => 'Eva' },
282
- { :value => 'Fay' },
283
- { :value => 'Liv' },
284
- { :value => 'Una', :fill => { :color => 'green' } }
279
+ { value: 'Amy', border: { color: 'blue' } },
280
+ { value: 'Bea' },
281
+ { value: 'Eva' },
282
+ { value: 'Fay' },
283
+ { value: 'Liv' },
284
+ { value: 'Una', fill: { color: 'green' } }
285
285
  ]
286
286
 
287
287
  # Configure the data series and add the data labels.
288
288
  chart9.add_series(
289
- :categories => '=Sheet1!$A$2:$A$7',
290
- :values => '=Sheet1!$B$2:$B$7',
291
- :data_labels => {
292
- :value => 1,
293
- :custom => custom_labels,
294
- :border => { :color => 'red' },
295
- :fill => { :color => 'yellow' }
289
+ categories: '=Sheet1!$A$2:$A$7',
290
+ values: '=Sheet1!$B$2:$B$7',
291
+ data_labels: {
292
+ value: 1,
293
+ custom: custom_labels,
294
+ border: { color: 'red' },
295
+ fill: { color: 'yellow' }
296
296
  }
297
297
  )
298
298
 
299
299
  # Add a chart title.
300
- chart9.set_title(:name => 'Chart with custom labels and formatting')
300
+ chart9.set_title(name: 'Chart with custom labels and formatting')
301
301
 
302
302
  # Turn off the chart legend.
303
- chart9.set_legend(:none => 1)
303
+ chart9.set_legend(none: 1)
304
304
 
305
305
  # Insert the chart into the worksheet (with an offset).
306
- worksheet.insert_chart('D130', chart9, { :x_offset => 25, :y_offset => 10 })
306
+ worksheet.insert_chart('D130', chart9, { x_offset: 25, y_offset: 10 })
307
307
 
308
308
  workbook.close
@@ -14,7 +14,7 @@ require 'write_xlsx'
14
14
 
15
15
  workbook = WriteXLSX.new('chart_data_table.xlsx')
16
16
  worksheet = workbook.add_worksheet
17
- bold = workbook.add_format(:bold => 1)
17
+ bold = workbook.add_format(bold: 1)
18
18
 
19
19
  # Add the worksheet data that the charts will refer to.
20
20
  headings = ['Number', 'Batch 1', 'Batch 2']
@@ -28,27 +28,27 @@ worksheet.write('A1', headings, bold)
28
28
  worksheet.write('A2', data)
29
29
 
30
30
  # Create a new column chart with a data table.
31
- chart1 = workbook.add_chart(:type => 'column', :embedded => 1)
31
+ chart1 = workbook.add_chart(type: 'column', embedded: 1)
32
32
 
33
33
  # Configure the first series.
34
34
  chart1.add_series(
35
- :name => '=Sheet1!$B$1',
36
- :categories => '=Sheet1!$A$2:$A$7',
37
- :values => '=Sheet1!$B$2:$B$7'
35
+ name: '=Sheet1!$B$1',
36
+ categories: '=Sheet1!$A$2:$A$7',
37
+ values: '=Sheet1!$B$2:$B$7'
38
38
  )
39
39
 
40
40
  # Configure second series. Note alternative use of array ref to define
41
41
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
42
42
  chart1.add_series(
43
- :name => '=Sheet1!$C$1',
44
- :categories => ['Sheet1', 1, 6, 0, 0],
45
- :values => ['Sheet1', 1, 6, 2, 2]
43
+ name: '=Sheet1!$C$1',
44
+ categories: ['Sheet1', 1, 6, 0, 0],
45
+ values: ['Sheet1', 1, 6, 2, 2]
46
46
  )
47
47
 
48
48
  # Add a chart title and some axis labels.
49
- chart1.set_title(:name => 'Chart with Data Table')
50
- chart1.set_x_axis(:name => 'Test number')
51
- chart1.set_y_axis(:name => 'Sample length (mm)')
49
+ chart1.set_title(name: 'Chart with Data Table')
50
+ chart1.set_x_axis(name: 'Test number')
51
+ chart1.set_y_axis(name: 'Sample length (mm)')
52
52
 
53
53
  # Set a default data table on the X-Axis.
54
54
  chart1.set_table
@@ -56,44 +56,44 @@ chart1.set_table
56
56
  # Insert the chart into the worksheet (with an offset).
57
57
  worksheet.insert_chart(
58
58
  'D2', chart1,
59
- :x_offset => 25, :y_offset => 10
59
+ x_offset: 25, y_offset: 10
60
60
  )
61
61
 
62
62
  #
63
63
  # Create a second charat.
64
64
  #
65
- chart2 = workbook.add_chart(:type => 'column', :embedded => 1)
65
+ chart2 = workbook.add_chart(type: 'column', embedded: 1)
66
66
 
67
67
  # Configure the first series.
68
68
  chart2.add_series(
69
- :name => '=Sheet1!$B$1',
70
- :categories => '=Sheet1!$A$2:$A$7',
71
- :values => '=Sheet1!$B$2:$B$7'
69
+ name: '=Sheet1!$B$1',
70
+ categories: '=Sheet1!$A$2:$A$7',
71
+ values: '=Sheet1!$B$2:$B$7'
72
72
  )
73
73
 
74
74
  # Configure second series. Note alternative use of array ref to define
75
75
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
76
76
  chart2.add_series(
77
- :name => '=Sheet1!$C$1',
78
- :categories => ['Sheet1', 1, 6, 0, 0],
79
- :values => ['Sheet1', 1, 6, 2, 2]
77
+ name: '=Sheet1!$C$1',
78
+ categories: ['Sheet1', 1, 6, 0, 0],
79
+ values: ['Sheet1', 1, 6, 2, 2]
80
80
  )
81
81
 
82
82
  # Add a chart title and some axis labels.
83
- chart2.set_title(:name => 'Data Table with legend keys')
84
- chart2.set_x_axis(:name => 'Test number')
85
- chart2.set_y_axis(:name => 'Sample length (mm)')
83
+ chart2.set_title(name: 'Data Table with legend keys')
84
+ chart2.set_x_axis(name: 'Test number')
85
+ chart2.set_y_axis(name: 'Sample length (mm)')
86
86
 
87
87
  # Set a default data table on the X-Axis with the legend keys shown.
88
- chart2.set_table(:show_keys => true)
88
+ chart2.set_table(show_keys: true)
89
89
 
90
90
  # Hide the chart legend since the keys are show on the data table.
91
- chart2.set_legend(:position => 'none')
91
+ chart2.set_legend(position: 'none')
92
92
 
93
93
  # Insert the chart into the worksheet (with an offset).
94
94
  worksheet.insert_chart(
95
95
  'D18', chart2,
96
- :x_offset => 25, :y_offset => 11
96
+ x_offset: 25, y_offset: 11
97
97
  )
98
98
 
99
99
  workbook.close