write_xlsx 1.10.0 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -1
  3. data/Changes +3 -0
  4. data/README.md +1 -1
  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 +3 -3
  71. data/lib/write_xlsx/package/table.rb +8 -8
  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 +23 -23
  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.rb +28 -28
  80. metadata +2 -2
@@ -19,7 +19,7 @@ require 'write_xlsx'
19
19
 
20
20
  workbook = WriteXLSX.new('chart_pie.xlsx')
21
21
  worksheet = workbook.add_worksheet
22
- bold = workbook.add_format(:bold => 1)
22
+ bold = workbook.add_format(bold: 1)
23
23
 
24
24
  # Add the worksheet data that the charts will refer to.
25
25
  headings = %w[Category Values]
@@ -32,19 +32,19 @@ worksheet.write('A1', headings, bold)
32
32
  worksheet.write('A2', data)
33
33
 
34
34
  # Create a new chart object. In this case an embedded chart.
35
- chart1 = workbook.add_chart(:type => 'pie', :embedded => 1)
35
+ chart1 = workbook.add_chart(type: 'pie', embedded: 1)
36
36
 
37
37
  # Configure the series. Note the use of the array ref to define ranges:
38
38
  # [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
39
39
  # See below for an alternative syntax.
40
40
  chart1.add_series(
41
- :name => 'Pie sales data',
42
- :categories => ['Sheet1', 1, 3, 0, 0],
43
- :values => ['Sheet1', 1, 3, 1, 1]
41
+ name: 'Pie sales data',
42
+ categories: ['Sheet1', 1, 3, 0, 0],
43
+ values: ['Sheet1', 1, 3, 1, 1]
44
44
  )
45
45
 
46
46
  # Add a title.
47
- chart1.set_title(:name => 'Popular Pie Types')
47
+ chart1.set_title(name: 'Popular Pie Types')
48
48
 
49
49
  # Set an Excel chart style. Blue colors with white outline and shadow.
50
50
  chart1.set_style(10)
@@ -52,7 +52,7 @@ chart1.set_style(10)
52
52
  # Insert the chart into the worksheet (with an offset).
53
53
  worksheet.insert_chart(
54
54
  'C2', chart1,
55
- :x_offset => 25, :y_offset => 10
55
+ x_offset: 25, y_offset: 10
56
56
  )
57
57
 
58
58
  #
