write_xlsx 1.10.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/Changes +3 -0
- data/README.md +1 -1
- data/examples/autofilter.rb +1 -1
- data/examples/chart_area.rb +12 -12
- data/examples/chart_bar.rb +12 -12
- data/examples/chart_clustered.rb +12 -12
- data/examples/chart_column.rb +12 -12
- data/examples/chart_combined.rb +25 -25
- data/examples/chart_data_labels.rb +99 -99
- data/examples/chart_data_table.rb +25 -25
- data/examples/chart_data_tools.rb +50 -50
- data/examples/chart_doughnut.rb +29 -29
- data/examples/chart_gauge.rb +18 -18
- data/examples/chart_line.rb +32 -32
- data/examples/chart_pareto.rb +16 -16
- data/examples/chart_pie.rb +17 -17
- data/examples/chart_radar.rb +38 -38
- data/examples/chart_scatter.rb +12 -12
- data/examples/chart_secondary_axis.rb +13 -13
- data/examples/chart_stock.rb +12 -12
- data/examples/chart_styles.rb +5 -5
- data/examples/colors.rb +11 -11
- data/examples/comments2.rb +15 -15
- data/examples/conditional_format.rb +74 -74
- data/examples/data_validate.rb +64 -64
- data/examples/date_time.rb +3 -3
- data/examples/demo.rb +14 -14
- data/examples/diag_border.rb +6 -6
- data/examples/dynamic_arrays.rb +2 -2
- data/examples/formats.rb +10 -10
- data/examples/hyperlink1.rb +4 -4
- data/examples/ignore_errors.rb +2 -2
- data/examples/indent.rb +2 -2
- data/examples/macros.rb +4 -4
- data/examples/merge1.rb +1 -1
- data/examples/merge2.rb +9 -9
- data/examples/merge3.rb +5 -5
- data/examples/merge4.rb +20 -20
- data/examples/merge5.rb +18 -18
- data/examples/merge6.rb +7 -7
- data/examples/outline.rb +1 -1
- data/examples/outline_collapsed.rb +1 -1
- data/examples/panes.rb +4 -4
- data/examples/properties.rb +9 -9
- data/examples/protection.rb +2 -2
- data/examples/rich_strings.rb +6 -6
- data/examples/shape1.rb +7 -7
- data/examples/shape2.rb +16 -16
- data/examples/shape3.rb +5 -5
- data/examples/shape4.rb +7 -7
- data/examples/shape5.rb +7 -7
- data/examples/shape6.rb +7 -7
- data/examples/shape7.rb +10 -10
- data/examples/shape8.rb +10 -10
- data/examples/shape_all.rb +4 -4
- data/examples/sparklines1.rb +11 -11
- data/examples/sparklines2.rb +76 -76
- data/examples/tables.rb +87 -87
- data/examples/watermark.rb +1 -1
- data/lib/write_xlsx/chart/bar.rb +4 -4
- data/lib/write_xlsx/chart/line.rb +1 -1
- data/lib/write_xlsx/chart/radar.rb +2 -2
- data/lib/write_xlsx/chart/scatter.rb +4 -4
- data/lib/write_xlsx/chart/series.rb +27 -27
- data/lib/write_xlsx/chart/stock.rb +5 -5
- data/lib/write_xlsx/chart.rb +30 -30
- data/lib/write_xlsx/colors.rb +19 -19
- data/lib/write_xlsx/package/conditional_format.rb +3 -3
- data/lib/write_xlsx/package/table.rb +8 -8
- data/lib/write_xlsx/shape.rb +5 -5
- data/lib/write_xlsx/sheets.rb +1 -1
- data/lib/write_xlsx/sparkline.rb +286 -286
- data/lib/write_xlsx/utility.rb +23 -23
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +20 -20
- data/lib/write_xlsx/worksheet/cell_data.rb +1 -1
- data/lib/write_xlsx/worksheet.rb +28 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66e9354b51872770af7121d5581615b53c0cb3b7e86c221b0ecee60fe54dae4b
|
4
|
+
data.tar.gz: 97d6ae9ed6dee9e57e98981e105da155ef405fd5ea40ea17e8057871f02d90d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
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
|
8
|
+
[Excel::Writer::XLSX](https://github.com/jmcnamara/excel-writer-xlsx)
|
9
9
|
|
10
10
|
## Description
|
11
11
|
|
data/examples/autofilter.rb
CHANGED
@@ -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(:
|
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
|
data/examples/chart_area.rb
CHANGED
@@ -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(:
|
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(:
|
30
|
+
chart = workbook.add_chart(type: 'area', embedded: 1)
|
31
31
|
|
32
32
|
# Configure the first series.
|
33
33
|
chart.add_series(
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
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
|
-
:
|
43
|
-
:
|
44
|
-
:
|
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(:
|
49
|
-
chart.set_x_axis(:
|
50
|
-
chart.set_y_axis(:
|
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
|
-
:
|
58
|
+
x_offset: 25, y_offset: 10
|
59
59
|
)
|
60
60
|
|
61
61
|
workbook.close
|
data/examples/chart_bar.rb
CHANGED
@@ -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(:
|
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(:
|
30
|
+
chart = workbook.add_chart(type: 'bar', embedded: 1)
|
31
31
|
|
32
32
|
# Configure the first series.
|
33
33
|
chart.add_series(
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
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
|
-
:
|
43
|
-
:
|
44
|
-
:
|
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(:
|
49
|
-
chart.set_x_axis(:
|
50
|
-
chart.set_y_axis(:
|
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
|
-
:
|
58
|
+
x_offset: 25, y_offset: 10
|
59
59
|
)
|
60
60
|
|
61
61
|
workbook.close
|
data/examples/chart_clustered.rb
CHANGED
@@ -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(:
|
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(:
|
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
|
-
:
|
38
|
-
:
|
39
|
-
:
|
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
|
-
:
|
44
|
-
:
|
45
|
-
:
|
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
|
-
:
|
50
|
-
:
|
51
|
-
:
|
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(:
|
58
|
+
chart.set_legend(position: 'none')
|
59
59
|
|
60
60
|
# Insert the chart into the worksheet.
|
61
61
|
worksheet.insert_chart('G3', chart)
|
data/examples/chart_column.rb
CHANGED
@@ -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(:
|
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(:
|
30
|
+
chart = workbook.add_chart(type: 'column', embedded: 1)
|
31
31
|
|
32
32
|
# Configure the first series.
|
33
33
|
chart.add_series(
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
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
|
-
:
|
43
|
-
:
|
44
|
-
:
|
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(:
|
49
|
-
chart.set_x_axis(:
|
50
|
-
chart.set_y_axis(:
|
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
|
-
:
|
58
|
+
x_offset: 25, y_offset: 10
|
59
59
|
)
|
60
60
|
|
61
61
|
workbook.close
|
data/examples/chart_combined.rb
CHANGED
@@ -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(:
|
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(:
|
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
|
-
:
|
40
|
-
:
|
41
|
-
:
|
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(:
|
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
|
-
:
|
50
|
-
:
|
51
|
-
:
|
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(:
|
60
|
-
column_chart1.set_x_axis(:
|
61
|
-
column_chart1.set_y_axis(:
|
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(:
|
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
|
-
:
|
77
|
-
:
|
78
|
-
:
|
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(:
|
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
|
-
:
|
89
|
-
:
|
90
|
-
:
|
91
|
-
:
|
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(:
|
99
|
-
column_chart2.set_x_axis(:
|
100
|
-
column_chart2.set_y_axis(:
|
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(:
|
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)
|