write_xlsx 0.72.3.beta1 → 0.73.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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/Changes +6 -0
  3. data/README.md +1 -1
  4. data/lib/write_xlsx/chart/axis.rb +15 -1
  5. data/lib/write_xlsx/chart/scatter.rb +1 -1
  6. data/lib/write_xlsx/chart/series.rb +17 -6
  7. data/lib/write_xlsx/chart.rb +60 -12
  8. data/lib/write_xlsx/package/table.rb +10 -9
  9. data/lib/write_xlsx/version.rb +1 -1
  10. data/lib/write_xlsx/workbook.rb +17 -8
  11. data/lib/write_xlsx/worksheet.rb +18 -5
  12. data/test/package/table/test_table01.rb +1 -0
  13. data/test/package/table/test_table02.rb +1 -0
  14. data/test/package/table/test_table03.rb +1 -0
  15. data/test/package/table/test_table04.rb +1 -0
  16. data/test/package/table/test_table05.rb +1 -0
  17. data/test/package/table/test_table06.rb +1 -0
  18. data/test/package/table/test_table07.rb +1 -0
  19. data/test/package/table/test_table08.rb +1 -0
  20. data/test/package/table/test_table09.rb +1 -0
  21. data/test/package/table/test_table10.rb +1 -0
  22. data/test/package/table/test_table11.rb +1 -0
  23. data/test/package/table/test_table12.rb +1 -0
  24. data/test/package/table/test_write_auto_filter.rb +1 -1
  25. data/test/package/table/test_write_table_column.rb +1 -1
  26. data/test/package/table/test_write_table_style_info.rb +1 -1
  27. data/test/regression/test_chart_axis30.rb +44 -0
  28. data/test/regression/test_chart_axis31.rb +44 -0
  29. data/test/regression/test_chart_axis32.rb +44 -0
  30. data/test/regression/test_chart_errorbars08.rb +54 -0
  31. data/test/regression/test_chart_errorbars09.rb +54 -0
  32. data/test/regression/test_chart_errorbars10.rb +56 -0
  33. data/test/regression/test_chart_font07.rb +44 -0
  34. data/test/regression/test_chart_font08.rb +44 -0
  35. data/test/regression/test_chart_scatter12.rb +51 -0
  36. data/test/regression/test_chart_scatter13.rb +51 -0
  37. data/test/regression/test_chart_scatter14.rb +52 -0
  38. data/test/regression/test_comment12.rb +35 -0
  39. data/test/regression/test_table16.rb +37 -0
  40. data/test/regression/xlsx_files/chart_axis30.xlsx +0 -0
  41. data/test/regression/xlsx_files/chart_axis31.xlsx +0 -0
  42. data/test/regression/xlsx_files/chart_axis32.xlsx +0 -0
  43. data/test/regression/xlsx_files/chart_errorbars07.xlsx +0 -0
  44. data/test/regression/xlsx_files/chart_errorbars08.xlsx +0 -0
  45. data/test/regression/xlsx_files/chart_errorbars09.xlsx +0 -0
  46. data/test/regression/xlsx_files/chart_errorbars10.xlsx +0 -0
  47. data/test/regression/xlsx_files/chart_font07.xlsx +0 -0
  48. data/test/regression/xlsx_files/chart_font08.xlsx +0 -0
  49. data/test/regression/xlsx_files/chart_scatter12.xlsx +0 -0
  50. data/test/regression/xlsx_files/chart_scatter14.xlsx +0 -0
  51. data/test/regression/xlsx_files/comment12.xlsx +0 -0
  52. metadata +60 -12
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartAxis32 < 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_axis32
14
+ @xlsx = 'chart_axis32.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, [96171520, 96173056])
21
+ data = [
22
+ [ 1, 2, 3, 4, 5 ],
23
+ [ 2, 4, 6, 8, 10 ],
24
+ [ 3, 6, 9, 12, 15 ]
25
+ ]
26
+
27
+ chart.set_x_axis(:position_axis => 'between')
28
+
29
+ worksheet.write('A1', data)
30
+
31
+ chart.add_series(:values => '=Sheet1!$A$1:$A$5')
32
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
33
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
34
+
35
+ worksheet.insert_chart('E9', chart)
36
+
37
+ workbook.close
38
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx),
39
+ @xlsx,
40
+ nil,
41
+ {}
42
+ )
43
+ end
44
+ end
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartErrorbars08 < 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_errorbars08
14
+ @xlsx = 'chart_errorbars08.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, [69198976, 69200896])
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
+ :y_error_bars => {
34
+ :type => 'custom',
35
+ :plus_values => [1],
36
+ :minus_values => [2]
37
+ }
38
+ )
39
+
40
+ chart.add_series(
41
+ :categories => '=Sheet1!$A$1:$A$5',
42
+ :values => '=Sheet1!$C$1:$C$5'
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+ compare_xlsx_for_regression(
49
+ File.join(@regression_output, @xlsx), @xlsx,
50
+ [],
51
+ {}
52
+ )
53
+ end
54
+ end
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartErrorbars09 < 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_errorbars09
14
+ @xlsx = 'chart_errorbars09.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, [71917952, 71919488])
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
+ :y_error_bars => {
34
+ :type => 'custom',
35
+ :plus_values => [1, 2, 3],
36
+ :minus_values => [2, 4, 6]
37
+ }
38
+ )
39
+
40
+ chart.add_series(
41
+ :categories => '=Sheet1!$A$1:$A$5',
42
+ :values => '=Sheet1!$C$1:$C$5'
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+ compare_xlsx_for_regression(
49
+ File.join(@regression_output, @xlsx), @xlsx,
50
+ [],
51
+ {}
52
+ )
53
+ end
54
+ end
@@ -0,0 +1,56 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartErrorbars10 < 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_errorbars10
14
+ @xlsx = 'chart_errorbars10.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, [69198976, 69200896])
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
+ :y_error_bars => {
34
+ :type => 'custom',
35
+ :plus_values => '=Sheet1!$A$1',
36
+ :minus_values => '=Sheet1!$B$1:$B$3',
37
+ :plus_data => [1],
38
+ :minus_data => [2, 4, 6]
39
+ }
40
+ )
41
+
42
+ chart.add_series(
43
+ :categories => '=Sheet1!$A$1:$A$5',
44
+ :values => '=Sheet1!$C$1:$C$5'
45
+ )
46
+
47
+ worksheet.insert_chart('E9', chart)
48
+
49
+ workbook.close
50
+ compare_xlsx_for_regression(
51
+ File.join(@regression_output, @xlsx), @xlsx,
52
+ [],
53
+ {}
54
+ )
55
+ end
56
+ end
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartFont07 < 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_font07
14
+ @xlsx = 'chart_font07.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, [69215744, 69217280])
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(:values => '=Sheet1!$A$1:$A$5')
31
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
32
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
33
+
34
+ chart.set_legend(:font => {:size => 9, :baseline => -1})
35
+
36
+ worksheet.insert_chart('E9', chart)
37
+
38
+ workbook.close
39
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
40
+ nil,
41
+ {}
42
+ )
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartFont08 < 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_font08
14
+ @xlsx = 'chart_font08.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, [69199744, 69214976])
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(:values => '=Sheet1!$A$1:$A$5')
31
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
32
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
33
+
34
+ chart.set_legend(:font => {:bold => 1, :italic => 1, :baseline => -1})
35
+
36
+ worksheet.insert_chart('E9', chart)
37
+
38
+ workbook.close
39
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
40
+ nil,
41
+ {}
42
+ )
43
+ end
44
+ end
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartScatter12 < 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_scatter12
14
+ @xlsx = 'chart_scatter12.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(
18
+ :type => 'scatter',
19
+ :embedded => 1,
20
+ :subtype => 'straight'
21
+ )
22
+
23
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
24
+ chart.instance_variable_set(:@axis_ids, [69472640, 69216896])
25
+
26
+ data = [
27
+ [1, 2, 3, 4, 5],
28
+ [2, 4, 6, 8, 10],
29
+ [3, 6, 9, 12, 15]
30
+ ]
31
+
32
+ worksheet.write('A1', data)
33
+
34
+ chart.add_series(
35
+ :categories => '=Sheet1!$A$1:$A$5',
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :marker => { :type => 'automatic' }
38
+ )
39
+
40
+ chart.add_series(
41
+ :categories => '=Sheet1!$A$1:$A$5',
42
+ :values => '=Sheet1!$C$1:$C$5'
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+
49
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
50
+ end
51
+ end
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartScatter13 < 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_scatter13
14
+ @xlsx = 'chart_scatter12.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(
18
+ :type => 'scatter',
19
+ :embedded => 1,
20
+ :subtype => 'straight_with_markers'
21
+ )
22
+
23
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
24
+ chart.instance_variable_set(:@axis_ids, [69472640, 69216896])
25
+
26
+ data = [
27
+ [1, 2, 3, 4, 5],
28
+ [2, 4, 6, 8, 10],
29
+ [3, 6, 9, 12, 15]
30
+ ]
31
+
32
+ worksheet.write('A1', data)
33
+
34
+ chart.add_series(
35
+ :categories => '=Sheet1!$A$1:$A$5',
36
+ :values => '=Sheet1!$B$1:$B$5'
37
+ )
38
+
39
+ chart.add_series(
40
+ :categories => '=Sheet1!$A$1:$A$5',
41
+ :values => '=Sheet1!$C$1:$C$5',
42
+ :marker => { :type => 'none' }
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+
49
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
50
+ end
51
+ end
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartScatter14 < 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_scatter14
14
+ @xlsx = 'chart_scatter14.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(
18
+ :type => 'scatter',
19
+ :subtype => 'straight',
20
+ :embedded => 1
21
+ )
22
+
23
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
24
+ chart.instance_variable_set(:@axis_ids, [69216512, 69214976])
25
+
26
+ data = [
27
+ [1, 2, 3, 4, 5],
28
+ [2, 4, 6, 8, 10],
29
+ [3, 6, 9, 12, 15]
30
+ ]
31
+
32
+ worksheet.write('A1', data)
33
+
34
+ chart.add_series(
35
+ :categories => '=Sheet1!$A$1:$A$5',
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :marker => { :type => 'star', :size => 5 }
38
+ )
39
+
40
+ chart.add_series(
41
+ :categories => '=Sheet1!$A$1:$A$5',
42
+ :values => '=Sheet1!$C$1:$C$5',
43
+ :marker => { :type => 'plus', :size => 5 }
44
+ )
45
+
46
+ worksheet.insert_chart('E9', chart)
47
+
48
+ workbook.close
49
+
50
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
51
+ end
52
+ end
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionComment12 < 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_comment12
14
+ @xlsx = 'comment12.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.set_row(0, 21)
19
+ worksheet.set_column('B:B', 10)
20
+
21
+ worksheet.write('A1', 'Foo')
22
+ worksheet.write_comment('A1', 'Some text')
23
+
24
+ # Set the author to match the target XLSX file.
25
+ worksheet.comments_author = 'John'
26
+
27
+ workbook.close
28
+ compare_xlsx_for_regression(
29
+ File.join(@regression_output, @xlsx),
30
+ @xlsx,
31
+ [],
32
+ {}
33
+ )
34
+ end
35
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionTable16 < 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_table16
14
+ @xlsx = 'table02.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet1 = workbook.add_worksheet
17
+ worksheet2 = workbook.add_worksheet
18
+
19
+ # Set the column width to match the taget worksheet.
20
+ worksheet1.set_column('B:J', 10.288)
21
+ worksheet2.set_column('C:L', 10.288)
22
+
23
+ # Add the tables in reverse order to test_table02.rb
24
+ worksheet2.add_table('I4:L11')
25
+ worksheet2.add_table('C16:H23')
26
+
27
+ worksheet1.add_table('B3:E11')
28
+ worksheet1.add_table('G10:J16')
29
+ worksheet1.add_table('C18:F25')
30
+
31
+ workbook.close
32
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
33
+ nil,
34
+ { 'xl/workbook.xml' => ['<workbookView'] }
35
+ )
36
+ end
37
+ end