write_xlsx 0.90.0 → 0.97.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 (135) hide show
  1. checksums.yaml +4 -4
  2. data/Changes +37 -0
  3. data/README.md +1 -1
  4. data/examples/a_simple.rb +1 -6
  5. data/examples/conditional_format.rb +73 -46
  6. data/examples/demo.rb +1 -7
  7. data/examples/hyperlink1.rb +4 -11
  8. data/lib/write_xlsx/chart.rb +81 -205
  9. data/lib/write_xlsx/chart/axis.rb +2 -2
  10. data/lib/write_xlsx/chart/caption.rb +3 -1
  11. data/lib/write_xlsx/chart/pie.rb +2 -0
  12. data/lib/write_xlsx/chart/series.rb +11 -7
  13. data/lib/write_xlsx/format.rb +15 -11
  14. data/lib/write_xlsx/package/conditional_format.rb +351 -38
  15. data/lib/write_xlsx/package/content_types.rb +10 -0
  16. data/lib/write_xlsx/package/custom.rb +125 -0
  17. data/lib/write_xlsx/package/packager.rb +26 -0
  18. data/lib/write_xlsx/package/styles.rb +53 -21
  19. data/lib/write_xlsx/package/table.rb +11 -4
  20. data/lib/write_xlsx/utility.rb +234 -34
  21. data/lib/write_xlsx/version.rb +1 -1
  22. data/lib/write_xlsx/workbook.rb +88 -1
  23. data/lib/write_xlsx/worksheet.rb +247 -23
  24. data/test/helper.rb +6 -1
  25. data/test/regression/_test_hyperlink31.rb +26 -0
  26. data/test/regression/images/zero_dpi.jpg +0 -0
  27. data/test/regression/test_chart_bar08.rb +3 -0
  28. data/test/regression/test_chart_bar11.rb +3 -0
  29. data/test/regression/test_chart_bar14.rb +3 -0
  30. data/test/regression/test_chart_chartarea05.rb +16 -17
  31. data/test/regression/test_chart_chartarea06.rb +49 -0
  32. data/test/regression/test_chart_data_labels25.rb +61 -0
  33. data/test/regression/test_chart_format26.rb +48 -0
  34. data/test/regression/test_chart_format27.rb +58 -0
  35. data/test/regression/test_chart_format28.rb +52 -0
  36. data/test/regression/test_chart_format29.rb +59 -0
  37. data/test/regression/test_chart_format30.rb +53 -0
  38. data/test/regression/test_chart_format31.rb +60 -0
  39. data/test/regression/test_chart_table03.rb +56 -0
  40. data/test/regression/test_cond_format14.rb +42 -0
  41. data/test/regression/test_cond_format15.rb +53 -0
  42. data/test/regression/test_cond_format16.rb +53 -0
  43. data/test/regression/test_cond_format17.rb +37 -0
  44. data/test/regression/test_cond_format18.rb +136 -0
  45. data/test/regression/test_date_1904_01.rb +1 -1
  46. data/test/regression/test_escapes04.rb +3 -0
  47. data/test/regression/test_escapes05.rb +3 -0
  48. data/test/regression/test_escapes07.rb +3 -0
  49. data/test/regression/test_escapes08.rb +3 -0
  50. data/test/regression/test_hyperlink01.rb +3 -0
  51. data/test/regression/test_hyperlink02.rb +3 -0
  52. data/test/regression/test_hyperlink03.rb +4 -0
  53. data/test/regression/test_hyperlink04.rb +3 -0
  54. data/test/regression/test_hyperlink05.rb +3 -0
  55. data/test/regression/test_hyperlink06.rb +3 -0
  56. data/test/regression/test_hyperlink07.rb +3 -0
  57. data/test/regression/test_hyperlink08.rb +3 -0
  58. data/test/regression/test_hyperlink09.rb +3 -0
  59. data/test/regression/test_hyperlink10.rb +3 -0
  60. data/test/regression/test_hyperlink11.rb +3 -0
  61. data/test/regression/test_hyperlink12.rb +3 -0
  62. data/test/regression/test_hyperlink13.rb +3 -0
  63. data/test/regression/test_hyperlink14.rb +3 -0
  64. data/test/regression/test_hyperlink15.rb +3 -0
  65. data/test/regression/test_hyperlink16.rb +3 -0
  66. data/test/regression/test_hyperlink17.rb +3 -0
  67. data/test/regression/test_hyperlink18.rb +3 -0
  68. data/test/regression/test_hyperlink20.rb +3 -0
  69. data/test/regression/test_hyperlink21.rb +3 -0
  70. data/test/regression/test_hyperlink22.rb +3 -0
  71. data/test/regression/test_hyperlink23.rb +3 -0
  72. data/test/regression/test_hyperlink24.rb +3 -0
  73. data/test/regression/test_hyperlink25.rb +3 -0
  74. data/test/regression/test_hyperlink26.rb +3 -0
  75. data/test/regression/test_hyperlink27.rb +3 -0
  76. data/test/regression/test_hyperlink28.rb +50 -0
  77. data/test/regression/test_hyperlink29.rb +27 -0
  78. data/test/regression/test_hyperlink30.rb +36 -0
  79. data/test/regression/test_image35.rb +26 -0
  80. data/test/regression/test_properties01.rb +1 -4
  81. data/test/regression/test_properties02.rb +1 -4
  82. data/test/regression/test_properties03.rb +26 -0
  83. data/test/regression/test_properties04.rb +61 -0
  84. data/test/regression/test_properties05.rb +30 -0
  85. data/test/regression/test_table03.rb +3 -0
  86. data/test/regression/test_table04.rb +3 -0
  87. data/test/regression/test_table05.rb +3 -0
  88. data/test/regression/test_table06.rb +3 -0
  89. data/test/regression/test_table20.rb +34 -0
  90. data/test/regression/test_table21.rb +36 -0
  91. data/test/regression/test_table22.rb +32 -0
  92. data/test/regression/xlsx_files/chart_chartarea05.xlsx +0 -0
  93. data/test/regression/xlsx_files/chart_chartarea06.xlsx +0 -0
  94. data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
  95. data/test/regression/xlsx_files/chart_format26.xlsx +0 -0
  96. data/test/regression/xlsx_files/chart_format27.xlsx +0 -0
  97. data/test/regression/xlsx_files/chart_format28.xlsx +0 -0
  98. data/test/regression/xlsx_files/chart_format29.xlsx +0 -0
  99. data/test/regression/xlsx_files/chart_format30.xlsx +0 -0
  100. data/test/regression/xlsx_files/chart_format31.xlsx +0 -0
  101. data/test/regression/xlsx_files/chart_table03.xlsx +0 -0
  102. data/test/regression/xlsx_files/cond_format14.xlsx +0 -0
  103. data/test/regression/xlsx_files/cond_format15.xlsx +0 -0
  104. data/test/regression/xlsx_files/cond_format16.xlsx +0 -0
  105. data/test/regression/xlsx_files/cond_format17.xlsx +0 -0
  106. data/test/regression/xlsx_files/cond_format18.xlsx +0 -0
  107. data/test/regression/xlsx_files/date_1904_01.xlsx +0 -0
  108. data/test/regression/xlsx_files/hyperlink28.xlsx +0 -0
  109. data/test/regression/xlsx_files/hyperlink29.xlsx +0 -0
  110. data/test/regression/xlsx_files/hyperlink30.xlsx +0 -0
  111. data/test/regression/xlsx_files/hyperlink31.xlsx +0 -0
  112. data/test/regression/xlsx_files/image35.xlsx +0 -0
  113. data/test/regression/xlsx_files/properties03.xlsx +0 -0
  114. data/test/regression/xlsx_files/properties04.xlsx +0 -0
  115. data/test/regression/xlsx_files/properties05.xlsx +0 -0
  116. data/test/regression/xlsx_files/table21.xlsx +0 -0
  117. data/test/regression/xlsx_files/table22.xlsx +0 -0
  118. data/test/workbook/test_write_workbook_view.rb +81 -0
  119. data/test/worksheet/test_cond_format_22.rb +266 -0
  120. data/test/worksheet/test_cond_format_23.rb +242 -0
  121. data/test/worksheet/test_cond_format_24.rb +303 -0
  122. data/test/worksheet/test_data_bar_01.rb +53 -0
  123. data/test/worksheet/test_data_bar_02.rb +79 -0
  124. data/test/worksheet/test_data_bar_03.rb +147 -0
  125. data/test/worksheet/test_data_bar_04.rb +145 -0
  126. data/test/worksheet/test_data_bar_05.rb +147 -0
  127. data/test/worksheet/test_data_bar_06.rb +145 -0
  128. data/test/worksheet/test_data_bar_07.rb +146 -0
  129. data/test/worksheet/test_data_bar_08.rb +54 -0
  130. data/test/worksheet/test_data_bar_09.rb +80 -0
  131. data/test/worksheet/test_data_bar_10.rb +165 -0
  132. data/test/worksheet/test_data_bar_11.rb +167 -0
  133. data/test/worksheet/test_data_bar_12.rb +104 -0
  134. data/test/worksheet/test_write_data_validation_02.rb +27 -0
  135. metadata +135 -2
