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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a6aa71ba6c2a27f86f844a1313cd1983f0b5e54e94fb944b3e2fbf31b089437
4
- data.tar.gz: 901aadf4eb4bd06ad95377b5d9de33ccc13850299e223453c0e544addcb26a1f
3
+ metadata.gz: 66e9354b51872770af7121d5581615b53c0cb3b7e86c221b0ecee60fe54dae4b
4
+ data.tar.gz: 97d6ae9ed6dee9e57e98981e105da155ef405fd5ea40ea17e8057871f02d90d9
5
5
  SHA512:
6
- metadata.gz: 94101fe3a84563a842fe9989ca162d29aee8dbb1944feb8bd8dbd3c5ee459b3956fb46ccb251ee28e099efd852f9142d3040b5f896b67440e4a5c7b54895d4a9
7
- data.tar.gz: 8cbd76084fd2276cf02eaff6dc58de57b60b8de991677020aa7634b637f2ec7a0f28b4fb9379483e025572cb5f0cc0070682cfc2eb353b97df118f700e843ae9
6
+ metadata.gz: a86f539563acd7da100be9fb11e1e3da99c1985200e21eaa91ca9db3f69ea130038f0ecead40ea0ba6efcc5b4f433dcd4acf039006faa65adb60ed88d0d5f005
7
+ data.tar.gz: f98a3ac1110600e8e2c578127f85a804c1237d44069481f6c0baacc27ff6f21eddbb96f063c544239730ba059a16f7637f39ebfd902f3cc87be4995401bf303b
data/.rubocop.yml CHANGED
@@ -90,7 +90,8 @@ Style/FormatStringToken:
90
90
  EnforcedStyle: unannotated
91
91
 
92
92
  Style/HashSyntax:
93
- Enabled: false
93
+ EnforceStyle: ruby19_no_mixed_keys
94
+ EnforcedShorthandSyntax: either
94
95
 
95
96
  Style/NumericLiterals:
96
97
  MinDigits: 10
@@ -101,6 +102,9 @@ Style/OptionalBooleanParameter:
101
102
  Style/RaiseArgs:
102
103
  Enabled: false
103
104
 
105
+ Style/SlicingWithRange:
106
+ Enabled: false
107
+
104
108
  Style/StringLiterals:
105
109
  Enabled: false
106
110
 
data/Changes CHANGED
@@ -1,5 +1,8 @@
1
1
  Change history of write_xlsx rubygem.
2
2
 
3
+ 2023-01-31 v1.10.1
4
+ Fixed PR #99. Remove range [1..] style to work on Ruby 2.5.
5
+
3
6
  2023-01-29 v.1.10.0
4
7
  Ruby version 2.5.0 or later are required.
5
8
 
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  gem to create a new file in the Excel 2007+ XLSX format, and you can use the
7
7
  same interface as writeexcel gem. write_xlsx is converted from Perl's module
