write_xlsx 0.90.0 → 0.97.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes +37 -0
- data/README.md +1 -1
- data/examples/a_simple.rb +1 -6
- data/examples/conditional_format.rb +73 -46
- data/examples/demo.rb +1 -7
- data/examples/hyperlink1.rb +4 -11
- data/lib/write_xlsx/chart.rb +81 -205
- data/lib/write_xlsx/chart/axis.rb +2 -2
- data/lib/write_xlsx/chart/caption.rb +3 -1
- data/lib/write_xlsx/chart/pie.rb +2 -0
- data/lib/write_xlsx/chart/series.rb +11 -7
- data/lib/write_xlsx/format.rb +15 -11
- data/lib/write_xlsx/package/conditional_format.rb +351 -38
- data/lib/write_xlsx/package/content_types.rb +10 -0
- data/lib/write_xlsx/package/custom.rb +125 -0
- data/lib/write_xlsx/package/packager.rb +26 -0
- data/lib/write_xlsx/package/styles.rb +53 -21
- data/lib/write_xlsx/package/table.rb +11 -4
- data/lib/write_xlsx/utility.rb +234 -34
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +88 -1
- data/lib/write_xlsx/worksheet.rb +247 -23
- data/test/helper.rb +6 -1
- data/test/regression/_test_hyperlink31.rb +26 -0
- data/test/regression/images/zero_dpi.jpg +0 -0
- data/test/regression/test_chart_bar08.rb +3 -0
- data/test/regression/test_chart_bar11.rb +3 -0
- data/test/regression/test_chart_bar14.rb +3 -0
- data/test/regression/test_chart_chartarea05.rb +16 -17
- data/test/regression/test_chart_chartarea06.rb +49 -0
- data/test/regression/test_chart_data_labels25.rb +61 -0
- data/test/regression/test_chart_format26.rb +48 -0
- data/test/regression/test_chart_format27.rb +58 -0
- data/test/regression/test_chart_format28.rb +52 -0
- data/test/regression/test_chart_format29.rb +59 -0
- data/test/regression/test_chart_format30.rb +53 -0
- data/test/regression/test_chart_format31.rb +60 -0
- data/test/regression/test_chart_table03.rb +56 -0
- data/test/regression/test_cond_format14.rb +42 -0
- data/test/regression/test_cond_format15.rb +53 -0
- data/test/regression/test_cond_format16.rb +53 -0
- data/test/regression/test_cond_format17.rb +37 -0
- data/test/regression/test_cond_format18.rb +136 -0
- data/test/regression/test_date_1904_01.rb +1 -1
- data/test/regression/test_escapes04.rb +3 -0
- data/test/regression/test_escapes05.rb +3 -0
- data/test/regression/test_escapes07.rb +3 -0
- data/test/regression/test_escapes08.rb +3 -0
- data/test/regression/test_hyperlink01.rb +3 -0
- data/test/regression/test_hyperlink02.rb +3 -0
- data/test/regression/test_hyperlink03.rb +4 -0
- data/test/regression/test_hyperlink04.rb +3 -0
- data/test/regression/test_hyperlink05.rb +3 -0
- data/test/regression/test_hyperlink06.rb +3 -0
- data/test/regression/test_hyperlink07.rb +3 -0
- data/test/regression/test_hyperlink08.rb +3 -0
- data/test/regression/test_hyperlink09.rb +3 -0
- data/test/regression/test_hyperlink10.rb +3 -0
- data/test/regression/test_hyperlink11.rb +3 -0
- data/test/regression/test_hyperlink12.rb +3 -0
- data/test/regression/test_hyperlink13.rb +3 -0
- data/test/regression/test_hyperlink14.rb +3 -0
- data/test/regression/test_hyperlink15.rb +3 -0
- data/test/regression/test_hyperlink16.rb +3 -0
- data/test/regression/test_hyperlink17.rb +3 -0
- data/test/regression/test_hyperlink18.rb +3 -0
- data/test/regression/test_hyperlink20.rb +3 -0
- data/test/regression/test_hyperlink21.rb +3 -0
- data/test/regression/test_hyperlink22.rb +3 -0
- data/test/regression/test_hyperlink23.rb +3 -0
- data/test/regression/test_hyperlink24.rb +3 -0
- data/test/regression/test_hyperlink25.rb +3 -0
- data/test/regression/test_hyperlink26.rb +3 -0
- data/test/regression/test_hyperlink27.rb +3 -0
- data/test/regression/test_hyperlink28.rb +50 -0
- data/test/regression/test_hyperlink29.rb +27 -0
- data/test/regression/test_hyperlink30.rb +36 -0
- data/test/regression/test_image35.rb +26 -0
- data/test/regression/test_properties01.rb +1 -4
- data/test/regression/test_properties02.rb +1 -4
- data/test/regression/test_properties03.rb +26 -0
- data/test/regression/test_properties04.rb +61 -0
- data/test/regression/test_properties05.rb +30 -0
- data/test/regression/test_table03.rb +3 -0
- data/test/regression/test_table04.rb +3 -0
- data/test/regression/test_table05.rb +3 -0
- data/test/regression/test_table06.rb +3 -0
- data/test/regression/test_table20.rb +34 -0
- data/test/regression/test_table21.rb +36 -0
- data/test/regression/test_table22.rb +32 -0
- data/test/regression/xlsx_files/chart_chartarea05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_chartarea06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format26.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format27.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format28.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format29.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format30.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format31.xlsx +0 -0
- data/test/regression/xlsx_files/chart_table03.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format14.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format15.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format16.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format17.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format18.xlsx +0 -0
- data/test/regression/xlsx_files/date_1904_01.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink28.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink29.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink30.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink31.xlsx +0 -0
- data/test/regression/xlsx_files/image35.xlsx +0 -0
- data/test/regression/xlsx_files/properties03.xlsx +0 -0
- data/test/regression/xlsx_files/properties04.xlsx +0 -0
- data/test/regression/xlsx_files/properties05.xlsx +0 -0
- data/test/regression/xlsx_files/table21.xlsx +0 -0
- data/test/regression/xlsx_files/table22.xlsx +0 -0
- data/test/workbook/test_write_workbook_view.rb +81 -0
- data/test/worksheet/test_cond_format_22.rb +266 -0
- data/test/worksheet/test_cond_format_23.rb +242 -0
- data/test/worksheet/test_cond_format_24.rb +303 -0
- data/test/worksheet/test_data_bar_01.rb +53 -0
- data/test/worksheet/test_data_bar_02.rb +79 -0
- data/test/worksheet/test_data_bar_03.rb +147 -0
- data/test/worksheet/test_data_bar_04.rb +145 -0
- data/test/worksheet/test_data_bar_05.rb +147 -0
- data/test/worksheet/test_data_bar_06.rb +145 -0
- data/test/worksheet/test_data_bar_07.rb +146 -0
- data/test/worksheet/test_data_bar_08.rb +54 -0
- data/test/worksheet/test_data_bar_09.rb +80 -0
- data/test/worksheet/test_data_bar_10.rb +165 -0
- data/test/worksheet/test_data_bar_11.rb +167 -0
- data/test/worksheet/test_data_bar_12.rb +104 -0
- data/test/worksheet/test_write_data_validation_02.rb +27 -0
- metadata +135 -2
data/test/helper.rb
CHANGED
@@ -22,7 +22,12 @@ class Writexlsx::Workbook
|
|
22
22
|
# Set the default index for each format. This is mainly used for testing.
|
23
23
|
#
|
24
24
|
def set_default_xf_indices #:nodoc:
|
25
|
-
|
25
|
+
# Delete the default url format.
|
26
|
+
@formats.formats.delete_at(1)
|
27
|
+
|
28
|
+
@formats.formats.each do |format|
|
29
|
+
format.get_xf_index
|
30
|
+
end
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionHyperlink31 < Minitest::Test
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
@tempfile.close(true) if @tempfile
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_hyperlink31
|
14
|
+
@xlsx = 'hyperlink31.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@io)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
format1 = workbook.add_format(:bold => 1)
|
18
|
+
|
19
|
+
worksheet.write('A1', 'Test', format1)
|
20
|
+
worksheet.write('A3', 'http://www.python.org/')
|
21
|
+
|
22
|
+
workbook.close
|
23
|
+
|
24
|
+
compare_for_regression
|
25
|
+
end
|
26
|
+
end
|
Binary file
|
@@ -24,6 +24,9 @@ def test_chart_bar11
|
|
24
24
|
[3, 6, 9, 12, 15]
|
25
25
|
]
|
26
26
|
|
27
|
+
# Turn off default URL format for testing.
|
28
|
+
worksheet.instance_variable_set(:@default_url_format, nil)
|
29
|
+
|
27
30
|
worksheet.write('A1', data)
|
28
31
|
worksheet.write('A7', 'http://www.perl.com/')
|
29
32
|
worksheet.write('A8', 'http://www.perl.org/')
|
@@ -17,30 +17,29 @@ def test_chart_chartarea05
|
|
17
17
|
chart = workbook.add_chart(:type => 'pie', :embedded => 1)
|
18
18
|
|
19
19
|
data = [
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
[ 2, 4, 6],
|
21
|
+
[60, 30, 10]
|
22
|
+
]
|
23
23
|
|
24
24
|
worksheet.write('A1', data)
|
25
25
|
|
26
26
|
chart.add_series(
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
:categories => '=Sheet1!$A$1:$A$3',
|
28
|
+
:values => '=Sheet1!$B$1:$B$3'
|
29
|
+
)
|
30
30
|
|
31
31
|
chart.set_chartarea(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# This should be ignored for a pie chart.
|
32
|
+
:border => {
|
33
|
+
:color => '#FFFF00',
|
34
|
+
:dash_type => 'long_dash'
|
35
|
+
},
|
36
|
+
:fill => { :color => '#92D050' }
|
37
|
+
)
|
38
|
+
|
40
39
|
chart.set_plotarea(
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
:border => { :dash_type => 'square_dot' },
|
41
|
+
:fill => { :color => '#FF0000' }
|
42
|
+
)
|
44
43
|
|
45
44
|
worksheet.insert_chart('E9', chart)
|
46
45
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionChartChartArea06 < Minitest::Test
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
@tempfile.close(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_chartarea06
|
14
|
+
@xlsx = 'chart_chartarea06.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@io)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'doughnut', :embedded => 1)
|
18
|
+
|
19
|
+
data = [
|
20
|
+
[ 2, 4, 6],
|
21
|
+
[60, 30, 10]
|
22
|
+
]
|
23
|
+
|
24
|
+
worksheet.write('A1', data)
|
25
|
+
|
26
|
+
chart.add_series(
|
27
|
+
:categories => '=Sheet1!$A$1:$A$3',
|
28
|
+
:values => '=Sheet1!$B$1:$B$3'
|
29
|
+
)
|
30
|
+
|
31
|
+
chart.set_chartarea(
|
32
|
+
:border => {
|
33
|
+
:color => '#FFFF00',
|
34
|
+
:dash_type => 'long_dash'
|
35
|
+
},
|
36
|
+
:fill => { :color => '#92D050' }
|
37
|
+
)
|
38
|
+
|
39
|
+
chart.set_plotarea(
|
40
|
+
:border => { :dash_type => 'square_dot' },
|
41
|
+
:fill => { :color => '#FF0000' }
|
42
|
+
)
|
43
|
+
|
44
|
+
worksheet.insert_chart('E9', chart)
|
45
|
+
|
46
|
+
workbook.close
|
47
|
+
compare_for_regression
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionChartDataLabels25 < Minitest::Test
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
@tempfile.close(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_data_labels25
|
14
|
+
@xlsx = 'chart_data_labels25.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@io)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'column', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xlsx file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [108652800, 108656128])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[1, 2, 3, 4, 5],
|
24
|
+
[2, 4, 6, 8, 10],
|
25
|
+
[3, 6, 9, 12, 15]
|
26
|
+
]
|
27
|
+
|
28
|
+
worksheet.write('A1', data)
|
29
|
+
|
30
|
+
chart.add_series(
|
31
|
+
:values => '=Sheet1!$A$1:$A$5',
|
32
|
+
:data_labels => {
|
33
|
+
:value => 1,
|
34
|
+
:position => 'outside_end',
|
35
|
+
:font => {
|
36
|
+
:rotation => 45,
|
37
|
+
:baseline => -1
|
38
|
+
}
|
39
|
+
}
|
40
|
+
)
|
41
|
+
|
42
|
+
chart.add_series(
|
43
|
+
:values => '=Sheet1!$B$1:$B$5',
|
44
|
+
:data_labels => {
|
45
|
+
:value => 1,
|
46
|
+
:position => 'inside_base',
|
47
|
+
:font => {
|
48
|
+
:rotation => -45,
|
49
|
+
:baseline => -1
|
50
|
+
}
|
51
|
+
}
|
52
|
+
)
|
53
|
+
|
54
|
+
chart.add_series(:values => '=Sheet1!$C$1:$C$5')
|
55
|
+
|
56
|
+
worksheet.insert_chart('E9', chart)
|
57
|
+
|
58
|
+
workbook.close
|
59
|
+
compare_for_regression
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionChartFormat26 < Minitest::Test
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
@tempfile.close(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_format26
|
14
|
+
@xlsx = 'chart_format26.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@io)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'line', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xlsx file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [108652416, 108655744])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[ 1, 2, 3, 4, 5 ],
|
24
|
+
[ 2, 4, 6, 8, 10 ],
|
25
|
+
[ 3, 6, 9, 12, 15 ]
|
26
|
+
]
|
27
|
+
|
28
|
+
worksheet.write('A1', data)
|
29
|
+
|
30
|
+
chart.add_series(
|
31
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
32
|
+
:values => '=Sheet1!$B$1:$B$5',
|
33
|
+
:trendline => { :type => 'linear', :display_equation => 1 }
|
34
|
+
)
|
35
|
+
|
36
|
+
chart.add_series(
|
37
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
38
|
+
:values => '=Sheet1!$C$1:$C$5'
|
39
|
+
)
|
40
|
+
|
41
|
+
chart.set_legend(:delete_series => [2, 0])
|
42
|
+
|
43
|
+
worksheet.insert_chart('E9', chart)
|
44
|
+
|
45
|
+
workbook.close
|
46
|
+
compare_for_regression
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionChartFormat27 < Minitest::Test
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
@tempfile.close(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_format27
|
14
|
+
@xlsx = 'chart_format27.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@io)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'line', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xlsx file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [108645376, 108655360])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[ 1, 2, 3, 4, 5 ],
|
24
|
+
[ 2, 4, 6, 8, 10 ],
|
25
|
+
[ 3, 6, 9, 12, 15 ]
|
26
|
+
]
|
27
|
+
|
28
|
+
worksheet.write('A1', data)
|
29
|
+
|
30
|
+
chart.add_series(
|
31
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
32
|
+
:values => '=Sheet1!$B$1:$B$5',
|
33
|
+
:trendline => {
|
34
|
+
:type => 'polynomial',
|
35
|
+
:name => 'My trend name',
|
36
|
+
:order => 2,
|
37
|
+
:forward => 0.5,
|
38
|
+
:backward => 0.5,
|
39
|
+
:display_equation => 1,
|
40
|
+
:line => {
|
41
|
+
:color => 'red',
|
42
|
+
:width => 1,
|
43
|
+
:dash_type => 'long_dash'
|
44
|
+
}
|
45
|
+
}
|
46
|
+
)
|
47
|
+
|
48
|
+
chart.add_series(
|
49
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
50
|
+
:values => '=Sheet1!$C$1:$C$5'
|
51
|
+
)
|
52
|
+
|
53
|
+
worksheet.insert_chart('E9', chart)
|
54
|
+
|
55
|
+
workbook.close
|
56
|
+
compare_for_regression
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionChartFormat28 < Minitest::Test
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
@tempfile.close(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_format28
|
14
|
+
@xlsx = 'chart_format28.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@io)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'line', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xlsx file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [108645376, 108655360])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[ 1, 2, 3, 4, 5 ],
|
24
|
+
[ 2, 4, 6, 8, 10 ],
|
25
|
+
[ 3, 6, 9, 12, 15 ]
|
26
|
+
]
|
27
|
+
|
28
|
+
worksheet.write('A1', data)
|
29
|
+
|
30
|
+
chart.add_series(
|
31
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
32
|
+
:values => '=Sheet1!$B$1:$B$5',
|
33
|
+
:trendline => {
|
34
|
+
:type => 'linear',
|
35
|
+
:display_equation => 1,
|
36
|
+
:display_r_squared => 1
|
37
|
+
}
|
38
|
+
)
|
39
|
+
|
40
|
+
chart.add_series(
|
41
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
42
|
+
:values => '=Sheet1!$C$1:$C$5'
|
43
|
+
)
|
44
|
+
|
45
|
+
chart.set_legend(:delete_series => [0, 2])
|
46
|
+
|
47
|
+
worksheet.insert_chart('E9', chart)
|
48
|
+
|
49
|
+
workbook.close
|
50
|
+
compare_for_regression
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestRegressionChartFormat29 < Minitest::Test
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
@tempfile.close(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_format29
|
14
|
+
@xlsx = 'chart_format29.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@io)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'line', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xlsx file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [108652416, 108655744])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[ 1, 2, 3, 4, 5 ],
|
24
|
+
[ 2, 4, 6, 8, 10 ],
|
25
|
+
[ 3, 6, 9, 12, 15 ]
|
26
|
+
]
|
27
|
+
|
28
|
+
worksheet.write('A1', data)
|
29
|
+
|
30
|
+
chart.add_series(
|
31
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
32
|
+
:values => '=Sheet1!$B$1:$B$5',
|
33
|
+
:trendline => {
|
34
|
+
:type => 'polynomial',
|
35
|
+
:name => 'My trend name',
|
36
|
+
:order => 2,
|
37
|
+
:forward => 0.5,
|
38
|
+
:backward => 0.5,
|
39
|
+
:display_equation => 1,
|
40
|
+
:display_r_squared => 1,
|
41
|
+
:line => {
|
42
|
+
:color => 'red',
|
43
|
+
:width => 1,
|
44
|
+
:dash_type => 'long_dash'
|
45
|
+
}
|
46
|
+
}
|
47
|
+
)
|
48
|
+
|
49
|
+
chart.add_series(
|
50
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
51
|
+
:values => '=Sheet1!$C$1:$C$5'
|
52
|
+
)
|
53
|
+
|
54
|
+
worksheet.insert_chart('E9', chart)
|
55
|
+
|
56
|
+
workbook.close
|
57
|
+
compare_for_regression
|
58
|
+
end
|
59
|
+
end
|