write_xlsx 1.04.0 → 1.08.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/Changes +50 -0
  4. data/README.md +1 -1
  5. data/examples/chart_data_labels.rb +320 -0
  6. data/examples/ignore_errors.rb +39 -0
  7. data/ignore_errors.xlsx +0 -0
  8. data/lib/write_xlsx/chart/series.rb +100 -0
  9. data/lib/write_xlsx/chart.rb +155 -33
  10. data/lib/write_xlsx/drawing.rb +80 -17
  11. data/lib/write_xlsx/package/app.rb +3 -3
  12. data/lib/write_xlsx/package/conditional_format.rb +2 -8
  13. data/lib/write_xlsx/package/packager.rb +1 -0
  14. data/lib/write_xlsx/package/styles.rb +16 -3
  15. data/lib/write_xlsx/package/table.rb +8 -0
  16. data/lib/write_xlsx/utility.rb +9 -3
  17. data/lib/write_xlsx/version.rb +1 -1
  18. data/lib/write_xlsx/workbook.rb +23 -0
  19. data/lib/write_xlsx/worksheet/data_validation.rb +1 -6
  20. data/lib/write_xlsx/worksheet.rb +160 -37
  21. data/test/drawing/{test_write_ext.rb → test_write_xdr_ext.rb} +2 -2
  22. data/test/perl_output/chart_data_labels.xlsx +0 -0
  23. data/test/perl_output/ignore_errors.xlsx +0 -0
  24. data/test/regression/test_array_formula04.rb +31 -0
  25. data/test/regression/test_chart_crossing01.rb +1 -1
  26. data/test/regression/test_chart_crossing05.rb +46 -0
  27. data/test/regression/test_chart_crossing06.rb +46 -0
  28. data/test/regression/test_chart_data_labels26.rb +44 -0
  29. data/test/regression/test_chart_data_labels27.rb +44 -0
  30. data/test/regression/test_chart_data_labels28.rb +52 -0
  31. data/test/regression/test_chart_data_labels29.rb +43 -0
  32. data/test/regression/test_chart_data_labels30.rb +46 -0
  33. data/test/regression/test_chart_data_labels31.rb +49 -0
  34. data/test/regression/test_chart_data_labels32.rb +54 -0
  35. data/test/regression/test_chart_data_labels33.rb +52 -0
  36. data/test/regression/test_chart_data_labels34.rb +54 -0
  37. data/test/regression/test_chart_data_labels35.rb +46 -0
  38. data/test/regression/test_chart_data_labels36.rb +54 -0
  39. data/test/regression/test_chart_data_labels37.rb +51 -0
  40. data/test/regression/test_chart_data_labels38.rb +54 -0
  41. data/test/regression/test_chart_data_labels39.rb +53 -0
  42. data/test/regression/test_chart_data_labels40.rb +53 -0
  43. data/test/regression/test_chart_data_labels41.rb +54 -0
  44. data/test/regression/test_chart_data_labels42.rb +58 -0
  45. data/test/regression/test_chart_data_labels43.rb +58 -0
  46. data/test/regression/test_chart_data_labels44.rb +56 -0
  47. data/test/regression/test_chart_data_labels45.rb +57 -0
  48. data/test/regression/test_chart_data_labels46.rb +61 -0
  49. data/test/regression/test_chart_data_labels47.rb +61 -0
  50. data/test/regression/test_chart_data_labels48.rb +55 -0
  51. data/test/regression/test_chart_data_labels49.rb +55 -0
  52. data/test/regression/test_chart_data_labels50.rb +57 -0
  53. data/test/regression/test_format16.rb +24 -0
  54. data/test/regression/test_format17.rb +24 -0
  55. data/test/regression/test_header04.rb +30 -0
  56. data/test/regression/test_hyperlink50.rb +27 -0
  57. data/test/regression/test_hyperlink51.rb +27 -0
  58. data/test/regression/test_ignore_error01.rb +23 -0
  59. data/test/regression/test_ignore_error02.rb +24 -0
  60. data/test/regression/test_ignore_error03.rb +26 -0
  61. data/test/regression/test_ignore_error04.rb +26 -0
  62. data/test/regression/test_ignore_error05.rb +32 -0
  63. data/test/regression/test_ignore_error06.rb +32 -0
  64. data/test/regression/test_image52.rb +26 -0
  65. data/test/regression/test_image53.rb +26 -0
  66. data/test/regression/test_image54.rb +26 -0
  67. data/test/regression/test_image55.rb +27 -0
  68. data/test/regression/test_protect04.rb +32 -0
  69. data/test/regression/test_protect05.rb +35 -0
  70. data/test/regression/test_protect06.rb +35 -0
  71. data/test/regression/test_protect07.rb +23 -0
  72. data/test/regression/test_table26.rb +38 -0
  73. data/test/regression/xlsx_files/array_formula04.xlsx +0 -0
  74. data/test/regression/xlsx_files/chart_crossing05.xlsx +0 -0
  75. data/test/regression/xlsx_files/chart_crossing06.xlsx +0 -0
  76. data/test/regression/xlsx_files/chart_data_labels26.xlsx +0 -0
  77. data/test/regression/xlsx_files/chart_data_labels27.xlsx +0 -0
  78. data/test/regression/xlsx_files/chart_data_labels28.xlsx +0 -0
  79. data/test/regression/xlsx_files/chart_data_labels29.xlsx +0 -0
  80. data/test/regression/xlsx_files/chart_data_labels30.xlsx +0 -0
  81. data/test/regression/xlsx_files/chart_data_labels31.xlsx +0 -0
  82. data/test/regression/xlsx_files/chart_data_labels32.xlsx +0 -0
  83. data/test/regression/xlsx_files/chart_data_labels33.xlsx +0 -0
  84. data/test/regression/xlsx_files/chart_data_labels34.xlsx +0 -0
  85. data/test/regression/xlsx_files/chart_data_labels35.xlsx +0 -0
  86. data/test/regression/xlsx_files/chart_data_labels36.xlsx +0 -0
  87. data/test/regression/xlsx_files/chart_data_labels37.xlsx +0 -0
  88. data/test/regression/xlsx_files/chart_data_labels38.xlsx +0 -0
  89. data/test/regression/xlsx_files/chart_data_labels39.xlsx +0 -0
  90. data/test/regression/xlsx_files/chart_data_labels40.xlsx +0 -0
  91. data/test/regression/xlsx_files/chart_data_labels41.xlsx +0 -0
  92. data/test/regression/xlsx_files/chart_data_labels42.xlsx +0 -0
  93. data/test/regression/xlsx_files/chart_data_labels43.xlsx +0 -0
  94. data/test/regression/xlsx_files/chart_data_labels44.xlsx +0 -0
  95. data/test/regression/xlsx_files/chart_data_labels45.xlsx +0 -0
  96. data/test/regression/xlsx_files/chart_data_labels46.xlsx +0 -0
  97. data/test/regression/xlsx_files/chart_data_labels47.xlsx +0 -0
  98. data/test/regression/xlsx_files/chart_data_labels48.xlsx +0 -0
  99. data/test/regression/xlsx_files/chart_data_labels49.xlsx +0 -0
  100. data/test/regression/xlsx_files/chart_data_labels50.xlsx +0 -0
  101. data/test/regression/xlsx_files/format16.xlsx +0 -0
  102. data/test/regression/xlsx_files/format17.xlsx +0 -0
  103. data/test/regression/xlsx_files/header04.xlsx +0 -0
  104. data/test/regression/xlsx_files/hyperlink50.xlsx +0 -0
  105. data/test/regression/xlsx_files/hyperlink51.xlsx +0 -0
  106. data/test/regression/xlsx_files/ignore_error01.xlsx +0 -0
  107. data/test/regression/xlsx_files/ignore_error02.xlsx +0 -0
  108. data/test/regression/xlsx_files/ignore_error03.xlsx +0 -0
  109. data/test/regression/xlsx_files/ignore_error04.xlsx +0 -0
  110. data/test/regression/xlsx_files/ignore_error05.xlsx +0 -0
  111. data/test/regression/xlsx_files/ignore_error06.xlsx +0 -0
  112. data/test/regression/xlsx_files/image52.xlsx +0 -0
  113. data/test/regression/xlsx_files/image53.xlsx +0 -0
  114. data/test/regression/xlsx_files/image54.xlsx +0 -0
  115. data/test/regression/xlsx_files/image55.xlsx +0 -0
  116. data/test/regression/xlsx_files/protect04.xlsx +0 -0
  117. data/test/regression/xlsx_files/protect05.xlsx +0 -0
  118. data/test/regression/xlsx_files/protect06.xlsx +0 -0
  119. data/test/regression/xlsx_files/protect07.xlsx +0 -0
  120. data/test/regression/xlsx_files/table26.xlsx +0 -0
  121. data/test/test_example_match.rb +345 -1
  122. data/test/utility/test_range.rb +20 -0
  123. metadata +209 -8
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels28 < 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_labels28
14
+ @xlsx = 'chart_data_labels28.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, [48514944, 48516480])
21
+
22
+ data = [
23
+ [ 1, 2, 3, 4, 5],
24
+ [ 2, 4, 6, 8, 10],
25
+ [ 3, 6, 9, 12, 15],
26
+ ['foo', 'bar']
27
+ ]
28
+
29
+ worksheet.write('A1', data)
30
+
31
+ custom = [
32
+ {:value => 123},
33
+ {:value => 'abc'},
34
+ nil,
35
+ {:formula => 'Sheet1!$D$1'},
36
+ {:formula => 'Sheet1!$D$2'}
37
+ ]
38
+
39
+ chart.add_series(
40
+ :values => '=Sheet1!$A$1:$A$5',
41
+ :data_labels => {:value => 1, :custom => custom }
42
+ )
43
+
44
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
45
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
46
+
47
+ worksheet.insert_chart('E9', chart)
48
+
49
+ workbook.close
50
+ compare_for_regression
51
+ end
52
+ end
@@ -0,0 +1,43 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels29 < 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_labels29
14
+ @xlsx = 'chart_data_labels29.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, [67858816, 67863296])
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 => {:value => 1, :custom => [{:delete => 1}] }
33
+ )
34
+
35
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
36
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
37
+
38
+ worksheet.insert_chart('E9', chart)
39
+
40
+ workbook.close
41
+ compare_for_regression
42
+ end
43
+ end
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels30 < 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_labels30
14
+ @xlsx = 'chart_data_labels30.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, [67858816, 67863296])
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
+ :custom => [{:delete => 1}, nil, {:delete => 1}, nil, {:delete => 1}]
35
+ }
36
+ )
37
+
38
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
39
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
40
+
41
+ worksheet.insert_chart('E9', chart)
42
+
43
+ workbook.close
44
+ compare_for_regression
45
+ end
46
+ end
@@ -0,0 +1,49 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels31 < 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_labels31
14
+ @xlsx = 'chart_data_labels31.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, [71248896, 71373568])
21
+
22
+ data = [
23
+ [ 1, 2, 3, 4, 5],
24
+ [ 2, 4, 6, 8, 10],
25
+ [ 3, 6, 9, 12, 15],
26
+ [ 10, 20, 30, 40, 50]
27
+ ]
28
+
29
+ worksheet.write('A1', data)
30
+
31
+ chart.add_series(
32
+ :values => '=Sheet1!$A$1:$A$5',
33
+ :data_labels => {
34
+ :value => 1,
35
+ :category => 1,
36
+ :series_name => 1,
37
+ :custom => [{:value => 33}]
38
+ }
39
+ )
40
+
41
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
42
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
43
+
44
+ worksheet.insert_chart('E9', chart)
45
+
46
+ workbook.close
47
+ compare_for_regression
48
+ end
49
+ end
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels32 < 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_labels32
14
+ @xlsx = 'chart_data_labels32.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, [71374336, 71414144])
21
+
22
+ data = [
23
+ [ 1, 2, 3, 4, 5],
24
+ [ 2, 4, 6, 8, 10],
25
+ [ 3, 6, 9, 12, 15],
26
+ [ 10, 20, 30, 40, 50]
27
+ ]
28
+
29
+ worksheet.write('A1', data)
30
+
31
+ chart.add_series(
32
+ :values => '=Sheet1!$A$1:$A$5',
33
+ :data_labels => {
34
+ :value => 1,
35
+ :custom => [
36
+ {
37
+ :value => 33,
38
+ :font => {
39
+ :bold => 1, :italic => 1, :color => 'red', :baseline => -1
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ )
45
+
46
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
47
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
48
+
49
+ worksheet.insert_chart('E9', chart)
50
+
51
+ workbook.close
52
+ compare_for_regression
53
+ end
54
+ end
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels33 < 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_labels33
14
+ @xlsx = 'chart_data_labels33.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, [65546112, 70217728])
21
+
22
+ data = [
23
+ [ 1, 2, 3, 4, 5],
24
+ [ 2, 4, 6, 8, 10],
25
+ [ 3, 6, 9, 12, 15],
26
+ [ 10, 20, 30, 40, 50]
27
+ ]
28
+
29
+ worksheet.write('A1', data)
30
+
31
+ chart.add_series(
32
+ :values => '=Sheet1!$A$1:$A$5',
33
+ :data_labels => {
34
+ :value => 1,
35
+ :custom => [
36
+ {:font => {
37
+ :bold => 1, :italic => 1, :baseline => -1
38
+ }
39
+ }
40
+ ]
41
+ }
42
+ )
43
+
44
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
45
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
46
+
47
+ worksheet.insert_chart('E9', chart)
48
+
49
+ workbook.close
50
+ compare_for_regression
51
+ end
52
+ end
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels34 < 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_labels34
14
+ @xlsx = 'chart_data_labels34.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, [48497792, 48499712])
21
+
22
+ data = [
23
+ [ 1, 2, 3, 4, 5],
24
+ [ 2, 4, 6, 8, 10],
25
+ [ 3, 6, 9, 12, 15],
26
+ [ 10, 20, 30, 40, 50]
27
+ ]
28
+
29
+ worksheet.write('A1', data)
30
+
31
+ chart.add_series(
32
+ :values => '=Sheet1!$A$1:$A$5',
33
+ :data_labels => {
34
+ :value => 1,
35
+ :custom => [
36
+ {
37
+ :value => '=Sheet1!$D$1',
38
+ :font => {
39
+ :bold => 1, :italic => 1, :color => 'red', :baseline => -1
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ )
45
+
46
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
47
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
48
+
49
+ worksheet.insert_chart('E9', chart)
50
+
51
+ workbook.close
52
+ compare_for_regression
53
+ end
54
+ end
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels35 < 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_labels35
14
+ @xlsx = 'chart_data_labels35.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, [48498944, 48508928])
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
+ :border => { :color => 'red' }
35
+ }
36
+ )
37
+
38
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
39
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
40
+
41
+ worksheet.insert_chart('E9', chart)
42
+
43
+ workbook.close
44
+ compare_for_regression
45
+ end
46
+ end
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels36 < 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_labels36
14
+ @xlsx = 'chart_data_labels36.xlsx'
15
+ workbook = WriteXLSX.new(@io)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'pie', :embedded => 1)
18
+
19
+ data = [
20
+ [ 1, 2, 3, 4, 5],
21
+ [ 2, 4, 6, 8, 10],
22
+ [ 3, 6, 9, 12, 15]
23
+ ]
24
+
25
+ worksheet.write('A1', data)
26
+
27
+ chart.add_series(
28
+ :values => '=Sheet1!$A$1:$A$5',
29
+ :data_labels => {
30
+ :value => 1,
31
+ :category => 1,
32
+ :series_name => 1,
33
+ :percentage => 1,
34
+ :separator => ';',
35
+ :leader_lines => 1,
36
+ :position => 'inside_end',
37
+ :legend_key => 1,
38
+ :num_format => '#,##0.00',
39
+ :font => {
40
+ :name => 'Consolas',
41
+ :baseline => -1,
42
+ :pitch_family => 49,
43
+ :charset => 0
44
+ },
45
+ :border => { :color => 'red' }
46
+ }
47
+ )
48
+
49
+ worksheet.insert_chart('E9', chart)
50
+
51
+ workbook.close
52
+ compare_for_regression
53
+ end
54
+ end
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels37 < 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_labels37
14
+ @xlsx = 'chart_data_labels37.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, [48498944, 48508928])
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
+ :border => {
35
+ :color => 'red',
36
+ :width => 1,
37
+ :dash_type => 'dash'
38
+ },
39
+ :fill => { :color => '#00B050' }
40
+ }
41
+ )
42
+
43
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
44
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
45
+
46
+ worksheet.insert_chart('E9', chart)
47
+
48
+ workbook.close
49
+ compare_for_regression
50
+ end
51
+ end
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels38 < 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_labels38
14
+ @xlsx = 'chart_data_labels38.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, [48498944, 48508928])
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
+ :border => {
35
+ :color => 'red',
36
+ :width => 1,
37
+ :dash_type => 'dash'
38
+ },
39
+ :pattern => {
40
+ :pattern => 'light_vertical',
41
+ :fg_color => '#00B050'
42
+ }
43
+ }
44
+ )
45
+
46
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
47
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
48
+
49
+ worksheet.insert_chart('E9', chart)
50
+
51
+ workbook.close
52
+ compare_for_regression
53
+ end
54
+ end
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels39 < 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_labels39
14
+ @xlsx = 'chart_data_labels39.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, [56179712, 56185600])
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
+ :border => {
35
+ :color => 'red',
36
+ :width => 1,
37
+ :dash_type => 'dash'
38
+ },
39
+ :gradient => {
40
+ :colors => ['#DDEBCF', '#9CB86E', '#156B13']
41
+ }
42
+ }
43
+ )
44
+
45
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
46
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
47
+
48
+ worksheet.insert_chart('E9', chart)
49
+
50
+ workbook.close
51
+ compare_for_regression
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels40 < 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_labels40
14
+ @xlsx = 'chart_data_labels40.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, [61191680, 61193600])
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
+ :custom => [
35
+ {
36
+ :value => 33,
37
+ :border => {
38
+ :color => 'red'
39
+ }
40
+ }
41
+ ]
42
+ }
43
+ )
44
+
45
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
46
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
47
+
48
+ worksheet.insert_chart('E9', chart)
49
+
50
+ workbook.close
51
+ compare_for_regression
52
+ end
53
+ end