@@ -0,0 +1,145 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestWorksheetDataBar04 < Minitest::Test
5
+ def setup
6
+ @workbook = WriteXLSX.new(StringIO.new)
7
+ @worksheet = @workbook.add_worksheet('')
8
+ end
9
+
10
+ ###############################################################################
11
+ #
12
+ # Tests for WriteXLSX::Worksheet methods.
13
+ #
14
+ #
15
+ def test_data_bar_04
16
+ @worksheet.select
17
+ @worksheet.instance_variable_set(:@index, 0)
18
+
19
+ @worksheet.conditional_formatting(
20
+ 'A1',
21
+ :type => 'data_bar',
22
+ :bar_solid => 1
23
+ )
24
+
25
+ @worksheet.conditional_formatting(
26
+ 'A2:B2',
27
+ :type => 'data_bar',
28
+ :bar_color => '#63C384',
29
+ :bar_no_border => 1
30
+ )
31
+
32
+ @worksheet.conditional_formatting(
33
+ 'A3:C3',
34
+ :type => 'data_bar',
35
+ :bar_color => '#FF555A',
36
+ :bar_border_color => '#FF0000'
37
+ )
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"/>
51
+ <sheetViews>
52
+ <sheetView tabSelected="1" workbookViewId="0"/>
53
+ </sheetViews>
54
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
55
+ <sheetData/>
56
+ <conditionalFormatting sqref="A1">
57
+ <cfRule type="dataBar" priority="1">
58
+ <dataBar>
59
+ <cfvo type="min"/>
60
+ <cfvo type="max"/>
61
+ <color rgb="FF638EC6"/>
62
+ </dataBar>
63
+ <extLst>
64
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
65
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000001}</x14:id>
66
+ </ext>
67
+ </extLst>
68
+ </cfRule>
69
+ </conditionalFormatting>
70
+ <conditionalFormatting sqref="A2:B2">
71
+ <cfRule type="dataBar" priority="2">
72
+ <dataBar>
73
+ <cfvo type="min"/>
74
+ <cfvo type="max"/>
75
+ <color rgb="FF63C384"/>
76
+ </dataBar>
77
+ <extLst>
78
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
79
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000002}</x14:id>
80
+ </ext>
81
+ </extLst>
82
+ </cfRule>
83
+ </conditionalFormatting>
84
+ <conditionalFormatting sqref="A3:C3">
85
+ <cfRule type="dataBar" priority="3">
86
+ <dataBar>
87
+ <cfvo type="min"/>
88
+ <cfvo type="max"/>
89
+ <color rgb="FFFF555A"/>
90
+ </dataBar>
91
+ <extLst>
92
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
93
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000003}</x14:id>
94
+ </ext>
95
+ </extLst>
96
+ </cfRule>
97
+ </conditionalFormatting>
98
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
99
+ <extLst>
100
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{78C0D931-6437-407d-A8EE-F0AAD7539E65}">
101
+ <x14:conditionalFormattings>
102
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
103
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000001}">
104
+ <x14:dataBar minLength="0" maxLength="100" border="1" gradient="0" negativeBarBorderColorSameAsPositive="0">
105
+ <x14:cfvo type="autoMin"/>
106
+ <x14:cfvo type="autoMax"/>
107
+ <x14:borderColor rgb="FF638EC6"/>
108
+ <x14:negativeFillColor rgb="FFFF0000"/>
109
+ <x14:negativeBorderColor rgb="FFFF0000"/>
110
+ <x14:axisColor rgb="FF000000"/>
111
+ </x14:dataBar>
112
+ </x14:cfRule>
113
+ <xm:sqref>A1</xm:sqref>
114
+ </x14:conditionalFormatting>
115
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
116
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000002}">
117
+ <x14:dataBar minLength="0" maxLength="100">
118
+ <x14:cfvo type="autoMin"/>
119
+ <x14:cfvo type="autoMax"/>
120
+ <x14:negativeFillColor rgb="FFFF0000"/>
121
+ <x14:axisColor rgb="FF000000"/>
122
+ </x14:dataBar>
123
+ </x14:cfRule>
124
+ <xm:sqref>A2:B2</xm:sqref>
125
+ </x14:conditionalFormatting>
126
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
127
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000003}">
128
+ <x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0">
129
+ <x14:cfvo type="autoMin"/>
130
+ <x14:cfvo type="autoMax"/>
131
+ <x14:borderColor rgb="FFFF0000"/>
132
+ <x14:negativeFillColor rgb="FFFF0000"/>
133
+ <x14:negativeBorderColor rgb="FFFF0000"/>
134
+ <x14:axisColor rgb="FF000000"/>
135
+ </x14:dataBar>
136
+ </x14:cfRule>
137
+ <xm:sqref>A3:C3</xm:sqref>
138
+ </x14:conditionalFormatting>
139
+ </x14:conditionalFormattings>
140
+ </ext>
141
+ </extLst>
142
+ </worksheet>
143
+ EOS
144
+ end
145
+ end
@@ -0,0 +1,147 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestWorksheetDataBar05 < Minitest::Test
5
+ def setup
6
+ @workbook = WriteXLSX.new(StringIO.new)
7
+ @worksheet = @workbook.add_worksheet('')
8
+ end
9
+
10
+ ###############################################################################
11
+ #
12
+ # Tests for WriteXLSX::Worksheet methods.
13
+ #
14
+ #
15
+ def test_data_bar_05
16
+ @worksheet.select
17
+ @worksheet.instance_variable_set(:@index, 0)
18
+
19
+ @worksheet.conditional_formatting(
20
+ 'A1',
21
+ :type => 'data_bar',
22
+ :bar_direction => 'left'
23
+ )
24
+
25
+ @worksheet.conditional_formatting(
26
+ 'A2:B2',
27
+ :type => 'data_bar',
28
+ :bar_color => '#63C384',
29
+ :bar_direction => 'right'
30
+ )
31
+
32
+ @worksheet.conditional_formatting(
33
+ 'A3:C3',
34
+ :type => 'data_bar',
35
+ :bar_color => '#FF555A',
36
+ :bar_negative_color => '#FFFF00'
37
+ )
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"/>
51
+ <sheetViews>
52
+ <sheetView tabSelected="1" workbookViewId="0"/>
53
+ </sheetViews>
54
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
55
+ <sheetData/>
56
+ <conditionalFormatting sqref="A1">
57
+ <cfRule type="dataBar" priority="1">
58
+ <dataBar>
59
+ <cfvo type="min"/>
60
+ <cfvo type="max"/>
61
+ <color rgb="FF638EC6"/>
62
+ </dataBar>
63
+ <extLst>
64
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
65
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000001}</x14:id>
66
+ </ext>
67
+ </extLst>
68
+ </cfRule>
69
+ </conditionalFormatting>
70
+ <conditionalFormatting sqref="A2:B2">
71
+ <cfRule type="dataBar" priority="2">
72
+ <dataBar>
73
+ <cfvo type="min"/>
74
+ <cfvo type="max"/>
75
+ <color rgb="FF63C384"/>
76
+ </dataBar>
77
+ <extLst>
78
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
79
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000002}</x14:id>
80
+ </ext>
81
+ </extLst>
82
+ </cfRule>
83
+ </conditionalFormatting>
84
+ <conditionalFormatting sqref="A3:C3">
85
+ <cfRule type="dataBar" priority="3">
86
+ <dataBar>
87
+ <cfvo type="min"/>
88
+ <cfvo type="max"/>
89
+ <color rgb="FFFF555A"/>
90
+ </dataBar>
91
+ <extLst>
92
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
93
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000003}</x14:id>
94
+ </ext>
95
+ </extLst>
96
+ </cfRule>
97
+ </conditionalFormatting>
98
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
99
+ <extLst>
100
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{78C0D931-6437-407d-A8EE-F0AAD7539E65}">
101
+ <x14:conditionalFormattings>
102
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
103
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000001}">
104
+ <x14:dataBar minLength="0" maxLength="100" border="1" direction="leftToRight" negativeBarBorderColorSameAsPositive="0">
105
+ <x14:cfvo type="autoMin"/>
106
+ <x14:cfvo type="autoMax"/>
107
+ <x14:borderColor rgb="FF638EC6"/>
108
+ <x14:negativeFillColor rgb="FFFF0000"/>
109
+ <x14:negativeBorderColor rgb="FFFF0000"/>
110
+ <x14:axisColor rgb="FF000000"/>
111
+ </x14:dataBar>
112
+ </x14:cfRule>
113
+ <xm:sqref>A1</xm:sqref>
114
+ </x14:conditionalFormatting>
115
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
116
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000002}">
117
+ <x14:dataBar minLength="0" maxLength="100" border="1" direction="rightToLeft" negativeBarBorderColorSameAsPositive="0">
118
+ <x14:cfvo type="autoMin"/>
119
+ <x14:cfvo type="autoMax"/>
120
+ <x14:borderColor rgb="FF63C384"/>
121
+ <x14:negativeFillColor rgb="FFFF0000"/>
122
+ <x14:negativeBorderColor rgb="FFFF0000"/>
123
+ <x14:axisColor rgb="FF000000"/>
124
+ </x14:dataBar>
125
+ </x14:cfRule>
126
+ <xm:sqref>A2:B2</xm:sqref>
127
+ </x14:conditionalFormatting>
128
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
129
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000003}">
130
+ <x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0">
131
+ <x14:cfvo type="autoMin"/>
132
+ <x14:cfvo type="autoMax"/>
133
+ <x14:borderColor rgb="FFFF555A"/>
134
+ <x14:negativeFillColor rgb="FFFFFF00"/>
135
+ <x14:negativeBorderColor rgb="FFFF0000"/>
136
+ <x14:axisColor rgb="FF000000"/>
137
+ </x14:dataBar>
138
+ </x14:cfRule>
139
+ <xm:sqref>A3:C3</xm:sqref>
140
+ </x14:conditionalFormatting>
141
+ </x14:conditionalFormattings>
142
+ </ext>
143
+ </extLst>
144
+ </worksheet>
145
+ EOS
146
+ end
147
+ end
@@ -0,0 +1,145 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestWorksheetDataBar06 < Minitest::Test
5
+ def setup
6
+ @workbook = WriteXLSX.new(StringIO.new)
7
+ @worksheet = @workbook.add_worksheet('')
8
+ end
9
+
10
+ ###############################################################################
11
+ #
12
+ # Tests for WriteXLSX::Worksheet methods.
13
+ #
14
+ #
15
+ def test_data_bar_06
16
+ @worksheet.select
17
+ @worksheet.instance_variable_set(:@index, 0)
18
+
19
+ @worksheet.conditional_formatting(
20
+ 'A1',
21
+ :type => 'data_bar',
22
+ :bar_negative_color_same => 1
23
+ )
24
+
25
+ @worksheet.conditional_formatting(
26
+ 'A2:B2',
27
+ :type => 'data_bar',
28
+ :bar_color => '#63C384',
29
+ :bar_negative_border_color => '#92D050'
30
+ )
31
+
32
+ @worksheet.conditional_formatting(
33
+ 'A3:C3',
34
+ :type => 'data_bar',
35
+ :bar_color => '#FF555A',
36
+ :bar_negative_border_color_same => 1
37
+ )
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"/>
51
+ <sheetViews>
52
+ <sheetView tabSelected="1" workbookViewId="0"/>
53
+ </sheetViews>
54
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
55
+ <sheetData/>
56
+ <conditionalFormatting sqref="A1">
57
+ <cfRule type="dataBar" priority="1">
58
+ <dataBar>
59
+ <cfvo type="min"/>
60
+ <cfvo type="max"/>
61
+ <color rgb="FF638EC6"/>
62
+ </dataBar>
63
+ <extLst>
64
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
65
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000001}</x14:id>
66
+ </ext>
67
+ </extLst>
68
+ </cfRule>
69
+ </conditionalFormatting>
70
+ <conditionalFormatting sqref="A2:B2">
71
+ <cfRule type="dataBar" priority="2">
72
+ <dataBar>
73
+ <cfvo type="min"/>
74
+ <cfvo type="max"/>
75
+ <color rgb="FF63C384"/>
76
+ </dataBar>
77
+ <extLst>
78
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
79
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000002}</x14:id>
80
+ </ext>
81
+ </extLst>
82
+ </cfRule>
83
+ </conditionalFormatting>
84
+ <conditionalFormatting sqref="A3:C3">
85
+ <cfRule type="dataBar" priority="3">
86
+ <dataBar>
87
+ <cfvo type="min"/>
88
+ <cfvo type="max"/>
89
+ <color rgb="FFFF555A"/>
90
+ </dataBar>
91
+ <extLst>
92
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
93
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000003}</x14:id>
94
+ </ext>
95
+ </extLst>
96
+ </cfRule>
97
+ </conditionalFormatting>
98
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
99
+ <extLst>
100
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{78C0D931-6437-407d-A8EE-F0AAD7539E65}">
101
+ <x14:conditionalFormattings>
102
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
103
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000001}">
104
+ <x14:dataBar minLength="0" maxLength="100" border="1" negativeBarColorSameAsPositive="1" negativeBarBorderColorSameAsPositive="0">
105
+ <x14:cfvo type="autoMin"/>
106
+ <x14:cfvo type="autoMax"/>
107
+ <x14:borderColor rgb="FF638EC6"/>
108
+ <x14:negativeBorderColor rgb="FFFF0000"/>
109
+ <x14:axisColor rgb="FF000000"/>
110
+ </x14:dataBar>
111
+ </x14:cfRule>
112
+ <xm:sqref>A1</xm:sqref>
113
+ </x14:conditionalFormatting>
114
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
115
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000002}">
116
+ <x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0">
117
+ <x14:cfvo type="autoMin"/>
118
+ <x14:cfvo type="autoMax"/>
119
+ <x14:borderColor rgb="FF63C384"/>
120
+ <x14:negativeFillColor rgb="FFFF0000"/>
121
+ <x14:negativeBorderColor rgb="FF92D050"/>
122
+ <x14:axisColor rgb="FF000000"/>
123
+ </x14:dataBar>
124
+ </x14:cfRule>
125
+ <xm:sqref>A2:B2</xm:sqref>
126
+ </x14:conditionalFormatting>
127
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
128
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000003}">
129
+ <x14:dataBar minLength="0" maxLength="100" border="1">
130
+ <x14:cfvo type="autoMin"/>
131
+ <x14:cfvo type="autoMax"/>
132
+ <x14:borderColor rgb="FFFF555A"/>
133
+ <x14:negativeFillColor rgb="FFFF0000"/>
134
+ <x14:axisColor rgb="FF000000"/>
135
+ </x14:dataBar>
136
+ </x14:cfRule>
137
+ <xm:sqref>A3:C3</xm:sqref>
138
+ </x14:conditionalFormatting>
139
+ </x14:conditionalFormattings>
140
+ </ext>
141
+ </extLst>
142
+ </worksheet>
143
+ EOS
144
+ end
145
+ end
@@ -0,0 +1,146 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestWorksheetDataBar07 < Minitest::Test
5
+ def setup
6
+ @workbook = WriteXLSX.new(StringIO.new)
7
+ @worksheet = @workbook.add_worksheet('')
8
+ end
9
+
10
+ ###############################################################################
11
+ #
12
+ # Tests for WriteXLSX::Worksheet methods.
13
+ #
14
+ #
15
+ def test_data_bar_07
16
+ @worksheet.select
17
+ @worksheet.instance_variable_set(:@index, 0)
18
+
19
+ @worksheet.conditional_formatting(
20
+ 'A1',
21
+ :type => 'data_bar',
22
+ :bar_axis_position => 'middle'
23
+ )
24
+
25
+ @worksheet.conditional_formatting(
26
+ 'A2:B2',
27
+ :type => 'data_bar',
28
+ :bar_color => '#63C384',
29
+ :bar_axis_position => 'none'
30
+ )
31
+
32
+ @worksheet.conditional_formatting(
33
+ 'A3:C3',
34
+ :type => 'data_bar',
35
+ :bar_color => '#FF555A',
36
+ :bar_axis_color => '#0070C0'
37
+ )
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"/>
51
+ <sheetViews>
52
+ <sheetView tabSelected="1" workbookViewId="0"/>
53
+ </sheetViews>
54
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
55
+ <sheetData/>
56
+ <conditionalFormatting sqref="A1">
57
+ <cfRule type="dataBar" priority="1">
58
+ <dataBar>
59
+ <cfvo type="min"/>
60
+ <cfvo type="max"/>
61
+ <color rgb="FF638EC6"/>
62
+ </dataBar>
63
+ <extLst>
64
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
65
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000001}</x14:id>
66
+ </ext>
67
+ </extLst>
68
+ </cfRule>
69
+ </conditionalFormatting>
70
+ <conditionalFormatting sqref="A2:B2">
71
+ <cfRule type="dataBar" priority="2">
72
+ <dataBar>
73
+ <cfvo type="min"/>
74
+ <cfvo type="max"/>
75
+ <color rgb="FF63C384"/>
76
+ </dataBar>
77
+ <extLst>
78
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
79
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000002}</x14:id>
80
+ </ext>
81
+ </extLst>
82
+ </cfRule>
83
+ </conditionalFormatting>
84
+ <conditionalFormatting sqref="A3:C3">
85
+ <cfRule type="dataBar" priority="3">
86
+ <dataBar>
87
+ <cfvo type="min"/>
88
+ <cfvo type="max"/>
89
+ <color rgb="FFFF555A"/>
90
+ </dataBar>
91
+ <extLst>
92
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
93
+ <x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000003}</x14:id>
94
+ </ext>
95
+ </extLst>
96
+ </cfRule>
97
+ </conditionalFormatting>
98
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
99
+ <extLst>
100
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{78C0D931-6437-407d-A8EE-F0AAD7539E65}">
101
+ <x14:conditionalFormattings>
102
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
103
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000001}">
104
+ <x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0" axisPosition="middle">
105
+ <x14:cfvo type="autoMin"/>
106
+ <x14:cfvo type="autoMax"/>
107
+ <x14:borderColor rgb="FF638EC6"/>
108
+ <x14:negativeFillColor rgb="FFFF0000"/>
109
+ <x14:negativeBorderColor rgb="FFFF0000"/>
110
+ <x14:axisColor rgb="FF000000"/>
111
+ </x14:dataBar>
112
+ </x14:cfRule>
113
+ <xm:sqref>A1</xm:sqref>
114
+ </x14:conditionalFormatting>
115
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
116
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000002}">
117
+ <x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0" axisPosition="none">
118
+ <x14:cfvo type="autoMin"/>
119
+ <x14:cfvo type="autoMax"/>
120
+ <x14:borderColor rgb="FF63C384"/>
121
+ <x14:negativeFillColor rgb="FFFF0000"/>
122
+ <x14:negativeBorderColor rgb="FFFF0000"/>
123
+ </x14:dataBar>
124
+ </x14:cfRule>
125
+ <xm:sqref>A2:B2</xm:sqref>
126
+ </x14:conditionalFormatting>
127
+ <x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
128
+ <x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000003}">
129
+ <x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0">
130
+ <x14:cfvo type="autoMin"/>
131
+ <x14:cfvo type="autoMax"/>
132
+ <x14:borderColor rgb="FFFF555A"/>
133
+ <x14:negativeFillColor rgb="FFFF0000"/>
134
+ <x14:negativeBorderColor rgb="FFFF0000"/>
135
+ <x14:axisColor rgb="FF0070C0"/>
136
+ </x14:dataBar>
137
+ </x14:cfRule>
138
+ <xm:sqref>A3:C3</xm:sqref>
139
+ </x14:conditionalFormatting>
140
+ </x14:conditionalFormattings>
141
+ </ext>
142
+ </extLst>
143
+ </worksheet>
144
+ EOS
145
+ end
146
+ end