writeexcel 0.1.0 → 0.3.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.
- data/README +26 -31
- data/examples/a_simple.rb +42 -42
- data/examples/{autofilters.rb → autofilter.rb} +264 -266
- data/examples/bigfile.rb +29 -0
- data/examples/chart_area.rb +120 -0
- data/examples/chart_bar.rb +119 -0
- data/examples/chart_column.rb +119 -0
- data/examples/chart_line.rb +119 -0
- data/examples/chart_pie.rb +107 -0
- data/examples/chart_scatter.rb +120 -0
- data/examples/chart_stock.rb +147 -0
- data/examples/copyformat.rb +51 -51
- data/examples/data_validate.rb +278 -278
- data/examples/date_time.rb +86 -86
- data/examples/defined_name.rb +31 -0
- data/examples/demo.rb +120 -118
- data/examples/diag_border.rb +35 -35
- data/examples/formats.rb +489 -489
- data/examples/header.rb +136 -136
- data/examples/hidden.rb +28 -28
- data/examples/hyperlink.rb +42 -42
- data/examples/images.rb +52 -52
- data/examples/merge1.rb +39 -39
- data/examples/merge2.rb +44 -44
- data/examples/merge3.rb +65 -65
- data/examples/merge4.rb +82 -82
- data/examples/merge5.rb +79 -79
- data/examples/properties.rb +33 -0
- data/examples/properties_jp.rb +32 -0
- data/examples/protection.rb +46 -46
- data/examples/regions.rb +52 -52
- data/examples/repeat.rb +42 -42
- data/examples/stats.rb +75 -75
- data/examples/stocks.rb +80 -80
- data/examples/tab_colors.rb +30 -30
- data/examples/write_arrays.rb +82 -0
- data/lib/writeexcel.rb +1134 -18
- data/lib/writeexcel/biffwriter.rb +273 -260
- data/lib/writeexcel/chart.rb +2306 -217
- data/lib/writeexcel/charts/area.rb +152 -0
- data/lib/writeexcel/charts/bar.rb +177 -0
- data/lib/writeexcel/charts/column.rb +156 -0
- data/lib/writeexcel/charts/external.rb +61 -0
- data/lib/writeexcel/charts/line.rb +152 -0
- data/lib/writeexcel/charts/pie.rb +169 -0
- data/lib/writeexcel/charts/scatter.rb +192 -0
- data/lib/writeexcel/charts/stock.rb +211 -0
- data/lib/writeexcel/excelformulaparser.rb +208 -195
- data/lib/writeexcel/format.rb +1697 -1108
- data/lib/writeexcel/formula.rb +1050 -986
- data/lib/writeexcel/olewriter.rb +322 -322
- data/lib/writeexcel/properties.rb +251 -250
- data/lib/writeexcel/storage_lite.rb +968 -0
- data/lib/writeexcel/workbook.rb +3294 -2630
- data/lib/writeexcel/worksheet.rb +9012 -6377
- data/test/excelfile/Chart1.xls +0 -0
- data/test/excelfile/Chart2.xls +0 -0
- data/test/excelfile/Chart3.xls +0 -0
- data/test/excelfile/Chart4.xls +0 -0
- data/test/excelfile/Chart5.xls +0 -0
- data/test/perl_output/Chart1.xls.data +0 -0
- data/test/perl_output/Chart2.xls.data +0 -0
- data/test/perl_output/Chart3.xls.data +0 -0
- data/test/perl_output/Chart4.xls.data +0 -0
- data/test/perl_output/Chart5.xls.data +0 -0
- data/test/perl_output/a_simple.xls +0 -0
- data/test/perl_output/autofilter.xls +0 -0
- data/test/perl_output/chart_area.xls +0 -0
- data/test/perl_output/chart_bar.xls +0 -0
- data/test/perl_output/chart_column.xls +0 -0
- data/test/perl_output/chart_line.xls +0 -0
- data/test/perl_output/data_validate.xls +0 -0
- data/test/perl_output/date_time.xls +0 -0
- data/test/perl_output/demo.xls +0 -0
- data/test/perl_output/demo101.bin +0 -0
- data/test/perl_output/demo201.bin +0 -0
- data/test/perl_output/demo301.bin +0 -0
- data/test/perl_output/demo401.bin +0 -0
- data/test/perl_output/demo501.bin +0 -0
- data/test/perl_output/diag_border.xls +0 -0
- data/test/perl_output/headers.xls +0 -0
- data/test/perl_output/hyperlink.xls +0 -0
- data/test/perl_output/images.xls +0 -0
- data/test/perl_output/merge1.xls +0 -0
- data/test/perl_output/merge2.xls +0 -0
- data/test/perl_output/merge3.xls +0 -0
- data/test/perl_output/merge4.xls +0 -0
- data/test/perl_output/merge5.xls +0 -0
- data/test/perl_output/protection.xls +0 -0
- data/test/perl_output/regions.xls +0 -0
- data/test/perl_output/stats.xls +0 -0
- data/test/perl_output/stocks.xls +0 -0
- data/test/perl_output/tab_colors.xls +0 -0
- data/test/perl_output/unicode_cyrillic.xls +0 -0
- data/test/perl_output/workbook1.xls +0 -0
- data/test/perl_output/workbook2.xls +0 -0
- data/test/tc_all.rb +32 -31
- data/test/tc_biff.rb +104 -104
- data/test/tc_chart.rb +22 -22
- data/test/tc_example_match.rb +1944 -1280
- data/test/tc_format.rb +1254 -1267
- data/test/tc_formula.rb +63 -63
- data/test/tc_ole.rb +110 -110
- data/test/tc_storage_lite.rb +149 -0
- data/test/tc_workbook.rb +140 -115
- data/test/tc_worksheet.rb +115 -115
- data/test/test_00_IEEE_double.rb +14 -14
- data/test/test_01_add_worksheet.rb +12 -12
- data/test/test_02_merge_formats.rb +58 -58
- data/test/test_04_dimensions.rb +397 -397
- data/test/test_05_rows.rb +182 -182
- data/test/test_06_extsst.rb +80 -80
- data/test/test_11_date_time.rb +484 -484
- data/test/test_12_date_only.rb +506 -506
- data/test/test_13_date_seconds.rb +486 -486
- data/test/test_21_escher.rb +642 -629
- data/test/test_22_mso_drawing_group.rb +750 -739
- data/test/test_23_note.rb +78 -78
- data/test/test_24_txo.rb +80 -80
- data/test/test_25_position_object.rb +82 -0
- data/test/test_26_autofilter.rb +327 -327
- data/test/test_27_autofilter.rb +144 -144
- data/test/test_28_autofilter.rb +174 -174
- data/test/test_29_process_jpg.rb +681 -131
- data/test/test_30_validation_dval.rb +82 -82
- data/test/test_31_validation_dv_strings.rb +131 -131
- data/test/test_32_validation_dv_formula.rb +211 -211
- data/test/test_40_property_types.rb +191 -191
- data/test/test_41_properties.rb +238 -238
- data/test/test_42_set_properties.rb +442 -419
- data/test/test_50_name_stored.rb +305 -0
- data/test/test_51_name_print_area.rb +363 -0
- data/test/test_52_name_print_titles.rb +460 -0
- data/test/test_53_autofilter.rb +209 -0
- data/test/test_60_chart_generic.rb +576 -0
- data/test/test_61_chart_subclasses.rb +97 -0
- data/test/test_62_chart_formats.rb +270 -0
- data/test/test_63_chart_area_formats.rb +647 -0
- data/test/test_chartex.rb +35 -0
- data/test/ts_all.rb +46 -34
- data/writeexcel.gemspec +18 -0
- data/writeexcel.rdoc +583 -0
- metadata +162 -108
data/test/test_05_rows.rb
CHANGED
@@ -1,182 +1,182 @@
|
|
1
|
-
###############################################################################
|
2
|
-
#
|
3
|
-
# A test for
|
4
|
-
#
|
5
|
-
# Check that max/min columns of the Excel ROW record are written correctly.
|
6
|
-
#
|
7
|
-
# reverse('©'), October 2007, John McNamara, jmcnamara@cpan.org
|
8
|
-
#
|
9
|
-
# original written in Perl by John McNamara
|
10
|
-
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
11
|
-
#
|
12
|
-
############################################################################
|
13
|
-
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
14
|
-
|
15
|
-
require "test/unit"
|
16
|
-
require 'writeexcel'
|
17
|
-
|
18
|
-
class TC_rows < Test::Unit::TestCase
|
19
|
-
|
20
|
-
def setup
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_1
|
24
|
-
t = Time.now.strftime("%Y%m%d")
|
25
|
-
path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
26
|
-
@test_file = File.join(Dir.tmpdir, path)
|
27
|
-
workbook =
|
28
|
-
workbook.compatibility_mode(1)
|
29
|
-
@tests = []
|
30
|
-
|
31
|
-
# for test case 1
|
32
|
-
row = 1
|
33
|
-
col1 = 0
|
34
|
-
col2 = 0
|
35
|
-
worksheet = workbook.add_worksheet
|
36
|
-
worksheet.set_row(row, 15)
|
37
|
-
@tests.push(
|
38
|
-
[
|
39
|
-
" \tset_row(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
40
|
-
{
|
41
|
-
:col_min => 0,
|
42
|
-
:col_max => 0,
|
43
|
-
}
|
44
|
-
]
|
45
|
-
)
|
46
|
-
|
47
|
-
# for test case 2
|
48
|
-
row = 2
|
49
|
-
col1 = 0
|
50
|
-
col2 = 0
|
51
|
-
worksheet = workbook.add_worksheet
|
52
|
-
worksheet.write(row, col1, 'Test')
|
53
|
-
worksheet.write(row, col2, 'Test')
|
54
|
-
@tests.push(
|
55
|
-
[
|
56
|
-
" \tset_row(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
57
|
-
{
|
58
|
-
:col_min => 0,
|
59
|
-
:col_max => 1,
|
60
|
-
}
|
61
|
-
]
|
62
|
-
)
|
63
|
-
|
64
|
-
|
65
|
-
# for test case 3
|
66
|
-
row = 3
|
67
|
-
col1 = 0
|
68
|
-
col2 = 1
|
69
|
-
worksheet = workbook.add_worksheet
|
70
|
-
worksheet.write(row, col1, 'Test')
|
71
|
-
worksheet.write(row, col2, 'Test')
|
72
|
-
@tests.push(
|
73
|
-
[
|
74
|
-
" \twrite(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
75
|
-
{
|
76
|
-
:col_min => 0,
|
77
|
-
:col_max => 2,
|
78
|
-
}
|
79
|
-
]
|
80
|
-
)
|
81
|
-
|
82
|
-
# for test case 4
|
83
|
-
row = 4
|
84
|
-
col1 = 1
|
85
|
-
col2 = 1
|
86
|
-
worksheet = workbook.add_worksheet
|
87
|
-
worksheet.write(row, col1, 'Test')
|
88
|
-
worksheet.write(row, col2, 'Test')
|
89
|
-
@tests.push(
|
90
|
-
[
|
91
|
-
" \twrite(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
92
|
-
{
|
93
|
-
:col_min => 1,
|
94
|
-
:col_max => 2,
|
95
|
-
}
|
96
|
-
]
|
97
|
-
)
|
98
|
-
|
99
|
-
# for test case 5
|
100
|
-
row = 5
|
101
|
-
col1 = 1
|
102
|
-
col2 = 255
|
103
|
-
worksheet = workbook.add_worksheet
|
104
|
-
worksheet.write(row, col1, 'Test')
|
105
|
-
worksheet.write(row, col2, 'Test')
|
106
|
-
@tests.push(
|
107
|
-
[
|
108
|
-
" \twrite(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
109
|
-
{
|
110
|
-
:col_min => 1,
|
111
|
-
:col_max => 256,
|
112
|
-
}
|
113
|
-
]
|
114
|
-
)
|
115
|
-
|
116
|
-
# for test case 6
|
117
|
-
row = 6
|
118
|
-
col1 = 255
|
119
|
-
col2 = 255
|
120
|
-
worksheet = workbook.add_worksheet
|
121
|
-
worksheet.write(row, col1, 'Test')
|
122
|
-
worksheet.write(row, col2, 'Test')
|
123
|
-
@tests.push(
|
124
|
-
[
|
125
|
-
" \twrite(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
126
|
-
{
|
127
|
-
:col_min => 255,
|
128
|
-
:col_max => 256,
|
129
|
-
}
|
130
|
-
]
|
131
|
-
)
|
132
|
-
|
133
|
-
# for test case 7
|
134
|
-
row = 7
|
135
|
-
col1 = 2
|
136
|
-
col2 = 9
|
137
|
-
worksheet = workbook.add_worksheet
|
138
|
-
worksheet.set_row(row, 15)
|
139
|
-
worksheet.write(row, col1, 'Test')
|
140
|
-
worksheet.write(row, col2, 'Test')
|
141
|
-
@tests.push(
|
142
|
-
[
|
143
|
-
" \tset_row + write(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
144
|
-
{
|
145
|
-
:col_min => 2,
|
146
|
-
:col_max => 10,
|
147
|
-
}
|
148
|
-
]
|
149
|
-
)
|
150
|
-
|
151
|
-
workbook.biff_only = 1
|
152
|
-
workbook.close
|
153
|
-
# Read in the row records
|
154
|
-
rows = []
|
155
|
-
|
156
|
-
xlsfile = open(@test_file, "rb")
|
157
|
-
while header = xlsfile.read(4)
|
158
|
-
record, length = header.unpack('vv')
|
159
|
-
data = xlsfile.read(length)
|
160
|
-
|
161
|
-
#read the row records only
|
162
|
-
next unless record == 0x0208
|
163
|
-
col_min, col_max = data.unpack('x2 vv')
|
164
|
-
|
165
|
-
rows.push(
|
166
|
-
{
|
167
|
-
:col_min => col_min,
|
168
|
-
:col_max => col_max
|
169
|
-
}
|
170
|
-
)
|
171
|
-
end
|
172
|
-
xlsfile.close
|
173
|
-
(0 .. @tests.size - 1).each do |i|
|
174
|
-
assert_equal(@tests[i][1], rows[i], @tests[i][0])
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def teardown
|
179
|
-
File.unlink(@test_file) if FileTest.exist?(@test_file)
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
1
|
+
###############################################################################
|
2
|
+
#
|
3
|
+
# A test for WriteExcel.
|
4
|
+
#
|
5
|
+
# Check that max/min columns of the Excel ROW record are written correctly.
|
6
|
+
#
|
7
|
+
# reverse('©'), October 2007, John McNamara, jmcnamara@cpan.org
|
8
|
+
#
|
9
|
+
# original written in Perl by John McNamara
|
10
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
11
|
+
#
|
12
|
+
############################################################################
|
13
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
14
|
+
|
15
|
+
require "test/unit"
|
16
|
+
require 'writeexcel'
|
17
|
+
|
18
|
+
class TC_rows < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def setup
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_1
|
24
|
+
t = Time.now.strftime("%Y%m%d")
|
25
|
+
path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
26
|
+
@test_file = File.join(Dir.tmpdir, path)
|
27
|
+
workbook = WriteExcel.new(@test_file)
|
28
|
+
workbook.compatibility_mode(1)
|
29
|
+
@tests = []
|
30
|
+
|
31
|
+
# for test case 1
|
32
|
+
row = 1
|
33
|
+
col1 = 0
|
34
|
+
col2 = 0
|
35
|
+
worksheet = workbook.add_worksheet
|
36
|
+
worksheet.set_row(row, 15)
|
37
|
+
@tests.push(
|
38
|
+
[
|
39
|
+
" \tset_row(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
40
|
+
{
|
41
|
+
:col_min => 0,
|
42
|
+
:col_max => 0,
|
43
|
+
}
|
44
|
+
]
|
45
|
+
)
|
46
|
+
|
47
|
+
# for test case 2
|
48
|
+
row = 2
|
49
|
+
col1 = 0
|
50
|
+
col2 = 0
|
51
|
+
worksheet = workbook.add_worksheet
|
52
|
+
worksheet.write(row, col1, 'Test')
|
53
|
+
worksheet.write(row, col2, 'Test')
|
54
|
+
@tests.push(
|
55
|
+
[
|
56
|
+
" \tset_row(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
57
|
+
{
|
58
|
+
:col_min => 0,
|
59
|
+
:col_max => 1,
|
60
|
+
}
|
61
|
+
]
|
62
|
+
)
|
63
|
+
|
64
|
+
|
65
|
+
# for test case 3
|
66
|
+
row = 3
|
67
|
+
col1 = 0
|
68
|
+
col2 = 1
|
69
|
+
worksheet = workbook.add_worksheet
|
70
|
+
worksheet.write(row, col1, 'Test')
|
71
|
+
worksheet.write(row, col2, 'Test')
|
72
|
+
@tests.push(
|
73
|
+
[
|
74
|
+
" \twrite(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
75
|
+
{
|
76
|
+
:col_min => 0,
|
77
|
+
:col_max => 2,
|
78
|
+
}
|
79
|
+
]
|
80
|
+
)
|
81
|
+
|
82
|
+
# for test case 4
|
83
|
+
row = 4
|
84
|
+
col1 = 1
|
85
|
+
col2 = 1
|
86
|
+
worksheet = workbook.add_worksheet
|
87
|
+
worksheet.write(row, col1, 'Test')
|
88
|
+
worksheet.write(row, col2, 'Test')
|
89
|
+
@tests.push(
|
90
|
+
[
|
91
|
+
" \twrite(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
92
|
+
{
|
93
|
+
:col_min => 1,
|
94
|
+
:col_max => 2,
|
95
|
+
}
|
96
|
+
]
|
97
|
+
)
|
98
|
+
|
99
|
+
# for test case 5
|
100
|
+
row = 5
|
101
|
+
col1 = 1
|
102
|
+
col2 = 255
|
103
|
+
worksheet = workbook.add_worksheet
|
104
|
+
worksheet.write(row, col1, 'Test')
|
105
|
+
worksheet.write(row, col2, 'Test')
|
106
|
+
@tests.push(
|
107
|
+
[
|
108
|
+
" \twrite(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
109
|
+
{
|
110
|
+
:col_min => 1,
|
111
|
+
:col_max => 256,
|
112
|
+
}
|
113
|
+
]
|
114
|
+
)
|
115
|
+
|
116
|
+
# for test case 6
|
117
|
+
row = 6
|
118
|
+
col1 = 255
|
119
|
+
col2 = 255
|
120
|
+
worksheet = workbook.add_worksheet
|
121
|
+
worksheet.write(row, col1, 'Test')
|
122
|
+
worksheet.write(row, col2, 'Test')
|
123
|
+
@tests.push(
|
124
|
+
[
|
125
|
+
" \twrite(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
126
|
+
{
|
127
|
+
:col_min => 255,
|
128
|
+
:col_max => 256,
|
129
|
+
}
|
130
|
+
]
|
131
|
+
)
|
132
|
+
|
133
|
+
# for test case 7
|
134
|
+
row = 7
|
135
|
+
col1 = 2
|
136
|
+
col2 = 9
|
137
|
+
worksheet = workbook.add_worksheet
|
138
|
+
worksheet.set_row(row, 15)
|
139
|
+
worksheet.write(row, col1, 'Test')
|
140
|
+
worksheet.write(row, col2, 'Test')
|
141
|
+
@tests.push(
|
142
|
+
[
|
143
|
+
" \tset_row + write(): row = #{row}, col1 = #{col1}, col2 = #{col2}",
|
144
|
+
{
|
145
|
+
:col_min => 2,
|
146
|
+
:col_max => 10,
|
147
|
+
}
|
148
|
+
]
|
149
|
+
)
|
150
|
+
|
151
|
+
workbook.biff_only = 1
|
152
|
+
workbook.close
|
153
|
+
# Read in the row records
|
154
|
+
rows = []
|
155
|
+
|
156
|
+
xlsfile = open(@test_file, "rb")
|
157
|
+
while header = xlsfile.read(4)
|
158
|
+
record, length = header.unpack('vv')
|
159
|
+
data = xlsfile.read(length)
|
160
|
+
|
161
|
+
#read the row records only
|
162
|
+
next unless record == 0x0208
|
163
|
+
col_min, col_max = data.unpack('x2 vv')
|
164
|
+
|
165
|
+
rows.push(
|
166
|
+
{
|
167
|
+
:col_min => col_min,
|
168
|
+
:col_max => col_max
|
169
|
+
}
|
170
|
+
)
|
171
|
+
end
|
172
|
+
xlsfile.close
|
173
|
+
(0 .. @tests.size - 1).each do |i|
|
174
|
+
assert_equal(@tests[i][1], rows[i], @tests[i][0])
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def teardown
|
179
|
+
File.unlink(@test_file) if FileTest.exist?(@test_file)
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
data/test/test_06_extsst.rb
CHANGED
@@ -1,80 +1,80 @@
|
|
1
|
-
###############################################################################
|
2
|
-
#
|
3
|
-
# A test for
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
[
|
35
|
-
[
|
36
|
-
[
|
37
|
-
[
|
38
|
-
[
|
39
|
-
[
|
40
|
-
[
|
41
|
-
[
|
42
|
-
[
|
43
|
-
[
|
44
|
-
[
|
45
|
-
[
|
46
|
-
[
|
47
|
-
[
|
48
|
-
[
|
49
|
-
[
|
50
|
-
[
|
51
|
-
[
|
52
|
-
[
|
53
|
-
[
|
54
|
-
[
|
55
|
-
[
|
56
|
-
[
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
str_unique = test[0]
|
69
|
-
|
70
|
-
@workbook.str_unique =
|
71
|
-
@workbook.calculate_extsst_size
|
72
|
-
|
73
|
-
assert_equal(@workbook.extsst_buckets,
|
74
|
-
|
75
|
-
assert_equal(@workbook.extsst_bucket_size,
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
end
|
1
|
+
###############################################################################
|
2
|
+
#
|
3
|
+
# A test for WriteExcel.
|
4
|
+
#
|
5
|
+
# all test is commented out because Workbook#calculate_extsst_size was set to
|
6
|
+
# private method. Before that, all test passed.
|
7
|
+
#
|
8
|
+
#
|
9
|
+
#
|
10
|
+
#
|
11
|
+
# Check that we calculate the correct bucket size and number for the EXTSST
|
12
|
+
# record. The data is taken from actual Excel files.
|
13
|
+
#
|
14
|
+
# reverse('©'), October 2007, John McNamara, jmcnamara@cpan.org
|
15
|
+
#
|
16
|
+
# original written in Perl by John McNamara
|
17
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
18
|
+
#
|
19
|
+
############################################################################
|
20
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
21
|
+
|
22
|
+
require "test/unit"
|
23
|
+
require 'writeexcel'
|
24
|
+
require 'stringio'
|
25
|
+
|
26
|
+
class TC_extsst < Test::Unit::TestCase
|
27
|
+
|
28
|
+
def setup
|
29
|
+
io = StringIO.new
|
30
|
+
@workbook = WriteExcel.new(io)
|
31
|
+
|
32
|
+
@tests = [ # Unique Number of Bucket
|
33
|
+
# strings buckets size
|
34
|
+
[0, 0, 8],
|
35
|
+
[1, 1, 8],
|
36
|
+
[7, 1, 8],
|
37
|
+
[8, 1, 8],
|
38
|
+
[15, 2, 8],
|
39
|
+
[16, 2, 8],
|
40
|
+
[17, 3, 8],
|
41
|
+
[32, 4, 8],
|
42
|
+
[33, 5, 8],
|
43
|
+
[64, 8, 8],
|
44
|
+
[128, 16, 8],
|
45
|
+
[256, 32, 8],
|
46
|
+
[512, 64, 8],
|
47
|
+
[1023, 128, 8],
|
48
|
+
[1024, 114, 9],
|
49
|
+
[1025, 114, 9],
|
50
|
+
[2048, 121, 17],
|
51
|
+
[4096, 125, 33],
|
52
|
+
[4097, 125, 33],
|
53
|
+
[8192, 127, 65],
|
54
|
+
[8193, 127, 65],
|
55
|
+
[9000, 127, 71],
|
56
|
+
[10000, 127, 79],
|
57
|
+
[16384, 128, 129],
|
58
|
+
[262144, 128, 2049],
|
59
|
+
[1048576, 128, 8193],
|
60
|
+
[4194304, 128, 32769],
|
61
|
+
[8257536, 128, 64513],
|
62
|
+
]
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_to_tests
|
66
|
+
@tests.each do |test|
|
67
|
+
|
68
|
+
str_unique = test[0]
|
69
|
+
|
70
|
+
@workbook.str_unique = str_unique
|
71
|
+
@workbook.calculate_extsst_size
|
72
|
+
|
73
|
+
assert_equal(test[1], @workbook.extsst_buckets,
|
74
|
+
" \tBucket number for #{str_unique} strings")
|
75
|
+
assert_equal(test[2], @workbook.extsst_bucket_size,
|
76
|
+
" \tBucket size for #{str_unique} strings")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|