write_xlsx 0.54.0 → 0.55.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestSparkline01 < Test::Unit::TestCase
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet
10
+ end
11
+
12
+ def test_sparkline01
13
+ @worksheet.instance_variable_set(:@excel_version, 2010)
14
+ @worksheet.select
15
+
16
+ data = [-2, 2, 3, -1, 0]
17
+
18
+ @worksheet.write('A1', data)
19
+
20
+ # Set up sparklines
21
+
22
+ # No sparkline in the first testcase.
23
+
24
+ # End sparklines
25
+
26
+ @worksheet.assemble_xml_file
27
+ result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
28
+
29
+ expected = expected_to_array(expected_xml)
30
+ assert_equal(expected, result)
31
+ end
32
+
33
+ def expected_xml
34
+ <<EOS
35
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
36
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
37
+ <dimension ref="A1:E1"/>
38
+ <sheetViews>
39
+ <sheetView tabSelected="1" workbookViewId="0"/>
40
+ </sheetViews>
41
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
42
+ <sheetData>
43
+ <row r="1" spans="1:5" x14ac:dyDescent="0.25">
44
+ <c r="A1">
45
+ <v>-2</v>
46
+ </c>
47
+ <c r="B1">
48
+ <v>2</v>
49
+ </c>
50
+ <c r="C1">
51
+ <v>3</v>
52
+ </c>
53
+ <c r="D1">
54
+ <v>-1</v>
55
+ </c>
56
+ <c r="E1">
57
+ <v>0</v>
58
+ </c>
59
+ </row>
60
+ </sheetData>
61
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
62
+ </worksheet>
63
+ EOS
64
+ end
65
+ end
@@ -0,0 +1,92 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestSparkline02 < Test::Unit::TestCase
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet
10
+ end
11
+
12
+ def test_sparkline02
13
+ @worksheet.instance_variable_set(:@excel_version, 2010)
14
+ @worksheet.select
15
+
16
+ data = [-2, 2, 3, -1, 0]
17
+
18
+ @worksheet.write('A1', data)
19
+
20
+ # Set up sparklines
21
+
22
+ @worksheet.add_sparkline(
23
+ {
24
+ :location => 'F1',
25
+ :range => 'Sheet1!A1:E1'
26
+ }
27
+ )
28
+
29
+ # End sparklines
30
+
31
+ @worksheet.assemble_xml_file
32
+ result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
33
+
34
+ expected = expected_to_array(expected_xml)
35
+ assert_equal(expected, result)
36
+ end
37
+
38
+ def expected_xml
39
+ <<EOS
40
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
41
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
42
+ <dimension ref="A1:E1"/>
43
+ <sheetViews>
44
+ <sheetView tabSelected="1" workbookViewId="0"/>
45
+ </sheetViews>
46
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
47
+ <sheetData>
48
+ <row r="1" spans="1:5" x14ac:dyDescent="0.25">
49
+ <c r="A1">
50
+ <v>-2</v>
51
+ </c>
52
+ <c r="B1">
53
+ <v>2</v>
54
+ </c>
55
+ <c r="C1">
56
+ <v>3</v>
57
+ </c>
58
+ <c r="D1">
59
+ <v>-1</v>
60
+ </c>
61
+ <c r="E1">
62
+ <v>0</v>
63
+ </c>
64
+ </row>
65
+ </sheetData>
66
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
67
+ <extLst>
68
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}">
69
+ <x14:sparklineGroups xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
70
+ <x14:sparklineGroup displayEmptyCellsAs="gap">
71
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
72
+ <x14:colorNegative theme="5"/>
73
+ <x14:colorAxis rgb="FF000000"/>
74
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
75
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
76
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
77
+ <x14:colorHigh theme="4"/>
78
+ <x14:colorLow theme="4"/>
79
+ <x14:sparklines>
80
+ <x14:sparkline>
81
+ <xm:f>Sheet1!A1:E1</xm:f>
82
+ <xm:sqref>F1</xm:sqref>
83
+ </x14:sparkline>
84
+ </x14:sparklines>
85
+ </x14:sparklineGroup>
86
+ </x14:sparklineGroups>
87
+ </ext>
88
+ </extLst>
89
+ </worksheet>
90
+ EOS
91
+ end
92
+ end
@@ -0,0 +1,133 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestSparkline03 < Test::Unit::TestCase
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet
10
+ end
11
+
12
+ def test_sparkline03
13
+ @worksheet.instance_variable_set(:@excel_version, 2010)
14
+ @worksheet.select
15
+
16
+ data = [-2, 2, 3, -1, 0]
17
+
18
+ @worksheet.write('A1', data)
19
+ @worksheet.write('A2', data)
20
+
21
+ # Set up sparklines
22
+
23
+ @worksheet.add_sparkline(
24
+ {
25
+ :location => 'F1',
26
+ :range => 'Sheet1!A1:E1'
27
+ }
28
+ )
29
+
30
+ @worksheet.add_sparkline(
31
+ {
32
+ :location => 'F2',
33
+ :range => 'Sheet1!A2:E2'
34
+ }
35
+ )
36
+
37
+ # End sparklines
38
+
39
+ @worksheet.assemble_xml_file
40
+ result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
41
+
42
+ expected = expected_to_array(expected_xml)
43
+ assert_equal(expected, result)
44
+ end
45
+
46
+ def expected_xml
47
+ <<EOS
48
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
49
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
50
+ <dimension ref="A1:E2"/>
51
+ <sheetViews>
52
+ <sheetView tabSelected="1" workbookViewId="0"/>
53
+ </sheetViews>
54
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
55
+ <sheetData>
56
+ <row r="1" spans="1:5" x14ac:dyDescent="0.25">
57
+ <c r="A1">
58
+ <v>-2</v>
59
+ </c>
60
+ <c r="B1">
61
+ <v>2</v>
62
+ </c>
63
+ <c r="C1">
64
+ <v>3</v>
65
+ </c>
66
+ <c r="D1">
67
+ <v>-1</v>
68
+ </c>
69
+ <c r="E1">
70
+ <v>0</v>
71
+ </c>
72
+ </row>
73
+ <row r="2" spans="1:5" x14ac:dyDescent="0.25">
74
+ <c r="A2">
75
+ <v>-2</v>
76
+ </c>
77
+ <c r="B2">
78
+ <v>2</v>
79
+ </c>
80
+ <c r="C2">
81
+ <v>3</v>
82
+ </c>
83
+ <c r="D2">
84
+ <v>-1</v>
85
+ </c>
86
+ <c r="E2">
87
+ <v>0</v>
88
+ </c>
89
+ </row>
90
+ </sheetData>
91
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
92
+ <extLst>
93
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}">
94
+ <x14:sparklineGroups xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
95
+ <x14:sparklineGroup displayEmptyCellsAs="gap">
96
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
97
+ <x14:colorNegative theme="5"/>
98
+ <x14:colorAxis rgb="FF000000"/>
99
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
100
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
101
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
102
+ <x14:colorHigh theme="4"/>
103
+ <x14:colorLow theme="4"/>
104
+ <x14:sparklines>
105
+ <x14:sparkline>
106
+ <xm:f>Sheet1!A2:E2</xm:f>
107
+ <xm:sqref>F2</xm:sqref>
108
+ </x14:sparkline>
109
+ </x14:sparklines>
110
+ </x14:sparklineGroup>
111
+ <x14:sparklineGroup displayEmptyCellsAs="gap">
112
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
113
+ <x14:colorNegative theme="5"/>
114
+ <x14:colorAxis rgb="FF000000"/>
115
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
116
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
117
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
118
+ <x14:colorHigh theme="4"/>
119
+ <x14:colorLow theme="4"/>
120
+ <x14:sparklines>
121
+ <x14:sparkline>
122
+ <xm:f>Sheet1!A1:E1</xm:f>
123
+ <xm:sqref>F1</xm:sqref>
124
+ </x14:sparkline>
125
+ </x14:sparklines>
126
+ </x14:sparklineGroup>
127
+ </x14:sparklineGroups>
128
+ </ext>
129
+ </extLst>
130
+ </worksheet>
131
+ EOS
132
+ end
133
+ end
@@ -0,0 +1,93 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestSparkline04 < Test::Unit::TestCase
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet
10
+ end
11
+
12
+ def test_sparkline04
13
+ @worksheet.instance_variable_set(:@excel_version, 2010)
14
+ @worksheet.select
15
+
16
+ data = [-2, 2, 3, -1, 0]
17
+
18
+ @worksheet.write('A1', data)
19
+
20
+ # Set up sparklines
21
+
22
+ @worksheet.add_sparkline(
23
+ {
24
+ :location => 'F1',
25
+ :range => 'Sheet1!A1:E1',
26
+ :type => 'column'
27
+ }
28
+ )
29
+
30
+ # End sparklines
31
+
32
+ @worksheet.assemble_xml_file
33
+ result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
34
+
35
+ expected = expected_to_array(expected_xml)
36
+ assert_equal(expected, result)
37
+ end
38
+
39
+ def expected_xml
40
+ <<EOS
41
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
42
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
43
+ <dimension ref="A1:E1"/>
44
+ <sheetViews>
45
+ <sheetView tabSelected="1" workbookViewId="0"/>
46
+ </sheetViews>
47
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
48
+ <sheetData>
49
+ <row r="1" spans="1:5" x14ac:dyDescent="0.25">
50
+ <c r="A1">
51
+ <v>-2</v>
52
+ </c>
53
+ <c r="B1">
54
+ <v>2</v>
55
+ </c>
56
+ <c r="C1">
57
+ <v>3</v>
58
+ </c>
59
+ <c r="D1">
60
+ <v>-1</v>
61
+ </c>
62
+ <c r="E1">
63
+ <v>0</v>
64
+ </c>
65
+ </row>
66
+ </sheetData>
67
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
68
+ <extLst>
69
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}">
70
+ <x14:sparklineGroups xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
71
+ <x14:sparklineGroup type="column" displayEmptyCellsAs="gap">
72
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
73
+ <x14:colorNegative theme="5"/>
74
+ <x14:colorAxis rgb="FF000000"/>
75
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
76
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
77
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
78
+ <x14:colorHigh theme="4"/>
79
+ <x14:colorLow theme="4"/>
80
+ <x14:sparklines>
81
+ <x14:sparkline>
82
+ <xm:f>Sheet1!A1:E1</xm:f>
83
+ <xm:sqref>F1</xm:sqref>
84
+ </x14:sparkline>
85
+ </x14:sparklines>
86
+ </x14:sparklineGroup>
87
+ </x14:sparklineGroups>
88
+ </ext>
89
+ </extLst>
90
+ </worksheet>
91
+ EOS
92
+ end
93
+ end
@@ -0,0 +1,93 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestSparkline05 < Test::Unit::TestCase
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet
10
+ end
11
+
12
+ def test_sparkline05
13
+ @worksheet.instance_variable_set(:@excel_version, 2010)
14
+ @worksheet.select
15
+
16
+ data = [-2, 2, 3, -1, 0]
17
+
18
+ @worksheet.write('A1', data)
19
+
20
+ # Set up sparklines
21
+
22
+ @worksheet.add_sparkline(
23
+ {
24
+ :location => ['$F$1'],
25
+ :range => ['$A$1:$E$1'],
26
+ :type => 'win_loss'
27
+ }
28
+ )
29
+
30
+ # End sparklines
31
+
32
+ @worksheet.assemble_xml_file
33
+ result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
34
+
35
+ expected = expected_to_array(expected_xml)
36
+ assert_equal(expected, result)
37
+ end
38
+
39
+ def expected_xml
40
+ <<EOS
41
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
42
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
43
+ <dimension ref="A1:E1"/>
44
+ <sheetViews>
45
+ <sheetView tabSelected="1" workbookViewId="0"/>
46
+ </sheetViews>
47
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
48
+ <sheetData>
49
+ <row r="1" spans="1:5" x14ac:dyDescent="0.25">
50
+ <c r="A1">
51
+ <v>-2</v>
52
+ </c>
53
+ <c r="B1">
54
+ <v>2</v>
55
+ </c>
56
+ <c r="C1">
57
+ <v>3</v>
58
+ </c>
59
+ <c r="D1">
60
+ <v>-1</v>
61
+ </c>
62
+ <c r="E1">
63
+ <v>0</v>
64
+ </c>
65
+ </row>
66
+ </sheetData>
67
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
68
+ <extLst>
69
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}">
70
+ <x14:sparklineGroups xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
71
+ <x14:sparklineGroup type="stacked" displayEmptyCellsAs="gap">
72
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
73
+ <x14:colorNegative theme="5"/>
74
+ <x14:colorAxis rgb="FF000000"/>
75
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
76
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
77
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
78
+ <x14:colorHigh theme="4"/>
79
+ <x14:colorLow theme="4"/>
80
+ <x14:sparklines>
81
+ <x14:sparkline>
82
+ <xm:f>Sheet1!A1:E1</xm:f>
83
+ <xm:sqref>F1</xm:sqref>
84
+ </x14:sparkline>
85
+ </x14:sparklines>
86
+ </x14:sparklineGroup>
87
+ </x14:sparklineGroups>
88
+ </ext>
89
+ </extLst>
90
+ </worksheet>
91
+ EOS
92
+ end
93
+ end