write_xlsx 0.79.0 → 0.80.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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/Changes +6 -0
  3. data/README.md +1 -1
  4. data/lib/write_xlsx/chart.rb +38 -1
  5. data/lib/write_xlsx/chart/area.rb +4 -0
  6. data/lib/write_xlsx/chart/bar.rb +9 -0
  7. data/lib/write_xlsx/chart/column.rb +9 -0
  8. data/lib/write_xlsx/chart/line.rb +13 -0
  9. data/lib/write_xlsx/chart/pie.rb +10 -0
  10. data/lib/write_xlsx/chart/radar.rb +4 -0
  11. data/lib/write_xlsx/chart/scatter.rb +13 -0
  12. data/lib/write_xlsx/chart/series.rb +38 -26
  13. data/lib/write_xlsx/chart/stock.rb +13 -0
  14. data/lib/write_xlsx/utility.rb +1 -1
  15. data/lib/write_xlsx/version.rb +1 -1
  16. data/lib/write_xlsx/worksheet.rb +11 -4
  17. data/test/chart/test_write_d_lbls.rb +18 -1
  18. data/test/regression/test_chart_data_labels01.rb +47 -0
  19. data/test/regression/test_chart_data_labels02.rb +47 -0
  20. data/test/regression/test_chart_data_labels03.rb +47 -0
  21. data/test/regression/test_chart_data_labels04.rb +47 -0
  22. data/test/regression/test_chart_data_labels05.rb +50 -0
  23. data/test/regression/test_chart_data_labels06.rb +50 -0
  24. data/test/regression/test_chart_data_labels07.rb +40 -0
  25. data/test/regression/test_chart_data_labels08.rb +46 -0
  26. data/test/regression/test_chart_data_labels09.rb +47 -0
  27. data/test/regression/test_chart_data_labels10.rb +47 -0
  28. data/test/regression/test_chart_data_labels11.rb +37 -0
  29. data/test/regression/test_chart_data_labels12.rb +37 -0
  30. data/test/regression/test_chart_data_labels13.rb +37 -0
  31. data/test/regression/test_chart_data_labels14.rb +37 -0
  32. data/test/regression/test_chart_data_labels15.rb +37 -0
  33. data/test/regression/test_chart_data_labels16.rb +40 -0
  34. data/test/regression/test_chart_data_labels17.rb +63 -0
  35. data/test/regression/test_chart_data_labels18.rb +53 -0
  36. data/test/regression/test_chart_data_labels19.rb +53 -0
  37. data/test/regression/test_chart_data_labels20.rb +44 -0
  38. data/test/regression/test_chart_data_labels21.rb +48 -0
  39. data/test/regression/test_chart_data_labels22.rb +47 -0
  40. data/test/regression/test_chart_data_labels23.rb +50 -0
  41. data/test/regression/test_chart_format19.rb +1 -1
  42. data/test/regression/test_quote_name01.rb +48 -0
  43. data/test/regression/test_quote_name03.rb +41 -0
  44. data/test/regression/xlsx_files/chart_data_labels01.xlsx +0 -0
  45. data/test/regression/xlsx_files/chart_data_labels02.xlsx +0 -0
  46. data/test/regression/xlsx_files/chart_data_labels03.xlsx +0 -0
  47. data/test/regression/xlsx_files/chart_data_labels04.xlsx +0 -0
  48. data/test/regression/xlsx_files/chart_data_labels05.xlsx +0 -0
  49. data/test/regression/xlsx_files/chart_data_labels06.xlsx +0 -0
  50. data/test/regression/xlsx_files/chart_data_labels07.xlsx +0 -0
  51. data/test/regression/xlsx_files/chart_data_labels08.xlsx +0 -0
  52. data/test/regression/xlsx_files/chart_data_labels09.xlsx +0 -0
  53. data/test/regression/xlsx_files/chart_data_labels10.xlsx +0 -0
  54. data/test/regression/xlsx_files/chart_data_labels11.xlsx +0 -0
  55. data/test/regression/xlsx_files/chart_data_labels12.xlsx +0 -0
  56. data/test/regression/xlsx_files/chart_data_labels13.xlsx +0 -0
  57. data/test/regression/xlsx_files/chart_data_labels14.xlsx +0 -0
  58. data/test/regression/xlsx_files/chart_data_labels15.xlsx +0 -0
  59. data/test/regression/xlsx_files/chart_data_labels16.xlsx +0 -0
  60. data/test/regression/xlsx_files/chart_data_labels17.xlsx +0 -0
  61. data/test/regression/xlsx_files/chart_data_labels18.xlsx +0 -0
  62. data/test/regression/xlsx_files/chart_data_labels19.xlsx +0 -0
  63. data/test/regression/xlsx_files/chart_data_labels20.xlsx +0 -0
  64. data/test/regression/xlsx_files/chart_data_labels21.xlsx +0 -0
  65. data/test/regression/xlsx_files/chart_data_labels22.xlsx +0 -0
  66. data/test/regression/xlsx_files/chart_data_labels23.xlsx +0 -0
  67. data/test/regression/xlsx_files/chart_data_labels24.xlsx +0 -0
  68. data/test/regression/xlsx_files/quote_name01.xlsx +0 -0
  69. data/test/regression/xlsx_files/quote_name02.xlsx +0 -0
  70. data/test/regression/xlsx_files/quote_name03.xlsx +0 -0
  71. metadata +105 -1
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels02 < 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_data_labels02
14
+ @xlsx = 'chart_data_labels02.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
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, [47721856, 53641216])
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, :position => 'inside_end' }
33
+ )
34
+
35
+ chart.add_series(
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :data_labels => { :value => 1, :position => 'center' }
38
+ )
39
+
40
+ chart.add_series( :values => '=Sheet1!$C$1:$C$5' )
41
+
42
+ worksheet.insert_chart('E9', chart)
43
+
44
+ workbook.close
45
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels03 < 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_data_labels03
14
+ @xlsx = 'chart_data_labels03.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'bar', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [45693952, 45762816])
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, :position => 'outside_end' }
33
+ )
34
+
35
+ chart.add_series(
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :data_labels => { :value => 1, :position => 'inside_base' }
38
+ )
39
+
40
+ chart.add_series( :values => '=Sheet1!$C$1:$C$5' )
41
+
42
+ worksheet.insert_chart('E9', chart)
43
+
44
+ workbook.close
45
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels04 < 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_data_labels04
14
+ @xlsx = 'chart_data_labels04.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'bar', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [47719168, 47720704])
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, :position => 'inside_end' }
33
+ )
34
+
35
+ chart.add_series(
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :data_labels => { :value => 1, :position => 'center' }
38
+ )
39
+
40
+ chart.add_series( :values => '=Sheet1!$C$1:$C$5' )
41
+
42
+ worksheet.insert_chart('E9', chart)
43
+
44
+ workbook.close
45
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
46
+ end
47
+ end
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels05 < 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_data_labels05
14
+ @xlsx = 'chart_data_labels05.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
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, [45678592, 45680128])
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, :position => 'right' }
33
+ )
34
+
35
+ chart.add_series(
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :data_labels => { :value => 1, :position => 'top' }
38
+ )
39
+
40
+ chart.add_series(
41
+ :values => '=Sheet1!$C$1:$C$5',
42
+ :data_labels => { :value => 1, :position => 'bottom' }
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels06 < 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_data_labels06
14
+ @xlsx = 'chart_data_labels06.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
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, [45678592, 45680128])
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, :position => 'right' }
33
+ )
34
+
35
+ chart.add_series(
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :data_labels => { :value => 1, :position => 'left' }
38
+ )
39
+
40
+ chart.add_series(
41
+ :values => '=Sheet1!$C$1:$C$5',
42
+ :data_labels => { :value => 1, :position => 'center' }
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
49
+ end
50
+ end
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels07 < 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_data_labels07
14
+ @xlsx = 'chart_data_labels07.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'area', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [45703168, 45705472])
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, :position => 'center' }
33
+ )
34
+
35
+ worksheet.insert_chart('E9', chart)
36
+
37
+ workbook.close
38
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
39
+ end
40
+ end
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels08 < 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_data_labels08
14
+ @xlsx = 'chart_data_labels08.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'scatter', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [45740416, 45705856])
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
+ :data_labels => { :value => 1, :position => 'right' }
34
+ )
35
+
36
+ chart.add_series(
37
+ :categories => '=Sheet1!$A$1:$A$5',
38
+ :values => '=Sheet1!$C$1:$C$5'
39
+ )
40
+
41
+ worksheet.insert_chart('E9', chart)
42
+
43
+ workbook.close
44
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
45
+ end
46
+ end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels09 < 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_data_labels09
14
+ @xlsx = 'chart_data_labels09.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'scatter', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [45740416, 45705856])
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
+ :data_labels => { :value => 1, :position => 'above' }
34
+ )
35
+
36
+ chart.add_series(
37
+ :categories => '=Sheet1!$A$1:$A$5',
38
+ :values => '=Sheet1!$C$1:$C$5',
39
+ :data_labels => { :value => 1, :position => 'below' }
40
+ )
41
+
42
+ worksheet.insert_chart('E9', chart)
43
+
44
+ workbook.close
45
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels10 < 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_data_labels10
14
+ @xlsx = 'chart_data_labels10.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'scatter', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [45740416, 45705856])
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
+ :data_labels => { :value => 1, :position => 'left' }
34
+ )
35
+
36
+ chart.add_series(
37
+ :categories => '=Sheet1!$A$1:$A$5',
38
+ :values => '=Sheet1!$C$1:$C$5',
39
+ :data_labels => { :value => 1, :position => 'center' }
40
+ )
41
+
42
+ worksheet.insert_chart('E9', chart)
43
+
44
+ workbook.close
45
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
46
+ end
47
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDataLabels11 < 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_data_labels11
14
+ @xlsx = 'chart_data_labels11.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
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 => { :value => 1, :leader_lines => 1, :position => 'best_fit' }
30
+ )
31
+
32
+ worksheet.insert_chart('E9', chart)
33
+
34
+ workbook.close
35
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
36
+ end
37
+ end