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
data/examples/formats.rb
CHANGED
@@ -18,8 +18,8 @@ require 'write_xlsx'
|
|
18
18
|
workbook = WriteXLSX.new('formats.xlsx')
|
19
19
|
|
20
20
|
# Some common formats
|
21
|
-
center = workbook.add_format(:
|
22
|
-
heading = workbook.add_format(:
|
21
|
+
center = workbook.add_format(align: 'center')
|
22
|
+
heading = workbook.add_format(align: 'center', bold: 1)
|
23
23
|
|
24
24
|
# The named colors
|
25
25
|
colors = {
|
@@ -61,8 +61,8 @@ def intro(workbook, _center, _heading, _colors)
|
|
61
61
|
format2.set_color('blue')
|
62
62
|
|
63
63
|
format3 = workbook.add_format(
|
64
|
-
:
|
65
|
-
:
|
64
|
+
color: 'blue',
|
65
|
+
underline: 1
|
66
66
|
)
|
67
67
|
|
68
68
|
worksheet.write(2, 0, 'This workbook demonstrates some of', format)
|
@@ -113,9 +113,9 @@ def named_colors(workbook, center, heading, colors)
|
|
113
113
|
[33, 11, 53, 17, 22, 18, 13, 16, 23, 9, 12, 15, 14, 20, 8, 10].each do |index|
|
114
114
|
color = colors[index]
|
115
115
|
format = workbook.add_format(
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
116
|
+
bg_color: color,
|
117
|
+
pattern: 1,
|
118
|
+
border: 1
|
119
119
|
)
|
120
120
|
|
121
121
|
worksheet.write(i + 1, 0, index, center)
|
@@ -142,9 +142,9 @@ def standard_colors(workbook, center, heading, colors)
|
|
142
142
|
|
143
143
|
(8..63).each do |i|
|
144
144
|
format = workbook.add_format(
|
145
|
-
:
|
146
|
-
:
|
147
|
-
:
|
145
|
+
bg_color: i,
|
146
|
+
pattern: 1,
|
147
|
+
border: 1
|
148
148
|
)
|
149
149
|
|
150
150
|
worksheet.write((i - 7), 0, i, center)
|
data/examples/hyperlink1.rb
CHANGED
@@ -24,10 +24,10 @@ worksheet.set_selection('B1')
|
|
24
24
|
|
25
25
|
# Add a sample format.
|
26
26
|
red_format = workbook.add_format(
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
27
|
+
color: 'red',
|
28
|
+
bold: 1,
|
29
|
+
underline: 1,
|
30
|
+
size: 12
|
31
31
|
)
|
32
32
|
|
33
33
|
# Add an alternate description string to the URL.
|
data/examples/ignore_errors.rb
CHANGED
@@ -25,8 +25,8 @@ worksheet.write_formula('C6', '=1/0')
|
|
25
25
|
|
26
26
|
# Turn off some of the warnings:
|
27
27
|
worksheet.ignore_errors(
|
28
|
-
:
|
29
|
-
:
|
28
|
+
number_stored_as_text: 'C3',
|
29
|
+
eval_error: 'C6'
|
30
30
|
)
|
31
31
|
|
32
32
|
# Write some descriptions for the cells and make the column wider for clarity.
|
data/examples/indent.rb
CHANGED
@@ -16,8 +16,8 @@ require 'write_xlsx'
|
|
16
16
|
workbook = WriteXLSX.new('indent.xlsx')
|
17
17
|
|
18
18
|
worksheet = workbook.add_worksheet
|
19
|
-
indent1 = workbook.add_format(:
|
20
|
-
indent2 = workbook.add_format(:
|
19
|
+
indent1 = workbook.add_format(indent: 1)
|
20
|
+
indent2 = workbook.add_format(indent: 2)
|
21
21
|
|
22
22
|
worksheet.set_column('A:A', 40)
|
23
23
|
|
data/examples/macros.rb
CHANGED
@@ -32,10 +32,10 @@ worksheet.write('A3', 'Press the button to say hello.')
|
|
32
32
|
# Add a button tied to a macro in the VBA project.
|
33
33
|
worksheet.insert_button(
|
34
34
|
'B3',
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
35
|
+
macro: 'say_hello',
|
36
|
+
caption: 'Press Me',
|
37
|
+
width: 80,
|
38
|
+
height: 30
|
39
39
|
)
|
40
40
|
|
41
41
|
workbook.close
|
data/examples/merge1.rb
CHANGED
@@ -24,7 +24,7 @@ worksheet.set_column('B:D', 20)
|
|
24
24
|
worksheet.set_row(2, 30)
|
25
25
|
|
26
26
|
# Create a merge format
|
27
|
-
format = workbook.add_format(:
|
27
|
+
format = workbook.add_format(center_across: 1)
|
28
28
|
|
29
29
|
# Only one cell should contain text, the others should be blank.
|
30
30
|
worksheet.write(2, 1, "Center across selection", format)
|
data/examples/merge2.rb
CHANGED
@@ -26,15 +26,15 @@ worksheet.set_row(2, 40)
|
|
26
26
|
|
27
27
|
# Create a merged format
|
28
28
|
format = workbook.add_format(
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
29
|
+
center_across: 1,
|
30
|
+
bold: 1,
|
31
|
+
size: 15,
|
32
|
+
pattern: 1,
|
33
|
+
border: 6,
|
34
|
+
color: 'white',
|
35
|
+
fg_color: 'green',
|
36
|
+
border_color: 'yellow',
|
37
|
+
align: 'vcenter'
|
38
38
|
)
|
39
39
|
|
40
40
|
# Only one cell should contain text, the others should be blank.
|
data/examples/merge3.rb
CHANGED
@@ -25,11 +25,11 @@ worksheet.set_column('B:D', 20)
|
|
25
25
|
# Example: Merge cells containing a hyperlink using merge_range().
|
26
26
|
#
|
27
27
|
format = workbook.add_format(
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
28
|
+
border: 1,
|
29
|
+
underline: 1,
|
30
|
+
color: 'blue',
|
31
|
+
align: 'center',
|
32
|
+
valign: 'vcenter'
|
33
33
|
)
|
34
34
|
|
35
35
|
# Merge 3 cells
|
data/examples/merge4.rb
CHANGED
@@ -25,11 +25,11 @@ worksheet.set_column('B:D', 20)
|
|
25
25
|
# Example 1: Text centered vertically and horizontally
|
26
26
|
#
|
27
27
|
format1 = workbook.add_format(
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
28
|
+
border: 6,
|
29
|
+
bold: 1,
|
30
|
+
color: 'red',
|
31
|
+
valign: 'vcenter',
|
32
|
+
align: 'center'
|
33
33
|
)
|
34
34
|
|
35
35
|
worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
|
@@ -39,11 +39,11 @@ worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
|
|
39
39
|
# Example 2: Text aligned to the top and left
|
40
40
|
#
|
41
41
|
format2 = workbook.add_format(
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
42
|
+
border: 6,
|
43
|
+
bold: 1,
|
44
|
+
color: 'red',
|
45
|
+
valign: 'top',
|
46
|
+
align: 'left'
|
47
47
|
)
|
48
48
|
|
49
49
|
worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
|
@@ -53,11 +53,11 @@ worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
|
|
53
53
|
# Example 3: Text aligned to the bottom and right
|
54
54
|
#
|
55
55
|
format3 = workbook.add_format(
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
56
|
+
border: 6,
|
57
|
+
bold: 1,
|
58
|
+
color: 'red',
|
59
|
+
valign: 'bottom',
|
60
|
+
align: 'right'
|
61
61
|
)
|
62
62
|
|
63
63
|
worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
|
@@ -67,11 +67,11 @@ worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
|
|
67
67
|
# Example 4: Text justified (i.e. wrapped) in the cell
|
68
68
|
#
|
69
69
|
format4 = workbook.add_format(
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
70
|
+
border: 6,
|
71
|
+
bold: 1,
|
72
|
+
color: 'red',
|
73
|
+
valign: 'top',
|
74
|
+
align: 'justify'
|
75
75
|
)
|
76
76
|
|
77
77
|
worksheet.merge_range('B11:D12', 'Justified: ' << ('so on and ' * 18), format4)
|
data/examples/merge5.rb
CHANGED
@@ -26,12 +26,12 @@ worksheet = workbook.add_worksheet
|
|
26
26
|
# Rotation 1, letters run from top to bottom
|
27
27
|
#
|
28
28
|
format1 = workbook.add_format(
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
29
|
+
border: 6,
|
30
|
+
bold: 1,
|
31
|
+
color: 'red',
|
32
|
+
valign: 'vcentre',
|
33
|
+
align: 'centre',
|
34
|
+
rotation: 270
|
35
35
|
)
|
36
36
|
|
37
37
|
worksheet.merge_range('B4:B9', 'Rotation 270', format1)
|
@@ -41,12 +41,12 @@ worksheet.merge_range('B4:B9', 'Rotation 270', format1)
|
|
41
41
|
# Rotation 2, 90ー anticlockwise
|
42
42
|
#
|
43
43
|
format2 = workbook.add_format(
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
44
|
+
border: 6,
|
45
|
+
bold: 1,
|
46
|
+
color: 'red',
|
47
|
+
valign: 'vcentre',
|
48
|
+
align: 'centre',
|
49
|
+
rotation: 90
|
50
50
|
)
|
51
51
|
|
52
52
|
worksheet.merge_range('D4:D9', 'Rotation 90', format2)
|
@@ -56,12 +56,12 @@ worksheet.merge_range('D4:D9', 'Rotation 90', format2)
|
|
56
56
|
# Rotation 3, 90ー clockwise
|
57
57
|
#
|
58
58
|
format3 = workbook.add_format(
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
59
|
+
border: 6,
|
60
|
+
bold: 1,
|
61
|
+
color: 'red',
|
62
|
+
valign: 'vcentre',
|
63
|
+
align: 'centre',
|
64
|
+
rotation: -90
|
65
65
|
)
|
66
66
|
|
67
67
|
worksheet.merge_range('F4:F9', 'Rotation -90', format3)
|
data/examples/merge6.rb
CHANGED
@@ -22,13 +22,13 @@ worksheet.set_column('B:D', 25)
|
|
22
22
|
|
23
23
|
# Format for the merged cells.
|
24
24
|
format = workbook.add_format(
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
25
|
+
border: 6,
|
26
|
+
bold: 1,
|
27
|
+
color: 'red',
|
28
|
+
size: 20,
|
29
|
+
valign: 'vcentre',
|
30
|
+
align: 'left',
|
31
|
+
indent: 1
|
32
32
|
)
|
33
33
|
|
34
34
|
###############################################################################
|
data/examples/outline.rb
CHANGED
@@ -74,7 +74,7 @@ worksheet3 = workbook.add_worksheet('Outline Columns')
|
|
74
74
|
worksheet4 = workbook.add_worksheet('Outline levels')
|
75
75
|
|
76
76
|
# Add a general format
|
77
|
-
bold = workbook.add_format(:
|
77
|
+
bold = workbook.add_format(bold: 1)
|
78
78
|
|
79
79
|
###############################################################################
|
80
80
|
#
|
@@ -24,7 +24,7 @@ worksheet5 = workbook.add_worksheet('Outline Columns')
|
|
24
24
|
worksheet6 = workbook.add_worksheet('Collapsed Columns')
|
25
25
|
|
26
26
|
# Add a general format
|
27
|
-
bold = workbook.add_format(:
|
27
|
+
bold = workbook.add_format(bold: 1)
|
28
28
|
|
29
29
|
###############################################################################
|
30
30
|
#
|
data/examples/panes.rb
CHANGED
@@ -37,12 +37,12 @@ worksheet4.split_panes(15, 8.43) # 1 row and column
|
|
37
37
|
#
|
38
38
|
|
39
39
|
header = workbook.add_format(
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
40
|
+
align: 'center',
|
41
|
+
valign: 'vcenter',
|
42
|
+
fg_color: '#C3FFC0'
|
43
43
|
)
|
44
44
|
|
45
|
-
center = workbook.add_format(:
|
45
|
+
center = workbook.add_format(align: 'center')
|
46
46
|
|
47
47
|
#######################################################################
|
48
48
|
#
|
data/examples/properties.rb
CHANGED
@@ -15,15 +15,15 @@ workbook = WriteXLSX.new('properties.xlsx')
|
|
15
15
|
worksheet = workbook.add_worksheet
|
16
16
|
|
17
17
|
workbook.set_properties(
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
18
|
+
title: 'This is an example spreadsheet',
|
19
|
+
subject: 'With document properties',
|
20
|
+
author: 'John McNamara',
|
21
|
+
manager: 'Dr. Heinz Doofenshmirtz',
|
22
|
+
company: 'of Wolves',
|
23
|
+
category: 'Example spreadsheets',
|
24
|
+
keywords: 'Sample, Example, Properties',
|
25
|
+
comments: 'Created with Perl and Excel::Writer::XLSX',
|
26
|
+
status: 'Quo'
|
27
27
|
)
|
28
28
|
|
29
29
|
worksheet.set_column('A:A', 70)
|
data/examples/protection.rb
CHANGED
@@ -7,8 +7,8 @@ workbook = WriteXLSX.new('protection.xlsx')
|
|
7
7
|
worksheet = workbook.add_worksheet
|
8
8
|
|
9
9
|
# Create some format objects
|
10
|
-
unlocked = workbook.add_format(:
|
11
|
-
hidden = workbook.add_format(:
|
10
|
+
unlocked = workbook.add_format(locked: 0)
|
11
|
+
hidden = workbook.add_format(hidden: 1)
|
12
12
|
|
13
13
|
# Format the columns
|
14
14
|
worksheet.set_column('A:A', 45)
|
data/examples/rich_strings.rb
CHANGED
@@ -18,12 +18,12 @@ worksheet = workbook.add_worksheet
|
|
18
18
|
worksheet.set_column('A:A', 30)
|
19
19
|
|
20
20
|
# Set some formats to use.
|
21
|
-
bold = workbook.add_format(:
|
22
|
-
italic = workbook.add_format(:
|
23
|
-
red = workbook.add_format(:
|
24
|
-
blue = workbook.add_format(:
|
25
|
-
center = workbook.add_format(:
|
26
|
-
superc = workbook.add_format(:
|
21
|
+
bold = workbook.add_format(bold: 1)
|
22
|
+
italic = workbook.add_format(italic: 1)
|
23
|
+
red = workbook.add_format(color: 'red')
|
24
|
+
blue = workbook.add_format(color: 'blue')
|
25
|
+
center = workbook.add_format(align: 'center')
|
26
|
+
superc = workbook.add_format(font_script: 1)
|
27
27
|
|
28
28
|
# Write some strings with multiple formats.
|
29
29
|
worksheet.write_rich_string(
|
data/examples/shape1.rb
CHANGED
@@ -17,18 +17,18 @@ worksheet = workbook.add_worksheet
|
|
17
17
|
|
18
18
|
# Add a circle, with centered text.
|
19
19
|
ellipse = workbook.add_shape(
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
20
|
+
type: 'ellipse',
|
21
|
+
text: "Hello\nWorld",
|
22
|
+
width: 60,
|
23
|
+
height: 60
|
24
24
|
)
|
25
25
|
worksheet.insert_shape('A1', ellipse, 50, 50)
|
26
26
|
|
27
27
|
# Add a plus sign.
|
28
28
|
plus = workbook.add_shape(
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
29
|
+
type: 'plus',
|
30
|
+
width: 20,
|
31
|
+
height: 20
|
32
32
|
)
|
33
33
|
worksheet.insert_shape('D8', plus)
|
34
34
|
|
data/examples/shape2.rb
CHANGED
@@ -18,15 +18,15 @@ worksheet = workbook.add_worksheet
|
|
18
18
|
worksheet.hide_gridlines(2)
|
19
19
|
|
20
20
|
plain = workbook.add_shape(
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
21
|
+
type: 'smileyFace',
|
22
|
+
text: "Plain",
|
23
|
+
width: 100,
|
24
|
+
height: 100
|
25
25
|
)
|
26
26
|
|
27
27
|
bbformat = workbook.add_format(
|
28
|
-
:
|
29
|
-
:
|
28
|
+
color: 'red',
|
29
|
+
font: 'Lucida Calligraphy'
|
30
30
|
)
|
31
31
|
|
32
32
|
bbformat.set_bold
|
@@ -34,16 +34,16 @@ bbformat.set_underline
|
|
34
34
|
bbformat.set_italic
|
35
35
|
|
36
36
|
decor = workbook.add_shape(
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
37
|
+
type: 'smileyFace',
|
38
|
+
text: 'Decorated',
|
39
|
+
rotation: 45,
|
40
|
+
width: 200,
|
41
|
+
height: 100,
|
42
|
+
format: bbformat,
|
43
|
+
line_type: 'sysDot',
|
44
|
+
line_weight: 3,
|
45
|
+
fill: 'FFFF00',
|
46
|
+
line: '3366FF'
|
47
47
|
)
|
48
48
|
|
49
49
|
worksheet.insert_shape('A1', plain, 50, 50)
|
data/examples/shape3.rb
CHANGED
@@ -16,11 +16,11 @@ workbook = WriteXLSX.new('shape3.xlsx')
|
|
16
16
|
worksheet = workbook.add_worksheet
|
17
17
|
|
18
18
|
normal = workbook.add_shape(
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
19
|
+
name: 'chip',
|
20
|
+
type: 'diamond',
|
21
|
+
text: 'Normal',
|
22
|
+
width: 100,
|
23
|
+
height: 100
|
24
24
|
)
|
25
25
|
|
26
26
|
worksheet.insert_shape('A1', normal, 50, 50)
|
data/examples/shape4.rb
CHANGED
@@ -19,9 +19,9 @@ worksheet.hide_gridlines(2)
|
|
19
19
|
|
20
20
|
type = 'rect'
|
21
21
|
shape = workbook.add_shape(
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
22
|
+
type: type,
|
23
|
+
width: 90,
|
24
|
+
height: 90
|
25
25
|
)
|
26
26
|
|
27
27
|
(1..10).each do |n|
|
@@ -34,10 +34,10 @@ shape = workbook.add_shape(
|
|
34
34
|
end
|
35
35
|
|
36
36
|
stencil = workbook.add_shape(
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
37
|
+
stencil: 1, # The default.
|
38
|
+
width: 90,
|
39
|
+
height: 90,
|
40
|
+
text: 'started as a box'
|
41
41
|
)
|
42
42
|
worksheet.insert_shape('A1', stencil, 100, 150)
|
43
43
|
|
data/examples/shape5.rb
CHANGED
@@ -16,21 +16,21 @@ workbook = WriteXLSX.new('shape5.xlsx')
|
|
16
16
|
worksheet = workbook.add_worksheet
|
17
17
|
|
18
18
|
s1 = workbook.add_shape(
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
19
|
+
type: 'ellipse',
|
20
|
+
width: 60,
|
21
|
+
height: 60
|
22
22
|
)
|
23
23
|
worksheet.insert_shape('A1', s1, 50, 50)
|
24
24
|
|
25
25
|
s2 = workbook.add_shape(
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
26
|
+
type: 'plus',
|
27
|
+
width: 20,
|
28
|
+
height: 20
|
29
29
|
)
|
30
30
|
worksheet.insert_shape('A1', s2, 250, 200)
|
31
31
|
|
32
32
|
# Create a connector to link the two shapes.
|
33
|
-
cxn_shape = workbook.add_shape(:
|
33
|
+
cxn_shape = workbook.add_shape(type: 'bentConnector3')
|
34
34
|
|
35
35
|
# Link the start of the connector to the right side.
|
36
36
|
cxn_shape.start = s1.id
|
data/examples/shape6.rb
CHANGED
@@ -16,21 +16,21 @@ workbook = WriteXLSX.new('shape6.xlsx')
|
|
16
16
|
worksheet = workbook.add_worksheet
|
17
17
|
|
18
18
|
s1 = workbook.add_shape(
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
19
|
+
type: 'chevron',
|
20
|
+
width: 60,
|
21
|
+
height: 60
|
22
22
|
)
|
23
23
|
worksheet.insert_shape('A1', s1, 50, 50)
|
24
24
|
|
25
25
|
s2 = workbook.add_shape(
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
26
|
+
type: 'pentagon',
|
27
|
+
width: 20,
|
28
|
+
height: 20
|
29
29
|
)
|
30
30
|
worksheet.insert_shape('A1', s2, 250, 200)
|
31
31
|
|
32
32
|
# Create a connector to link the two shapes.
|
33
|
-
cxn_shape = workbook.add_shape(:
|
33
|
+
cxn_shape = workbook.add_shape(type: 'curvedConnector3')
|
34
34
|
|
35
35
|
# Link the start of the connector to the right side.
|
36
36
|
cxn_shape.start = s1.id
|
data/examples/shape7.rb
CHANGED
@@ -22,11 +22,11 @@ cx = 210
|
|
22
22
|
cy = 190
|
23
23
|
|
24
24
|
ellipse = workbook.add_shape(
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
25
|
+
type: 'ellipse',
|
26
|
+
id: 2,
|
27
|
+
text: "Hello\nWorld",
|
28
|
+
width: cw,
|
29
|
+
height: ch
|
30
30
|
)
|
31
31
|
worksheet.insert_shape('A1', ellipse, cx, cy)
|
32
32
|
|
@@ -37,10 +37,10 @@ px = 120
|
|
37
37
|
py = 250
|
38
38
|
|
39
39
|
plus = workbook.add_shape(
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
40
|
+
type: 'plus',
|
41
|
+
id: 3,
|
42
|
+
width: pw,
|
43
|
+
height: ph
|
44
44
|
)
|
45
45
|
|
46
46
|
p1 = worksheet.insert_shape('A1', plus, 350, 350)
|
@@ -49,7 +49,7 @@ p3 = worksheet.insert_shape('A1', plus, 350, 150)
|
|
49
49
|
plus.adjustments = 35 # change shape of plus symbol.
|
50
50
|
p4 = worksheet.insert_shape('A1', plus, 150, 150)
|
51
51
|
|
52
|
-
cxn_shape = workbook.add_shape(:
|
52
|
+
cxn_shape = workbook.add_shape(type: 'bentConnector3', fill: 0)
|
53
53
|
|
54
54
|
cxn_shape.start = ellipse.id
|
55
55
|
cxn_shape.start_index = 4 # 4th connection pt, clockwise from top(0).
|