@@ -60,26 +60,26 @@ worksheet.insert_chart(
60
60
  #
61
61
 
62
62
  # Create an example Pie chart like above.
63
- chart2 = workbook.add_chart(:type => 'pie', :embedded => 1)
63
+ chart2 = workbook.add_chart(type: 'pie', embedded: 1)
64
64
 
65
65
  # Configure the series.
66
66
  chart2.add_series(
67
- :name => 'Pie sales data',
68
- :categories => '=Sheet1!$A$2:$A$4',
69
- :values => '=Sheet1!$B$2:$B$4',
70
- :points => [
71
- { :fill => { :color => '#5ABA10' } },
72
- { :fill => { :color => '#FE110E' } },
73
- { :fill => { :color => '#CA5C05' } }
67
+ name: 'Pie sales data',
68
+ categories: '=Sheet1!$A$2:$A$4',
69
+ values: '=Sheet1!$B$2:$B$4',
70
+ points: [
71
+ { fill: { color: '#5ABA10' } },
72
+ { fill: { color: '#FE110E' } },
73
+ { fill: { color: '#CA5C05' } }
74
74
  ]
75
75
  )
76
76
 
77
77
  # Add a title.
78
- chart2.set_title(:name => 'Pie Chart with user defined colors')
78
+ chart2.set_title(name: 'Pie Chart with user defined colors')
79
79
 
80
80
  worksheet.insert_chart(
81
81
  'C18', chart2,
82
- :x_offset => 25, :y_offset => 10
82
+ x_offset: 25, y_offset: 10
83
83
  )
84
84
 
85
85
  workbook.close
@@ -13,7 +13,7 @@ require 'write_xlsx'
13
13
 
14
14
  workbook = WriteXLSX.new('chart_radar.xlsx')
15
15
  worksheet = workbook.add_worksheet
16
- bold = workbook.add_format(:bold => 1)
16
+ bold = workbook.add_format(bold: 1)
17
17
 
18
18
  # Add the worksheet data that the charts will refer to.
19
19
  headings = ['Number', 'Batch 1', 'Batch 2']
@@ -27,27 +27,27 @@ worksheet.write('A1', headings, bold)
27
27
  worksheet.write('A2', data)
28
28
 
29
29
  # Create a new chart object. In this case an embedded chart.
30
- chart1 = workbook.add_chart(:type => 'radar', :embedded => 1)
30
+ chart1 = workbook.add_chart(type: 'radar', embedded: 1)
31
31
 
32
32
  # Configure the first series.
33
33
  chart1.add_series(
34
- :name => '=Sheet1!$B$1',
35
- :categories => '=Sheet1!$A$2:$A$7',
36
- :values => '=Sheet1!$B$2:$B$7'
34
+ name: '=Sheet1!$B$1',
35
+ categories: '=Sheet1!$A$2:$A$7',
36
+ values: '=Sheet1!$B$2:$B$7'
37
37
  )
38
38
 
39
39
  # Configure second series. Note alternative use of array ref to define
40
40
  # ranges: [ sheetname, row_start, row_end, col_start, col_end ].
41
41
  chart1.add_series(
42
- :name => '=Sheet1!$C$1',
43
- :categories => ['Sheet1', 1, 6, 0, 0],
44
- :values => ['Sheet1', 1, 6, 2, 2]
42
+ name: '=Sheet1!$C$1',
43
+ categories: ['Sheet1', 1, 6, 0, 0],
44
+ values: ['Sheet1', 1, 6, 2, 2]
45
45
  )
46
46
 
47
47
  # Add a chart title and some axis labels.
48
- chart1.set_title(:name => 'Results of sample analysis')
49
- chart1.set_x_axis(:name => 'Test number')
50
- chart1.set_y_axis(:name => 'Sample length (mm)')
48
+ chart1.set_title(name: 'Results of sample analysis')
49
+ chart1.set_x_axis(name: 'Test number')
50
+ chart1.set_y_axis(name: 'Sample length (mm)')
51
51
 
52
52
  # Set an Excel chart style. Blue colors with white outline and shadow.
53
53
  chart1.set_style(11)
@@ -55,36 +55,36 @@ chart1.set_style(11)
55
55
  # Insert the chart into the worksheet (with an offset).
56
56
  worksheet.insert_chart(
57
57
  'D2', chart1,
58
- :x_offset => 25, :y_offset => 10
58
+ x_offset: 25, y_offset: 10
59
59
  )
60
60
 
61
61
  #
62
62
  # Create a with_markers chart sub-type
63
63
  #
64
64
  chart2 = workbook.add_chart(
65
- :type => 'radar',
66
- :embedded => 1,
67
- :subtype => 'with_markers'
65
+ type: 'radar',
66
+ embedded: 1,
67
+ subtype: 'with_markers'
68
68
  )
69
69
 
70
70
  # Configure the first series.
71
71
  chart2.add_series(
72
- :name => '=Sheet1!$B$1',
73
- :categories => '=Sheet1!$A$2:$A$7',
74
- :values => '=Sheet1!$B$2:$B$7'
72
+ name: '=Sheet1!$B$1',
73
+ categories: '=Sheet1!$A$2:$A$7',
74
+ values: '=Sheet1!$B$2:$B$7'
75
75
  )
76
76
 
77
77
  # Configure second series.
78
78
  chart2.add_series(
79
- :name => '=Sheet1!$C$1',
80
- :categories => ['Sheet1', 1, 6, 0, 0],
81
- :values => ['Sheet1', 1, 6, 2, 2]
79
+ name: '=Sheet1!$C$1',
80
+ categories: ['Sheet1', 1, 6, 0, 0],
81
+ values: ['Sheet1', 1, 6, 2, 2]
82
82
  )
83
83
 
84
84
  # Add a chart title and some axis labels.
85
- chart2.set_title(:name => 'Stacked Chart')
86
- chart2.set_x_axis(:name => 'Test number')
87
- chart2.set_y_axis(:name => 'Sample length (mm)')
85
+ chart2.set_title(name: 'Stacked Chart')
86
+ chart2.set_x_axis(name: 'Test number')
87
+ chart2.set_y_axis(name: 'Sample length (mm)')
88
88
 
89
89
  # Set an Excel chart style. Blue colors with white outline and shadow.
90
90
  chart2.set_style(12)
@@ -92,36 +92,36 @@ chart2.set_style(12)
92
92
  # Insert the chart into the worksheet (with an offset).
93
93
  worksheet.insert_chart(
94
94
  'D18', chart2,
95
- :x_offset => 25, :y_offset => 10
95
+ x_offset: 25, y_offset: 10
96
96
  )
97
97
 
98
98
  #
99
99
  # Create a filled chart sub-type
100
100
  #
101
101
  chart3 = workbook.add_chart(
102
- :type => 'radar',
103
- :embedded => 1,
104
- :subtype => 'filled'
102
+ type: 'radar',
103
+ embedded: 1,
104
+ subtype: 'filled'
105
105
  )
106
106
 
107
107
  # Configure the first series.
108
108
  chart3.add_series(
109
- :name => '=Sheet1!$B$1',
110
- :categories => '=Sheet1!$A$2:$A$7',
111
- :values => '=Sheet1!$B$2:$B$7'
109
+ name: '=Sheet1!$B$1',
110
+ categories: '=Sheet1!$A$2:$A$7',
111
+ values: '=Sheet1!$B$2:$B$7'
112
112
  )
113
113
 
114
114
  # Configure second series.
115
115
  chart3.add_series(
116
- :name => '=Sheet1!$C$1',
117
- :categories => ['Sheet1', 1, 6, 0, 0],
118
- :values => ['Sheet1', 1, 6, 2, 2]
116
+ name: '=Sheet1!$C$1',
117
+ categories: ['Sheet1', 1, 6, 0, 0],
118
+ values: ['Sheet1', 1, 6, 2, 2]
119
119
  )
120
120
 
121
121
  # Add a chart title and some axis labels.
122
- chart3.set_title(:name => 'Percent Stacked Chart')
123
- chart3.set_x_axis(:name => 'Test number')
124
- chart3.set_y_axis(:name => 'Sample length (mm)')
122
+ chart3.set_title(name: 'Percent Stacked Chart')
123
+ chart3.set_x_axis(name: 'Test number')
124
+ chart3.set_y_axis(name: 'Sample length (mm)')
125
125
 
126
126
  # Set an Excel chart style. Blue colors with white outline and shadow.
127
127
  chart3.set_style(13)
@@ -129,7 +129,7 @@ chart3.set_style(13)
129
129
  # Insert the chart into the worksheet (with an offset).
130
130
  worksheet.insert_chart(
131
131
  'D34', chart3,
132
- :x_offset => 25, :y_offset => 10
132
+ x_offset: 25, y_offset: 10
133
133
  )
134
134
 
135
135
  workbook.close
@@ -13,7 +13,7 @@ require 'write_xlsx'
13
13
 
14
14
  workbook = WriteXLSX.new('chart_scatter.xlsx')
15
15
  worksheet = workbook.add_worksheet
16
- bold = workbook.add_format(:bold => 1)
16
+ bold = workbook.add_format(bold: 1)
17
17
 
18
18
  # Add the worksheet data that the charts will refer to.
19
19
  headings = ['Number', 'Batch 1', 'Batch 2']
@@ -27,27 +27,27 @@ worksheet.write('A1', headings, bold)
27
27
  worksheet.write('A2', data)
28
28
 
29
29
  # Create a new chart object. In this case an embedded chart.
30
- chart = workbook.add_chart(:type => 'scatter', :embedded => 1)
30
+ chart = workbook.add_chart(type: 'scatter', embedded: 1)
31
31
 
32
32
  # Configure the first series.
33
33
  chart.add_series(
34
- :name => '=Sheet1!$B$1',
35
- :categories => '=Sheet1!$A$2:$A$7',
36
- :values => '=Sheet1!$B$2:$B$7'
34
+ name: '=Sheet1!$B$1',
35
+ categories: '=Sheet1!$A$2:$A$7',
36
+ values: '=Sheet1!$B$2:$B$7'
37
37
  )
38
38
 
39
39
  # Configure second series. Note alternative use of array ref to define
40
40
  # ranges: [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
41
41
  chart.add_series(
42
- :name => '=Sheet1!$C$1',
43
- :categories => ['Sheet1', 1, 6, 0, 0],
44
- :values => ['Sheet1', 1, 6, 2, 2]
42
+ name: '=Sheet1!$C$1',
43
+ categories: ['Sheet1', 1, 6, 0, 0],
44
+ values: ['Sheet1', 1, 6, 2, 2]
45
45
  )
46
46
 
47
47
  # Add a chart title and some axis labels.
48
- chart.set_title(:name => 'Results of sample analysis')
49
- chart.set_x_axis(:name => 'Test number')
50
- chart.set_y_axis(:name => 'Sample length (mm)')
48
+ chart.set_title(name: 'Results of sample analysis')
49
+ chart.set_x_axis(name: 'Test number')
50
+ chart.set_y_axis(name: 'Sample length (mm)')
51
51
 
52
52
  # Set an Excel chart style. Blue colors with white outline and shadow.
53
53
  chart.set_style(10)
@@ -55,7 +55,7 @@ chart.set_style(10)
55
55
  # Insert the chart into the worksheet (with an offset).
56
56
  worksheet.insert_chart(
57
57
  'D2', chart,
58
- :x_offset => 25, :y_offset => 10
58
+ x_offset: 25, y_offset: 10
59
59
  )
60
60
 
61
61
  workbook.close
@@ -13,7 +13,7 @@ require 'write_xlsx'
13
13
 
14
14
  workbook = WriteXLSX.new('chart_secondary_axis.xlsx')
15
15
  worksheet = workbook.add_worksheet
16
- bold = workbook.add_format(:bold => 1)
16
+ bold = workbook.add_format(bold: 1)
17
17
 
18
18
  # Add the worksheet data that the charts will refer to.
19
19
  headings = %w[Aliens Humans]
@@ -26,32 +26,32 @@ worksheet.write('A1', headings, bold)
26
26
  worksheet.write('A2', data)
27
27
 
28
28
  # Create a new chart object. In this case an embedded chart.
29
- chart = workbook.add_chart(:type => 'line', :embedded => 1)
29
+ chart = workbook.add_chart(type: 'line', embedded: 1)
30
30
 
31
31
  # Configure the first series.
32
32
  chart.add_series(
33
- :name => '=Sheet1!$A$1',
34
- :values => '=Sheet1!$A$2:$A$7',
35
- :y2_axis => 1
33
+ name: '=Sheet1!$A$1',
34
+ values: '=Sheet1!$A$2:$A$7',
35
+ y2_axis: 1
36
36
  )
37
37
 
38
38
  chart.add_series(
39
- :name => '=Sheet1!$B$1',
40
- :values => '=Sheet1!$B$2:$B$7'
39
+ name: '=Sheet1!$B$1',
40
+ values: '=Sheet1!$B$2:$B$7'
41
41
  )
42
42
 
43
- chart.set_legend(:position => 'right')
43
+ chart.set_legend(position: 'right')
44
44
 
45
45
  # Add a chart title and some axis labels.
46
- chart.set_title(:name => 'Survey results')
47
- chart.set_x_axis(:name => 'Days')
48
- chart.set_y_axis(:name => 'Population', :major_gridlines => { :visible => 0 })
49
- chart.set_y2_axis(:name => 'Laser wounds')
46
+ chart.set_title(name: 'Survey results')
47
+ chart.set_x_axis(name: 'Days')
48
+ chart.set_y_axis(name: 'Population', major_gridlines: { visible: 0 })
49
+ chart.set_y2_axis(name: 'Laser wounds')
50
50
 
51
51
  # Insert the chart into the worksheet (with an offset).
52
52
  worksheet.insert_chart(
53
53
  'D2', chart,
54
- :x_offset => 25, :y_offset => 10
54
+ x_offset: 25, y_offset: 10
55
55
  )
56
56
 
57
57
  workbook.close
@@ -13,9 +13,9 @@ require 'write_xlsx'
13
13
 
14
14
  workbook = WriteXLSX.new('chart_stock.xlsx')
15
15
  worksheet = workbook.add_worksheet
16
- bold = workbook.add_format(:bold => 1)
17
- date_format = workbook.add_format(:num_format => 'dd/mm/yyyy')
18
- chart = workbook.add_chart(:type => 'stock', :embedded => 1)
16
+ bold = workbook.add_format(bold: 1)
17
+ date_format = workbook.add_format(num_format: 'dd/mm/yyyy')
18
+ chart = workbook.add_chart(type: 'stock', embedded: 1)
19
19
 
20
20
  # Add the worksheet data that the charts will refer to.
21
21
  headings = %w[Date High Low Close]
@@ -39,24 +39,24 @@ worksheet.set_column('A:D', 11)
39
39
 
40
40
  # Add a series for each of the High-Low-Close columns.
41
41
  chart.add_series(
42
- :categories => '=Sheet1!$A$2:$A$6',
43
- :values => '=Sheet1!$B$2:$B$6'
42
+ categories: '=Sheet1!$A$2:$A$6',
43
+ values: '=Sheet1!$B$2:$B$6'
44
44
  )
45
45
 
46
46
  chart.add_series(
47
- :categories => '=Sheet1!$A$2:$A$6',
48
- :values => '=Sheet1!$C$2:$C$6'
47
+ categories: '=Sheet1!$A$2:$A$6',
48
+ values: '=Sheet1!$C$2:$C$6'
49
49
  )
50
50
 
51
51
  chart.add_series(
52
- :categories => '=Sheet1!$A$2:$A$6',
53
- :values => '=Sheet1!$D$2:$D$6'
52
+ categories: '=Sheet1!$A$2:$A$6',
53
+ values: '=Sheet1!$D$2:$D$6'
54
54
  )
55
55
 
56
56
  # Add a chart title and some axis labels.
57
- chart.set_title(:name => 'High-Low-Close')
58
- chart.set_x_axis(:name => 'Date')
59
- chart.set_y_axis(:name => 'Share price')
57
+ chart.set_title(name: 'High-Low-Close')
58
+ chart.set_x_axis(name: 'Date')
59
+ chart.set_y_axis(name: 'Share price')
60
60
 
61
61
  worksheet.insert_chart('E9', chart)
62
62
 
@@ -28,13 +28,13 @@ chart_types.each do |chart_type|
28
28
  0.step(89, 15) do |row_num|
29
29
  0.step(63, 8) do |col_num|
30
30
  chart = workbook.add_chart(
31
- :type => chart_type,
32
- :embedded => 1
31
+ type: chart_type,
32
+ embedded: 1
33
33
  )
34
34
 
35
- chart.add_series(:values => '=Data!$A$1:$A$6')
36
- chart.set_title(:name => "Style #{style_number}")
37
- chart.set_legend(:none => 1)
35
+ chart.add_series(values: '=Data!$A$1:$A$6')
36
+ chart.set_title(name: "Style #{style_number}")
37
+ chart.set_legend(none: 1)
38
38
  chart.set_style(style_number)
39
39
 
40
40
  worksheet.insert_chart(row_num, col_num, chart)
data/examples/colors.rb CHANGED
@@ -20,8 +20,8 @@ require 'write_xlsx'
20
20
  workbook = WriteXLSX.new("colors.xlsx")
21
21
 
22
22
  # Some common formats
23
- center = workbook.add_format(:align => 'center')
24
- heading = workbook.add_format(:align => 'center', :bold => 1)
23
+ center = workbook.add_format(align: 'center')
24
+ heading = workbook.add_format(align: 'center', bold: 1)
25
25
 
26
26
  ######################################################################
27
27
  #
@@ -83,9 +83,9 @@ i = 1
83
83
  #
84
84
  order.each do |index|
85
85
  format = workbook.add_format(
86
- :fg_color => colors[index],
87
- :pattern => 1,
88
- :border => 1
86
+ fg_color: colors[index],
87
+ pattern: 1,
88
+ border: 1
89
89
  )
90
90
 
91
91
  worksheet1.write(i + 1, 0, index, center)
@@ -111,9 +111,9 @@ worksheet2.write(0, 3, "Name", heading)
111
111
 
112
112
  (8..63).each do |i|
113
113
  format = workbook.add_format(
114
- :fg_color => i,
115
- :pattern => 1,
116
- :border => 1
114
+ fg_color: i,
115
+ pattern: 1,
116
+ border: 1
117
117
  )
118
118
 
119
119
  worksheet2.write((i - 7), 0, i, center)
@@ -159,9 +159,9 @@ i = 1
159
159
 
160
160
  colors.each do |html_color, color|
161
161
  format = workbook.add_format(
162
- :fg_color => html_color,
163
- :pattern => 1,
164
- :border => 1
162
+ fg_color: html_color,
163
+ pattern: 1,
164
+ border: 1
165
165
  )
166
166
 
167
167
  worksheet3.write(i + 1, 1, html_color, center)
@@ -5,7 +5,7 @@ require 'write_xlsx'
5
5
 
6
6
  workbook = WriteXLSX.new('comments2.xlsx')
7
7
 
8
- text_wrap = workbook.add_format(:text_wrap => 1, :valign => 'top')
8
+ text_wrap = workbook.add_format(text_wrap: 1, valign: 'top')
9
9
  worksheet1 = workbook.add_worksheet
10
10
  worksheet2 = workbook.add_worksheet
11
11
  worksheet3 = workbook.add_worksheet
@@ -59,7 +59,7 @@ cell_text = 'This cell comment is visible.'
59
59
  comment = 'Hello.'
60
60
 
61
61
  worksheet2.write('C3', cell_text, text_wrap)
62
- worksheet2.write_comment('C3', comment, :visible => 1)
62
+ worksheet2.write_comment('C3', comment, visible: 1)
63
63
 
64
64
  cell_text = "This cell comment isn't visible (the default)."
65
65
 
@@ -88,7 +88,7 @@ cell_text = 'This cell comment is visible, explicitly.'
88
88
  comment = 'Hello.'
89
89
 
90
90
  worksheet3.write('C3', cell_text, text_wrap)
91
- worksheet3.write_comment('C3', comment, :visible => 1)
91
+ worksheet3.write_comment('C3', comment, visible: 1)
92
92
 
93
93
  cell_text =
94
94
  'This cell comment is also visible because we used show_comments().'
@@ -103,7 +103,7 @@ cell_text = 'However, we can still override it locally.'
103
103
  comment = 'Hello.'
104
104
 
105
105
  worksheet3.write('C9', cell_text, text_wrap)
106
- worksheet3.write_comment('C9', comment, :visible => 0)
106
+ worksheet3.write_comment('C9', comment, visible: 0)
107
107
 
108
108
  ###############################################################################
109
109
  #
@@ -131,28 +131,28 @@ cell_text = 'This cell comment is twice as wide.'
131
131
  comment = 'Hello.'
132
132
 
133
133
  worksheet4.write('C6', cell_text, text_wrap)
134
- worksheet4.write_comment('C6', comment, :x_scale => 2)
134
+ worksheet4.write_comment('C6', comment, x_scale: 2)
135
135
 
136
136
  cell_text = 'This cell comment is twice as high.'
137
137
 
138
138
  comment = 'Hello.'
139
139
 
140
140
  worksheet4.write('C9', cell_text, text_wrap)
141
- worksheet4.write_comment('C9', comment, :y_scale => 2)
141
+ worksheet4.write_comment('C9', comment, y_scale: 2)
142
142
 
143
143
  cell_text = 'This cell comment is scaled in both directions.'
144
144
 
145
145
  comment = 'Hello.'
146
146
 
147
147
  worksheet4.write('C16', cell_text, text_wrap)
148
- worksheet4.write_comment('C16', comment, :x_scale => 1.2, :y_scale => 0.8)
148
+ worksheet4.write_comment('C16', comment, x_scale: 1.2, y_scale: 0.8)
149
149
 
150
150
  cell_text = 'This cell comment has width and height specified in pixels.'
151
151
 
152
152
  comment = 'Hello.'
153
153
 
154
154
  worksheet4.write('C19', cell_text, text_wrap)
155
- worksheet4.write_comment('C19', comment, :width => 200, :height => 20)
155
+ worksheet4.write_comment('C19', comment, width: 200, height: 20)
156
156
 
157
157
  ###############################################################################
158
158
  #
@@ -179,21 +179,21 @@ cell_text = 'This cell comment has been moved to another cell.'
179
179
  comment = 'Hello.'
180
180
 
181
181
  worksheet5.write('C6', cell_text, text_wrap)
182
- worksheet5.write_comment('C6', comment, :start_cell => 'E4')
182
+ worksheet5.write_comment('C6', comment, start_cell: 'E4')
183
183
 
184
184
  cell_text = 'This cell comment has been moved to another cell.'
185
185
 
186
186
  comment = 'Hello.'
187
187
 
188
188
  worksheet5.write('C9', cell_text, text_wrap)
189
- worksheet5.write_comment('C9', comment, :start_row => 8, :start_col => 4)
189
+ worksheet5.write_comment('C9', comment, start_row: 8, start_col: 4)
190
190
 
191
191
  cell_text = 'This cell comment has been shifted within its default cell.'
192
192
 
193
193
  comment = 'Hello.'
194
194
 
195
195
  worksheet5.write('C12', cell_text, text_wrap)
196
- worksheet5.write_comment('C12', comment, :x_offset => 30, :y_offset => 12)
196
+ worksheet5.write_comment('C12', comment, x_offset: 30, y_offset: 12)
197
197
 
198
198
  ###############################################################################
199
199
  #
@@ -212,7 +212,7 @@ cell_text = 'This cell comment has a different colour.'
212
212
  comment = 'Hello.'
213
213
 
214
214
  worksheet6.write('C3', cell_text, text_wrap)
215
- worksheet6.write_comment('C3', comment, :color => 'green')
215
+ worksheet6.write_comment('C3', comment, color: 'green')
216
216
 
217
217
  cell_text = 'This cell comment has the default colour.'
218
218
 
@@ -226,7 +226,7 @@ cell_text = 'This cell comment has a different colour.'
226
226
  comment = 'Hello.'
227
227
 
228
228
  worksheet6.write('C9', cell_text, text_wrap)
229
- worksheet6.write_comment('C9', comment, :color => '#FF6600')
229
+ worksheet6.write_comment('C9', comment, color: '#FF6600')
230
230
 
231
231
  ###############################################################################
232
232
  #
@@ -257,7 +257,7 @@ cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
257
257
  comment = 'Hello.'
258
258
 
259
259
  worksheet7.write(cell, cell_text, text_wrap)
260
- worksheet7.write_comment(cell, comment, :author => author)
260
+ worksheet7.write_comment(cell, comment, author: author)
261
261
 
262
262
  author = '€'
263
263
  cell = 'C9'
@@ -266,7 +266,7 @@ cell_text = "Move the mouse over this cell and you will see 'Cell commented " +
266
266
  comment = 'Hello.'
267
267
 
268
268
  worksheet7.write(cell, cell_text, text_wrap)
269
- worksheet7.write_comment(cell, comment, :author => author)
269
+ worksheet7.write_comment(cell, comment, author: author)
270
270
 
271
271
  ###############################################################################
272
272
  #