write_xlsx 1.02.0 → 1.08.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/Changes +72 -0
  4. data/README.md +1 -1
  5. data/examples/chart_data_labels.rb +320 -0
  6. data/examples/chart_line.rb +85 -10
  7. data/examples/tables.rb +77 -42
  8. data/lib/write_xlsx/chart/line.rb +15 -1
  9. data/lib/write_xlsx/chart/series.rb +100 -0
  10. data/lib/write_xlsx/chart.rb +155 -33
  11. data/lib/write_xlsx/drawing.rb +80 -17
  12. data/lib/write_xlsx/format.rb +5 -5
  13. data/lib/write_xlsx/package/app.rb +3 -3
  14. data/lib/write_xlsx/package/comments.rb +4 -4
  15. data/lib/write_xlsx/package/conditional_format.rb +2 -8
  16. data/lib/write_xlsx/package/packager.rb +1 -0
  17. data/lib/write_xlsx/package/relationships.rb +2 -2
  18. data/lib/write_xlsx/package/styles.rb +42 -11
  19. data/lib/write_xlsx/package/table.rb +16 -7
  20. data/lib/write_xlsx/package/vml.rb +20 -19
  21. data/lib/write_xlsx/sheets.rb +12 -20
  22. data/lib/write_xlsx/utility.rb +9 -3
  23. data/lib/write_xlsx/version.rb +1 -1
  24. data/lib/write_xlsx/workbook.rb +76 -35
  25. data/lib/write_xlsx/worksheet/data_validation.rb +1 -6
  26. data/lib/write_xlsx/worksheet.rb +197 -57
  27. data/test/drawing/{test_write_ext.rb → test_write_xdr_ext.rb} +2 -2
  28. data/test/perl_output/chart_data_labels.xlsx +0 -0
  29. data/test/perl_output/chart_line.xlsx +0 -0
  30. data/test/perl_output/comments2.xlsx +0 -0
  31. data/test/perl_output/tables.xlsx +0 -0
  32. data/test/regression/images/red2.png +0 -0
  33. data/test/regression/test_array_formula04.rb +31 -0
  34. data/test/regression/test_chart_crossing01.rb +1 -1
  35. data/test/regression/test_chart_crossing05.rb +46 -0
  36. data/test/regression/test_chart_crossing06.rb +46 -0
  37. data/test/regression/test_chart_data_labels26.rb +44 -0
  38. data/test/regression/test_chart_data_labels27.rb +44 -0
  39. data/test/regression/test_chart_data_labels28.rb +52 -0
  40. data/test/regression/test_chart_data_labels29.rb +43 -0
  41. data/test/regression/test_chart_data_labels30.rb +46 -0
  42. data/test/regression/test_chart_data_labels31.rb +49 -0
  43. data/test/regression/test_chart_data_labels32.rb +54 -0
  44. data/test/regression/test_chart_data_labels33.rb +52 -0
  45. data/test/regression/test_chart_data_labels34.rb +54 -0
  46. data/test/regression/test_chart_data_labels35.rb +46 -0
  47. data/test/regression/test_chart_data_labels36.rb +54 -0
  48. data/test/regression/test_chart_data_labels37.rb +51 -0
  49. data/test/regression/test_chart_data_labels38.rb +54 -0
  50. data/test/regression/test_chart_data_labels39.rb +53 -0
  51. data/test/regression/test_chart_data_labels40.rb +53 -0
  52. data/test/regression/test_chart_data_labels41.rb +54 -0
  53. data/test/regression/test_chart_data_labels42.rb +58 -0
  54. data/test/regression/test_chart_data_labels43.rb +58 -0
  55. data/test/regression/test_chart_data_labels44.rb +56 -0
  56. data/test/regression/test_chart_data_labels45.rb +57 -0
  57. data/test/regression/test_chart_data_labels46.rb +61 -0
  58. data/test/regression/test_chart_data_labels47.rb +61 -0
  59. data/test/regression/test_chart_data_labels48.rb +55 -0
  60. data/test/regression/test_chart_data_labels49.rb +55 -0
  61. data/test/regression/test_chart_data_labels50.rb +57 -0
  62. data/test/regression/test_chart_line05.rb +43 -0
  63. data/test/regression/test_chart_line06.rb +43 -0
  64. data/test/regression/test_comment15.rb +28 -0
  65. data/test/regression/test_comment16.rb +34 -0
  66. data/test/regression/test_format16.rb +24 -0
  67. data/test/regression/test_format17.rb +24 -0
  68. data/test/regression/test_header04.rb +30 -0
  69. data/test/regression/test_header_image15.rb +36 -0
  70. data/test/regression/test_header_image16.rb +42 -0
  71. data/test/regression/test_header_image17.rb +46 -0
  72. data/test/regression/test_header_image18.rb +48 -0
  73. data/test/regression/test_header_image19.rb +36 -0
  74. data/test/regression/test_hyperlink48.rb +31 -0
  75. data/test/regression/test_hyperlink49.rb +29 -0
  76. data/test/regression/test_hyperlink50.rb +27 -0
  77. data/test/regression/test_hyperlink51.rb +27 -0
  78. data/test/regression/test_ignore_error01.rb +23 -0
  79. data/test/regression/test_ignore_error02.rb +24 -0
  80. data/test/regression/test_ignore_error03.rb +26 -0
  81. data/test/regression/test_ignore_error04.rb +26 -0
  82. data/test/regression/test_ignore_error05.rb +32 -0
  83. data/test/regression/test_ignore_error06.rb +32 -0
  84. data/test/regression/test_image45.rb +2 -1
  85. data/test/regression/test_image46.rb +1 -1
  86. data/test/regression/test_image48.rb +32 -0
  87. data/test/regression/test_image49.rb +38 -0
  88. data/test/regression/test_image50.rb +24 -0
  89. data/test/regression/test_image51.rb +30 -0
  90. data/test/regression/test_image52.rb +26 -0
  91. data/test/regression/test_image53.rb +26 -0
  92. data/test/regression/test_image54.rb +26 -0
  93. data/test/regression/test_image55.rb +27 -0
  94. data/test/regression/test_object_position12.rb +25 -0
  95. data/test/regression/test_object_position13.rb +25 -0
  96. data/test/regression/test_object_position14.rb +25 -0
  97. data/test/regression/test_object_position15.rb +29 -0
  98. data/test/regression/test_object_position16.rb +29 -0
  99. data/test/regression/test_object_position17.rb +29 -0
  100. data/test/regression/test_object_position18.rb +29 -0
  101. data/test/regression/test_object_position19.rb +29 -0
  102. data/test/regression/test_object_position20.rb +29 -0
  103. data/test/regression/test_protect04.rb +32 -0
  104. data/test/regression/test_protect05.rb +35 -0
  105. data/test/regression/test_protect06.rb +35 -0
  106. data/test/regression/test_protect07.rb +23 -0
  107. data/test/regression/test_table24.rb +27 -0
  108. data/test/regression/test_table25.rb +27 -0
  109. data/test/regression/test_table26.rb +38 -0
  110. data/test/regression/xlsx_files/array_formula04.xlsx +0 -0
  111. data/test/regression/xlsx_files/chart_crossing05.xlsx +0 -0
  112. data/test/regression/xlsx_files/chart_crossing06.xlsx +0 -0
  113. data/test/regression/xlsx_files/chart_data_labels26.xlsx +0 -0
  114. data/test/regression/xlsx_files/chart_data_labels27.xlsx +0 -0
  115. data/test/regression/xlsx_files/chart_data_labels28.xlsx +0 -0
  116. data/test/regression/xlsx_files/chart_data_labels29.xlsx +0 -0
  117. data/test/regression/xlsx_files/chart_data_labels30.xlsx +0 -0
  118. data/test/regression/xlsx_files/chart_data_labels31.xlsx +0 -0
  119. data/test/regression/xlsx_files/chart_data_labels32.xlsx +0 -0
  120. data/test/regression/xlsx_files/chart_data_labels33.xlsx +0 -0
  121. data/test/regression/xlsx_files/chart_data_labels34.xlsx +0 -0
  122. data/test/regression/xlsx_files/chart_data_labels35.xlsx +0 -0
  123. data/test/regression/xlsx_files/chart_data_labels36.xlsx +0 -0
  124. data/test/regression/xlsx_files/chart_data_labels37.xlsx +0 -0
  125. data/test/regression/xlsx_files/chart_data_labels38.xlsx +0 -0
  126. data/test/regression/xlsx_files/chart_data_labels39.xlsx +0 -0
  127. data/test/regression/xlsx_files/chart_data_labels40.xlsx +0 -0
  128. data/test/regression/xlsx_files/chart_data_labels41.xlsx +0 -0
  129. data/test/regression/xlsx_files/chart_data_labels42.xlsx +0 -0
  130. data/test/regression/xlsx_files/chart_data_labels43.xlsx +0 -0
  131. data/test/regression/xlsx_files/chart_data_labels44.xlsx +0 -0
  132. data/test/regression/xlsx_files/chart_data_labels45.xlsx +0 -0
  133. data/test/regression/xlsx_files/chart_data_labels46.xlsx +0 -0
  134. data/test/regression/xlsx_files/chart_data_labels47.xlsx +0 -0
  135. data/test/regression/xlsx_files/chart_data_labels48.xlsx +0 -0
  136. data/test/regression/xlsx_files/chart_data_labels49.xlsx +0 -0
  137. data/test/regression/xlsx_files/chart_data_labels50.xlsx +0 -0
  138. data/test/regression/xlsx_files/chart_line05.xlsx +0 -0
  139. data/test/regression/xlsx_files/chart_line06.xlsx +0 -0
  140. data/test/regression/xlsx_files/comment15.xlsx +0 -0
  141. data/test/regression/xlsx_files/comment16.xlsx +0 -0
  142. data/test/regression/xlsx_files/format16.xlsx +0 -0
  143. data/test/regression/xlsx_files/format17.xlsx +0 -0
  144. data/test/regression/xlsx_files/header04.xlsx +0 -0
  145. data/test/regression/xlsx_files/header_image15.xlsx +0 -0
  146. data/test/regression/xlsx_files/header_image16.xlsx +0 -0
  147. data/test/regression/xlsx_files/header_image17.xlsx +0 -0
  148. data/test/regression/xlsx_files/header_image18.xlsx +0 -0
  149. data/test/regression/xlsx_files/header_image19.xlsx +0 -0
  150. data/test/regression/xlsx_files/hyperlink46.xlsx +0 -0
  151. data/test/regression/xlsx_files/hyperlink50.xlsx +0 -0
  152. data/test/regression/xlsx_files/hyperlink51.xlsx +0 -0
  153. data/test/regression/xlsx_files/ignore_error01.xlsx +0 -0
  154. data/test/regression/xlsx_files/ignore_error02.xlsx +0 -0
  155. data/test/regression/xlsx_files/ignore_error03.xlsx +0 -0
  156. data/test/regression/xlsx_files/ignore_error04.xlsx +0 -0
  157. data/test/regression/xlsx_files/ignore_error05.xlsx +0 -0
  158. data/test/regression/xlsx_files/ignore_error06.xlsx +0 -0
  159. data/test/regression/xlsx_files/image45.xlsx +0 -0
  160. data/test/regression/xlsx_files/image46.xlsx +0 -0
  161. data/test/regression/xlsx_files/image48.xlsx +0 -0
  162. data/test/regression/xlsx_files/image49.xlsx +0 -0
  163. data/test/regression/xlsx_files/image50.xlsx +0 -0
  164. data/test/regression/xlsx_files/image51.xlsx +0 -0
  165. data/test/regression/xlsx_files/image52.xlsx +0 -0
  166. data/test/regression/xlsx_files/image53.xlsx +0 -0
  167. data/test/regression/xlsx_files/image54.xlsx +0 -0
  168. data/test/regression/xlsx_files/image55.xlsx +0 -0
  169. data/test/regression/xlsx_files/object_position12.xlsx +0 -0
  170. data/test/regression/xlsx_files/object_position13.xlsx +0 -0
  171. data/test/regression/xlsx_files/object_position14.xlsx +0 -0
  172. data/test/regression/xlsx_files/object_position15.xlsx +0 -0
  173. data/test/regression/xlsx_files/object_position16.xlsx +0 -0
  174. data/test/regression/xlsx_files/object_position17.xlsx +0 -0
  175. data/test/regression/xlsx_files/object_position18.xlsx +0 -0
  176. data/test/regression/xlsx_files/object_position19.xlsx +0 -0
  177. data/test/regression/xlsx_files/object_position20.xlsx +0 -0
  178. data/test/regression/xlsx_files/protect04.xlsx +0 -0
  179. data/test/regression/xlsx_files/protect05.xlsx +0 -0
  180. data/test/regression/xlsx_files/protect06.xlsx +0 -0
  181. data/test/regression/xlsx_files/protect07.xlsx +0 -0
  182. data/test/regression/xlsx_files/table24.xlsx +0 -0
  183. data/test/regression/xlsx_files/table25.xlsx +0 -0
  184. data/test/regression/xlsx_files/table26.xlsx +0 -0
  185. data/test/test_example_match.rb +433 -10
  186. data/test/utility/test_range.rb +20 -0
  187. data/test/workbook/test_check_sheetname.rb +0 -10
  188. data/write_xlsx.gemspec +1 -0
  189. metadata +323 -8
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels27 < 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_labels27
14
+ @xlsx = 'chart_data_labels27.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
+ [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 => {:value => 1, :custom => [{:value => '=Sheet1!$D$1'}]}
34
+ )
35
+
36
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
37
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
38
+
39
+ worksheet.insert_chart('E9', chart)
40
+
41
+ workbook.close
42
+ compare_for_regression
43
+ end
44
+ end
@@ -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