8
- [Excel::Writer::XLSX-1.09](https://github.com/jmcnamara/excel-writer-xlsx/tree/CPAN_1.09)
8
+ [Excel::Writer::XLSX](https://github.com/jmcnamara/excel-writer-xlsx)
9
9
 
10
10
  ## Description
11
11
 
@@ -24,7 +24,7 @@ worksheet5 = workbook.add_worksheet
24
24
  worksheet6 = workbook.add_worksheet
25
25
  worksheet7 = workbook.add_worksheet
26
26
 
27
- bold = workbook.add_format(:bold => 1)
27
+ bold = workbook.add_format(bold: 1)
28
28
 
29
29
  # Extract the data embedded at the end of this file.
30
30
  headings = DATA.gets.split
@@ -13,7 +13,7 @@ require 'write_xlsx'
13
13
 
14
14
  workbook = WriteXLSX.new('chart_area.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 => 'area', :embedded => 1)
30
+ chart = workbook.add_chart(type: 'area', 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(11)
@@ -55,7 +55,7 @@ chart.set_style(11)
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_bar.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 => 'bar', :embedded => 1)
30
+ chart = workbook.add_chart(type: 'bar', 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(11)
@@ -55,7 +55,7 @@ chart.set_style(11)
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
@@ -12,7 +12,7 @@ require 'write_xlsx'
12
12
 
13
13
  workbook = WriteXLSX.new('chart_clustered.xlsx')
14
14
  worksheet = workbook.add_worksheet
15
- bold = workbook.add_format(:bold => 1)
15
+ bold = workbook.add_format(bold: 1)
16
16
 
17
17
  # Add the worksheet data that the charts will refer to.
18
18
  headings = ['Types', 'Sub Type', 'Value 1', 'Value 2', 'Value 3']
@@ -28,34 +28,34 @@ worksheet.write('A1', headings, bold)
28
28
  worksheet.write_col('A2', data)
29
29
 
30
30
  # Create a new chart object. In this case an embedded chart.
31
- chart = workbook.add_chart(:type => 'column', :embedded => 1)
31
+ chart = workbook.add_chart(type: 'column', embedded: 1)
32
32
 
33
33
  # Configure the series. Note, that the categories are 2D ranges (from column A
34
34
  # to column B). This creates the clusters. The series are shown as formula
35
35
  # strings for clarity but you can also use the array syntax. See the docs.
36
36
  chart.add_series(
37
- :name => '=Sheet1!$C$1',
38
- :categories => '=Sheet1!$A$2:$B$6',
39
- :values => '=Sheet1!$C$2:$C$6'
37
+ name: '=Sheet1!$C$1',
38
+ categories: '=Sheet1!$A$2:$B$6',
39
+ values: '=Sheet1!$C$2:$C$6'
40
40
  )
41
41
 
42
42
  chart.add_series(
43
- :name => '=Sheet1!$D$1',
44
- :categories => '=Sheet1!$A$2:$B$6',
45
- :values => '=Sheet1!$D$2:$D$6'
43
+ name: '=Sheet1!$D$1',
44
+ categories: '=Sheet1!$A$2:$B$6',
45
+ values: '=Sheet1!$D$2:$D$6'
46
46
  )
47
47
 
48
48
  chart.add_series(
49
- :name => '=Sheet1!$E$1',
50
- :categories => '=Sheet1!$A$2:$B$6',
51
- :values => '=Sheet1!$E$2:$E$6'
49
+ name: '=Sheet1!$E$1',
50
+ categories: '=Sheet1!$A$2:$B$6',
51
+ values: '=Sheet1!$E$2:$E$6'
52
52
  )
53
53
 
54
54
  # Set the Excel chart style.
55
55
  chart.set_style(37)
56
56
 
57
57
  # Turn off the legend.
58
- chart.set_legend(:position => 'none')
58
+ chart.set_legend(position: 'none')
59
59
 
60
60
  # Insert the chart into the worksheet.
61
61
  worksheet.insert_chart('G3', chart)
@@ -13,7 +13,7 @@ require 'write_xlsx'
13
13
 
14
14
  workbook = WriteXLSX.new('chart_column.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 => 'column', :embedded => 1)
30
+ chart = workbook.add_chart(type: 'column', 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(11)
@@ -55,7 +55,7 @@ chart.set_style(11)
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_combined.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']
@@ -32,23 +32,23 @@ worksheet.write('A2', data)
32
32
  #
33
33
 
34
34
  # Create a new column chart. This will use this as the primary chart.
35
- column_chart1 = workbook.add_chart(:type => 'column', :embedded => 1)
35
+ column_chart1 = workbook.add_chart(type: 'column', embedded: 1)
36
36
 
37
37
  # Configure the data series for the primary chart.
38
38
  column_chart1.add_series(
39
- :name => '=Sheet1!$B$1',
40
- :categories => '=Sheet1!$A$2:$A$7',
41
- :values => '=Sheet1!$B$2:$B$7'
39
+ name: '=Sheet1!$B$1',
40
+ categories: '=Sheet1!$A$2:$A$7',
41
+ values: '=Sheet1!$B$2:$B$7'
42
42
  )
43
43
 
44
44
  # Create a new column chart. This will use this as the secondary chart.
45
- line_chart1 = workbook.add_chart(:type => 'line', :embedded => 1)
45
+ line_chart1 = workbook.add_chart(type: 'line', embedded: 1)
46
46
 
47
47
  # Configure the data series for the secondary chart.
48
48
  line_chart1.add_series(
49
- :name => '=Sheet1!$C$1',
50
- :categories => '=Sheet1!$A$2:$A$7',
51
- :values => '=Sheet1!$C$2:$C$7'
49
+ name: '=Sheet1!$C$1',
50
+ categories: '=Sheet1!$A$2:$A$7',
51
+ values: '=Sheet1!$C$2:$C$7'
52
52
  )
53
53
 
54
54
  # Combine the charts.
@@ -56,9 +56,9 @@ column_chart1.combine(line_chart1)
56
56
 
57
57
  # Add a chart title and some axis labels. Note, this is done via the
58
58
  # primary chart.
59
- column_chart1.set_title(:name => 'Combined chart - same Y axis')
60
- column_chart1.set_x_axis(:name => 'Test number')
61
- column_chart1.set_y_axis(:name => 'Sample length (mm)')
59
+ column_chart1.set_title(name: 'Combined chart - same Y axis')
60
+ column_chart1.set_x_axis(name: 'Test number')
61
+ column_chart1.set_y_axis(name: 'Sample length (mm)')
62
62
 
63
63
  # Insert the chart into the worksheet
64
64
  worksheet.insert_chart('E2', column_chart1)
@@ -69,38 +69,38 @@ worksheet.insert_chart('E2', column_chart1)
69
69
  #
70
70
 
71
71
  # Create a new column chart. This will use this as the primary chart.
72
- column_chart2 = workbook.add_chart(:type => 'column', :embedded => 1)
72
+ column_chart2 = workbook.add_chart(type: 'column', embedded: 1)
73
73
 
74
74
  # Configure the data series for the primary chart.
75
75
  column_chart2.add_series(
76
- :name => '=Sheet1!$B$1',
77
- :categories => '=Sheet1!$A$2:$A$7',
78
- :values => '=Sheet1!$B$2:$B$7'
76
+ name: '=Sheet1!$B$1',
77
+ categories: '=Sheet1!$A$2:$A$7',
78
+ values: '=Sheet1!$B$2:$B$7'
79
79
  )
80
80
 
81
81
  # Create a new column chart. This will use this as the secondary chart.
82
- line_chart2 = workbook.add_chart(:type => 'line', :embedded => 1)
82
+ line_chart2 = workbook.add_chart(type: 'line', embedded: 1)
83
83
 
84
84
  # Configure the data series for the secondary chart. We also set a
85
85
  # secondary Y axis via (y2_axis). This is the only difference between
86
86
  # this and the first example, apart from the axis label below.
87
87
  line_chart2.add_series(
88
- :name => '=Sheet1!$C$1',
89
- :categories => '=Sheet1!$A$2:$A$7',
90
- :values => '=Sheet1!$C$2:$C$7',
91
- :y2_axis => 1
88
+ name: '=Sheet1!$C$1',
89
+ categories: '=Sheet1!$A$2:$A$7',
90
+ values: '=Sheet1!$C$2:$C$7',
91
+ y2_axis: 1
92
92
  )
93
93
 
94
94
  # Combine the charts.
95
95
  column_chart2.combine(line_chart2)
96
96
 
97
97
  # Add a chart title and some axis labels.
98
- column_chart2.set_title(:name => 'Combine chart - secondary Y axis')
99
- column_chart2.set_x_axis(:name => 'Test number')
100
- column_chart2.set_y_axis(:name => 'Sample length (mm)')
98
+ column_chart2.set_title(name: 'Combine chart - secondary Y axis')
99
+ column_chart2.set_x_axis(name: 'Test number')
100
+ column_chart2.set_y_axis(name: 'Sample length (mm)')
101
101
 
102
102
  # NOTE: the y2 properties are on the secondary chart.
103
- line_chart2.set_y_axis(:name => 'Target length (mm)')
103
+ line_chart2.set_y_axis(name: 'Target length (mm)')
104
104
 
105
105
  # Insert the chart into the worksheet
106
106
  worksheet.insert_chart('E18', column_chart2)