write_xlsx 0.77.2 → 0.78.0
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/Changes +7 -0
- data/README.md +1 -1
- data/examples/chart_doughnut.rb +131 -0
- data/lib/write_xlsx/chart.rb +4 -1
- data/lib/write_xlsx/chart/doughnut.rb +90 -0
- data/lib/write_xlsx/chart/pie.rb +16 -2
- data/lib/write_xlsx/format.rb +6 -2
- data/lib/write_xlsx/utility.rb +31 -2
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +55 -10
- data/lib/write_xlsx/worksheet.rb +32 -12
- data/lib/write_xlsx/worksheet/page_setup.rb +14 -7
- data/test/perl_output/chart_doughnut.xlsx +0 -0
- data/test/regression/test_chart_column09.rb +43 -0
- data/test/regression/test_chart_column10.rb +43 -0
- data/test/regression/test_chart_doughnut01.rb +43 -0
- data/test/regression/test_chart_doughnut02.rb +42 -0
- data/test/regression/test_chart_doughnut03.rb +42 -0
- data/test/regression/test_chart_doughnut04.rb +42 -0
- data/test/regression/test_chart_doughnut05.rb +42 -0
- data/test/regression/test_chart_doughnut06.rb +38 -0
- data/test/regression/test_chart_pie05.rb +38 -0
- data/test/regression/test_default_format01.rb +26 -0
- data/test/regression/test_excel2003_style01.rb +21 -0
- data/test/regression/test_excel2003_style02.rb +37 -0
- data/test/regression/test_excel2003_style03.rb +40 -0
- data/test/regression/test_excel2003_style04.rb +24 -0
- data/test/regression/test_excel2003_style05.rb +31 -0
- data/test/regression/test_excel2003_style06.rb +31 -0
- data/test/regression/test_excel2003_style07.rb +31 -0
- data/test/regression/test_excel2003_style08.rb +26 -0
- data/test/regression/xlsx_files/chart_column09.xlsx +0 -0
- data/test/regression/xlsx_files/chart_column10.xlsx +0 -0
- data/test/regression/xlsx_files/chart_doughnut01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_doughnut02.xlsx +0 -0
- data/test/regression/xlsx_files/chart_doughnut03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_doughnut04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_doughnut05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_doughnut06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_pie05.xlsx +0 -0
- data/test/regression/xlsx_files/default_format01.xlsx +0 -0
- data/test/regression/xlsx_files/excel2003_style01.xlsx +0 -0
- data/test/regression/xlsx_files/excel2003_style02.xlsx +0 -0
- data/test/regression/xlsx_files/excel2003_style03.xlsx +0 -0
- data/test/regression/xlsx_files/excel2003_style04.xlsx +0 -0
- data/test/regression/xlsx_files/excel2003_style05.xlsx +0 -0
- data/test/regression/xlsx_files/excel2003_style06.xlsx +0 -0
- data/test/regression/xlsx_files/excel2003_style07.xlsx +0 -0
- data/test/regression/xlsx_files/excel2003_style08.xlsx +0 -0
- data/test/test_example_match.rb +116 -0
- data/test/test_option_hash_for_workbook.rb +72 -0
- data/test/workbook/test_write_calc_pr.rb +41 -0
- data/test/worksheet/test_write_phonetic_pr.rb +1 -1
- metadata +83 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionChartDoughnut06 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_chart_doughnut06
|
|
14
|
+
@xlsx = 'chart_doughnut06.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
|
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(:values => 'Sheet1!$A$1:$A$3')
|
|
27
|
+
chart.add_series(:values => 'Sheet1!$B$1:$B$3')
|
|
28
|
+
|
|
29
|
+
worksheet.insert_chart('E9', chart)
|
|
30
|
+
|
|
31
|
+
workbook.close
|
|
32
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx),
|
|
33
|
+
@xlsx,
|
|
34
|
+
nil,
|
|
35
|
+
nil
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionChartPie05 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_chart_pie05
|
|
14
|
+
@xlsx = 'chart_pie05.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
chart = workbook.add_chart(:type => 'pie', :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_rotation(45)
|
|
32
|
+
|
|
33
|
+
worksheet.insert_chart('E9', chart)
|
|
34
|
+
|
|
35
|
+
workbook.close
|
|
36
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionDefaultFormat01 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_default_format01
|
|
14
|
+
@xlsx = 'default_format01.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :default_format_properties => { :size => 10 })
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
worksheet.set_default_row(12.75)
|
|
19
|
+
|
|
20
|
+
# Override for testing
|
|
21
|
+
worksheet.instance_variable_set(:@original_row_height, 12.75)
|
|
22
|
+
|
|
23
|
+
workbook.close
|
|
24
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionExcel2003Style01 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_excel2003_style01
|
|
14
|
+
@xlsx = 'excel2003_style01.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :excel2003_style => true)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
workbook.close
|
|
19
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionExcel2003Style02 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_excel2003_style02
|
|
14
|
+
@xlsx = 'excel2003_style02.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :excel2003_style => true)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
worksheet.paper = 9
|
|
19
|
+
|
|
20
|
+
bold = workbook.add_format(:bold => true)
|
|
21
|
+
|
|
22
|
+
worksheet.write('A1', 'Foo')
|
|
23
|
+
worksheet.write('A2', 'Bar', bold)
|
|
24
|
+
|
|
25
|
+
workbook.close
|
|
26
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
|
|
27
|
+
[
|
|
28
|
+
'xl/printerSettings/printerSettings1.bin',
|
|
29
|
+
'xl/worksheets/_rels/sheet1.xml.rels'
|
|
30
|
+
],
|
|
31
|
+
{
|
|
32
|
+
'[Content_Types].xml' => ['<Default Extension="bin"'],
|
|
33
|
+
'xl/worksheets/sheet1.xml' => ['<pageMargins']
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionExcel2003Style03 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_excel2003_style03
|
|
14
|
+
@xlsx = 'excel2003_style03.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :excel2003_style => true)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
worksheet.paper = 9
|
|
19
|
+
|
|
20
|
+
worksheet.set_header('Page &P')
|
|
21
|
+
worksheet.set_footer('&A')
|
|
22
|
+
|
|
23
|
+
bold = workbook.add_format(:bold => true)
|
|
24
|
+
|
|
25
|
+
worksheet.write('A1', 'Foo')
|
|
26
|
+
worksheet.write('A2', 'Bar', bold)
|
|
27
|
+
|
|
28
|
+
workbook.close
|
|
29
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
|
|
30
|
+
[
|
|
31
|
+
'xl/printerSettings/printerSettings1.bin',
|
|
32
|
+
'xl/worksheets/_rels/sheet1.xml.rels'
|
|
33
|
+
],
|
|
34
|
+
{
|
|
35
|
+
'[Content_Types].xml' => ['<Default Extension="bin"'],
|
|
36
|
+
'xl/worksheets/sheet1.xml' => ['<pageMargins']
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionExcel2003Style04 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_excel2003_style04
|
|
14
|
+
@xlsx = 'excel2003_style04.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :excel2003_style => true)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
worksheet.write('A1', 'Foo')
|
|
19
|
+
worksheet.set_row(0, 21)
|
|
20
|
+
|
|
21
|
+
workbook.close
|
|
22
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionExcel2003Style05 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_excel2003_style05
|
|
14
|
+
@xlsx = 'excel2003_style05.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :excel2003_style => true)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
worksheet.insert_image('B3', 'test/regression/images/red.jpg')
|
|
19
|
+
|
|
20
|
+
workbook.close
|
|
21
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
|
|
22
|
+
[],
|
|
23
|
+
{
|
|
24
|
+
'xl/drawings/drawing1.xml' =>
|
|
25
|
+
[
|
|
26
|
+
'<xdr:cNvPr', '<a:picLocks', '<a:srcRect />', '<xdr:spPr', '<a:noFill />'
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionExcel2003Style06 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_excel2003_style06
|
|
14
|
+
@xlsx = 'excel2003_style06.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :excel2003_style => true)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
worksheet.insert_image('B3', 'test/regression/images/red.jpg', 4, 3)
|
|
19
|
+
|
|
20
|
+
workbook.close
|
|
21
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
|
|
22
|
+
[],
|
|
23
|
+
{
|
|
24
|
+
'xl/drawings/drawing1.xml' =>
|
|
25
|
+
[
|
|
26
|
+
'<xdr:cNvPr', '<a:picLocks', '<a:srcRect />', '<xdr:spPr', '<a:noFill />'
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionExcel2003Style07 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_excel2003_style07
|
|
14
|
+
@xlsx = 'excel2003_style07.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :excel2003_style => true)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
worksheet.insert_image('B3', 'test/regression/images/yellow.jpg', 4, 3)
|
|
19
|
+
|
|
20
|
+
workbook.close
|
|
21
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
|
|
22
|
+
[],
|
|
23
|
+
{
|
|
24
|
+
'xl/drawings/drawing1.xml' =>
|
|
25
|
+
[
|
|
26
|
+
'<xdr:cNvPr', '<a:picLocks', '<a:srcRect />', '<xdr:spPr', '<a:noFill />'
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestRegressionExcel2003Style08 < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
setup_dir_var
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def teardown
|
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_excel2003_style08
|
|
14
|
+
@xlsx = 'excel2003_style08.xlsx'
|
|
15
|
+
workbook = WriteXLSX.new(@xlsx, :excel2003_style => true)
|
|
16
|
+
worksheet = workbook.add_worksheet
|
|
17
|
+
|
|
18
|
+
courier = workbook.add_format(:font => 'Courier', :size => 8, :font_family => 3)
|
|
19
|
+
|
|
20
|
+
worksheet.write('A1', 'Foo')
|
|
21
|
+
worksheet.write('A2', 'Bar', courier)
|
|
22
|
+
|
|
23
|
+
workbook.close
|
|
24
|
+
compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/test/test_example_match.rb
CHANGED
|
@@ -482,6 +482,122 @@ def test_chart_column
|
|
|
482
482
|
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
|
483
483
|
end
|
|
484
484
|
|
|
485
|
+
def test_chart_doughnut
|
|
486
|
+
@xlsx = 'chart_doughnut.xlsx'
|
|
487
|
+
workbook = WriteXLSX.new(@xlsx)
|
|
488
|
+
worksheet = workbook.add_worksheet
|
|
489
|
+
bold = workbook.add_format(:bold => 1)
|
|
490
|
+
|
|
491
|
+
# Add the worksheet data that the charts will refer to.
|
|
492
|
+
headings = [ 'Category', 'Values' ]
|
|
493
|
+
data = [
|
|
494
|
+
[ 'Glazed', 'Chocolate', 'Cream' ],
|
|
495
|
+
[ 50, 35, 15 ]
|
|
496
|
+
]
|
|
497
|
+
|
|
498
|
+
worksheet.write('A1', headings, bold)
|
|
499
|
+
worksheet.write('A2', data)
|
|
500
|
+
|
|
501
|
+
# Create a new chart object. In this case an embedded chart.
|
|
502
|
+
chart1 = workbook.add_chart(:type => 'doughnut', :embedded => 1)
|
|
503
|
+
|
|
504
|
+
# Configure the series. Note the use of the array ref to define ranges:
|
|
505
|
+
# [ $sheetname, $row_start, $row_end, $col_start, $col_end ].
|
|
506
|
+
# See below for an alternative syntax.
|
|
507
|
+
chart1.add_series(
|
|
508
|
+
:name => 'Doughnut sales data',
|
|
509
|
+
:categories => [ 'Sheet1', 1, 3, 0, 0 ],
|
|
510
|
+
:values => [ 'Sheet1', 1, 3, 1, 1 ]
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
# Add a title.
|
|
514
|
+
chart1.set_title(:name => 'Popular Doughnut Types')
|
|
515
|
+
|
|
516
|
+
# Set an Excel chart style. Colors with white outline and shadow.
|
|
517
|
+
chart1.set_style(10)
|
|
518
|
+
|
|
519
|
+
# Insert the chart into the worksheet (with an offset).
|
|
520
|
+
worksheet.insert_chart('C2', chart1, 25, 10)
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
#
|
|
524
|
+
# Create a Doughnut chart with user defined segment colors.
|
|
525
|
+
#
|
|
526
|
+
|
|
527
|
+
# Create an example Doughnut chart like above.
|
|
528
|
+
chart2 = workbook.add_chart(:type => 'doughnut', :embedded => 1)
|
|
529
|
+
|
|
530
|
+
# Configure the series and add user defined segment colours.
|
|
531
|
+
chart2.add_series(
|
|
532
|
+
:name => 'Doughnut sales data',
|
|
533
|
+
:categories => '=Sheet1!$A$2:$A$4',
|
|
534
|
+
:values => '=Sheet1!$B$2:$B$4',
|
|
535
|
+
:points => [
|
|
536
|
+
{ :fill => { :color => '#FA58D0' } },
|
|
537
|
+
{ :fill => { :color => '#61210B' } },
|
|
538
|
+
{ :fill => { :color => '#F5F6CE' } }
|
|
539
|
+
]
|
|
540
|
+
)
|
|
541
|
+
|
|
542
|
+
# Add a title.
|
|
543
|
+
chart2.set_title(:name => 'Doughnut Chart with user defined colors')
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
# Insert the chart into the worksheet (with an offset).
|
|
547
|
+
worksheet.insert_chart('C18', chart2, 25, 10)
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
#
|
|
551
|
+
# Create a Doughnut chart with rotation of the segments.
|
|
552
|
+
#
|
|
553
|
+
|
|
554
|
+
# Create an example Doughnut chart like above.
|
|
555
|
+
chart3 = workbook.add_chart(:type => 'doughnut', :embedded => 1)
|
|
556
|
+
|
|
557
|
+
# Configure the series.
|
|
558
|
+
chart3.add_series(
|
|
559
|
+
:name => 'Doughnut sales data',
|
|
560
|
+
:categories => '=Sheet1!$A$2:$A$4',
|
|
561
|
+
:values => '=Sheet1!$B$2:$B$4'
|
|
562
|
+
)
|
|
563
|
+
|
|
564
|
+
# Add a title.
|
|
565
|
+
chart3.set_title(:name => 'Doughnut Chart with segment rotation')
|
|
566
|
+
|
|
567
|
+
# Change the angle/rotation of the first segment.
|
|
568
|
+
chart3.set_rotation(90)
|
|
569
|
+
|
|
570
|
+
# Insert the chart into the worksheet (with an offset).
|
|
571
|
+
worksheet.insert_chart('C34', chart3, 25, 10)
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
#
|
|
575
|
+
# Create a Doughnut chart with user defined hole size.
|
|
576
|
+
#
|
|
577
|
+
|
|
578
|
+
# Create an example Doughnut chart like above.
|
|
579
|
+
chart4 = workbook.add_chart(:type => 'doughnut', :embedded => 1)
|
|
580
|
+
|
|
581
|
+
# Configure the series.
|
|
582
|
+
chart4.add_series(
|
|
583
|
+
:name => 'Doughnut sales data',
|
|
584
|
+
:categories => '=Sheet1!$A$2:$A$4',
|
|
585
|
+
:values => '=Sheet1!$B$2:$B$4'
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
# Add a title.
|
|
589
|
+
chart4.set_title(:name => 'Doughnut Chart with user defined hole size')
|
|
590
|
+
|
|
591
|
+
# Change the hole size.
|
|
592
|
+
chart4.set_hole_size(33)
|
|
593
|
+
|
|
594
|
+
# Insert the chart into the worksheet (with an offset).
|
|
595
|
+
worksheet.insert_chart('C50', chart4, 25, 10)
|
|
596
|
+
|
|
597
|
+
workbook.close
|
|
598
|
+
compare_xlsx(File.join(@perl_output, @xlsx), @xlsx)
|
|
599
|
+
end
|
|
600
|
+
|
|
485
601
|
def test_chart_line
|
|
486
602
|
@xlsx = 'chart_line.xlsx'
|
|
487
603
|
workbook = WriteXLSX.new(@xlsx)
|