surpass 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +0 -0
- data/README.txt +133 -0
- data/Rakefile +35 -0
- data/examples/big-16mb.rb +25 -0
- data/examples/big-random-strings.rb +28 -0
- data/examples/blanks.rb +34 -0
- data/examples/col_width.rb +16 -0
- data/examples/dates.rb +31 -0
- data/examples/format.rb +23 -0
- data/examples/hello-world.rb +9 -0
- data/examples/image.rb +10 -0
- data/examples/merged.rb +36 -0
- data/examples/merged0.rb +27 -0
- data/examples/merged1.rb +99 -0
- data/examples/num_formats.rb +55 -0
- data/examples/numbers.rb +24 -0
- data/examples/outline.rb +110 -0
- data/examples/panes.rb +48 -0
- data/examples/protection.rb +132 -0
- data/examples/python.bmp +0 -0
- data/examples/row_styles.rb +16 -0
- data/examples/row_styles_empty.rb +15 -0
- data/examples/set_cell_and_range_style.rb +12 -0
- data/examples/wrapped-text.rb +13 -0
- data/examples/write_arrays.rb +16 -0
- data/examples/ws_props.rb +80 -0
- data/lib/biff_record.rb +2168 -0
- data/lib/bitmap.rb +218 -0
- data/lib/cell.rb +214 -0
- data/lib/chart.rb +16 -0
- data/lib/column.rb +40 -0
- data/lib/document.rb +406 -0
- data/lib/excel_formula.rb +6 -0
- data/lib/excel_magic.rb +1013 -0
- data/lib/formatting.rb +554 -0
- data/lib/row.rb +137 -0
- data/lib/style.rb +179 -0
- data/lib/surpass.rb +51 -0
- data/lib/utilities.rb +86 -0
- data/lib/workbook.rb +206 -0
- data/lib/worksheet.rb +561 -0
- data/spec/biff_record_spec.rb +268 -0
- data/spec/cell_spec.rb +56 -0
- data/spec/data/random-strings.txt +10000 -0
- data/spec/document_spec.rb +168 -0
- data/spec/excel_formula_spec.rb +0 -0
- data/spec/formatting_spec.rb +53 -0
- data/spec/reference/P-0508-0000507647-3280-5298.xls +0 -0
- data/spec/reference/all-cell-styles.bin +0 -0
- data/spec/reference/all-number-formats.bin +0 -0
- data/spec/reference/all-styles.bin +0 -0
- data/spec/reference/mini.xls +0 -0
- data/spec/row_spec.rb +19 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/style_spec.rb +89 -0
- data/spec/utilities_spec.rb +57 -0
- data/spec/workbook_spec.rb +48 -0
- data/spec/worksheet_spec.rb +0 -0
- data/stats/cloc.txt +8 -0
- data/stats/rcov.txt +0 -0
- data/stats/specdoc.txt +158 -0
- data/surpass-manual-0-0-3.pdf +0 -0
- data/surpass.gemspec +34 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/excel.rake +6 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/metrics.rake +42 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +292 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- metadata +144 -0
@@ -0,0 +1,268 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe InterfaceHeaderRecord do
|
4
|
+
it "should pack correctly" do
|
5
|
+
b = InterfaceHeaderRecord.new
|
6
|
+
b.to_biff.unpack('M*').should === ["\341\000\002\000\260\004"]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe InterfaceEndRecord do
|
11
|
+
it "should pack correctly" do
|
12
|
+
b = InterfaceEndRecord.new
|
13
|
+
b.to_biff.unpack('M*').should === ["\342\000\000\000"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe MMSRecord do
|
18
|
+
it "should pack correctly" do
|
19
|
+
b = MMSRecord.new
|
20
|
+
b.to_biff.unpack('M*').should === ["\301\000\002\000\000\000"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe WriteAccessRecord do
|
25
|
+
it "should pack correctly" do
|
26
|
+
b = WriteAccessRecord.new("Ana")
|
27
|
+
b.to_biff.unpack('M*').should === ["\\\000p\000Ana" + " " * 109]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe DSFRecord do
|
32
|
+
it "should pack correctly" do
|
33
|
+
b = DSFRecord.new
|
34
|
+
b.to_biff.unpack('M*').should === ["a\001\002\000\000\000"]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe TabIDRecord do
|
39
|
+
it "should pack correctly" do
|
40
|
+
b = TabIDRecord.new(2)
|
41
|
+
b.record_data.should === "\001\000\002\000"
|
42
|
+
b.to_biff.unpack('A*').should === ["=\001\004\000\001\000\002"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe FnGroupCountRecord do
|
47
|
+
it "should pack correctly" do
|
48
|
+
b = FnGroupCountRecord.new
|
49
|
+
b.record_data.should === "\016\000"
|
50
|
+
b.to_biff.unpack('A*').should === ["\234\000\002\000\016"]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe WindowProtectRecord do
|
55
|
+
it "should pack correctly" do
|
56
|
+
b = WindowProtectRecord.new(0)
|
57
|
+
b.record_data.should === "\000\000"
|
58
|
+
b.to_biff.unpack('A*').should === ["\031\000\002"]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ObjectProtectRecord do
|
63
|
+
it "should pack correctly" do
|
64
|
+
b = ObjectProtectRecord.new(0)
|
65
|
+
b.record_data.should === "\000\000"
|
66
|
+
b.to_biff.unpack('A*').should === ["c\000\002"]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe ScenarioProtectRecord do
|
71
|
+
it "should pack correctly" do
|
72
|
+
b = ScenarioProtectRecord.new(0)
|
73
|
+
b.record_data.should === "\000\000"
|
74
|
+
b.to_biff.unpack('A*').should === ["\335\000\002"]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe PasswordRecord do
|
79
|
+
before(:each) do
|
80
|
+
@b = PasswordRecord.new
|
81
|
+
end
|
82
|
+
it "should pack correctly with blank password" do
|
83
|
+
@b.password_hash("").should == 0
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should pack correctly with a password of 123456" do
|
87
|
+
@b.password_hash("123456").should === 50975
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should pack correctly with a password of abcdefghij" do
|
91
|
+
@b.password_hash("abcdefghij").should == 65265
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should pack correctly with a password of ok" do
|
95
|
+
@b.password_hash("ok").should == 53051
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe Prot4RevRecord do
|
100
|
+
it "should pack correctly" do
|
101
|
+
b = Prot4RevRecord.new
|
102
|
+
b.record_data.should === "\000\000"
|
103
|
+
b.to_biff.unpack('A*').should === ["\257\001\002"]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe Prot4RevPassRecord do
|
108
|
+
it "should pack correctly" do
|
109
|
+
b = Prot4RevPassRecord.new
|
110
|
+
b.record_data.should === "\000\000"
|
111
|
+
b.to_biff.unpack('A*').should === ["\274\001\002"]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe BackupRecord do
|
116
|
+
it "should pack correctly" do
|
117
|
+
b = BackupRecord.new(0)
|
118
|
+
b.record_data.should === "\000\000"
|
119
|
+
b.to_biff.unpack('A*').should === ["@\000\002"]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe HideObjRecord do
|
124
|
+
it "should pack correctly" do
|
125
|
+
b = HideObjRecord.new
|
126
|
+
b.record_data.should === "\000\000"
|
127
|
+
b.to_biff.unpack('A*').should === ["\215\000\002"]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe RefreshAllRecord do
|
132
|
+
it "should pack correctly" do
|
133
|
+
b = RefreshAllRecord.new
|
134
|
+
b.record_data.should === "\000\000"
|
135
|
+
b.to_biff.unpack('A*').should === ["\267\001\002"]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe BookBoolRecord do
|
140
|
+
it "should pack correctly" do
|
141
|
+
b = BookBoolRecord.new
|
142
|
+
b.record_data.should === "\000\000"
|
143
|
+
b.to_biff.unpack('A*').should === ["\332\000\002"]
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe CountryRecord do
|
148
|
+
it "should pack correctly" do
|
149
|
+
b = CountryRecord.new(1,1)
|
150
|
+
b.record_data.should === "\001\000\001\000"
|
151
|
+
b.to_biff.unpack('A*').should === ["\332\000\004\000\001\000\001"]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe UseSelfsRecord do
|
156
|
+
it "should pack correctly" do
|
157
|
+
b = UseSelfsRecord.new
|
158
|
+
b.record_data.should === "\001\000"
|
159
|
+
b.to_biff.unpack('A*').should === ["`\001\002\000\001"]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe EOFRecord do
|
164
|
+
it "should pack correctly" do
|
165
|
+
b = EOFRecord.new
|
166
|
+
b.record_data.should === ""
|
167
|
+
b.to_biff.unpack('A*').should === ["\n"]
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe DateModeRecord do
|
172
|
+
it "should pack correctly when passed true" do
|
173
|
+
b = DateModeRecord.new(true)
|
174
|
+
b.record_data.should === "\001\000"
|
175
|
+
b.to_biff.unpack('A*').should === ["\"\000\002\000\001"]
|
176
|
+
end
|
177
|
+
it "should pack correctly when passed false" do
|
178
|
+
b = DateModeRecord.new(false)
|
179
|
+
b.record_data.should === "\000\000"
|
180
|
+
b.to_biff.unpack('A*').should === ["\"\000\002"]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe PrecisionRecord do
|
185
|
+
it "should pack correctly when passed true" do
|
186
|
+
b = PrecisionRecord.new(true)
|
187
|
+
b.record_data.should === "\001\000"
|
188
|
+
b.to_biff.unpack('A*').should === ["\016\000\002\000\001"]
|
189
|
+
end
|
190
|
+
it "should pack correctly when passed false" do
|
191
|
+
b = PrecisionRecord.new(false)
|
192
|
+
b.record_data.should === "\000\000"
|
193
|
+
b.to_biff.unpack('A*').should === ["\016\000\002"]
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe CodepageBiff8Record do
|
198
|
+
it "should pack correctly" do
|
199
|
+
b = CodepageBiff8Record.new
|
200
|
+
b.record_data.should === "\260\004"
|
201
|
+
b.to_biff.unpack('A*').should === ["B\000\002\000\260\004"]
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe Window1Record do
|
206
|
+
it "should pack correctly" do
|
207
|
+
b = Window1Record.new(1,1,1,1,1,1,1,1,1)
|
208
|
+
b.record_data.should === "\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000"
|
209
|
+
b.to_biff.unpack('A*').should === ["=\000\022\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001"]
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe FontRecord do
|
214
|
+
it "should pack correctly" do
|
215
|
+
|
216
|
+
b = FontRecord.new(200,0,32767,400,0,0,0,204,"Arial")
|
217
|
+
b.record_data.should === "\310\000\000\000\377\177\220\001\000\000\000\000\314\000\005\000Arial"
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
# describe XFRecord do
|
222
|
+
# it "should pack correctly" do
|
223
|
+
# b = XFRecord.new([1,1,Alignment.new,Borders.new,Pattern.new,Protection.new])
|
224
|
+
# puts binary_string_to_hex_array(b.record_data)
|
225
|
+
# b.record_data.should === "\001\000\001\000\001\000"
|
226
|
+
# b.to_biff.unpack('A*').should === ["\257\001\002"]
|
227
|
+
# end
|
228
|
+
# end
|
229
|
+
|
230
|
+
describe StyleRecord do
|
231
|
+
it "should pack correctly" do
|
232
|
+
b = StyleRecord.new
|
233
|
+
b.record_data.should === "\000\200\000\377"
|
234
|
+
b.to_biff.unpack('A*').should === ["\223\002\004\000\000\200\000\377"]
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe BoundSheetRecord do
|
239
|
+
it "should pack correctly" do
|
240
|
+
b = BoundSheetRecord.new(0, 0, "x")
|
241
|
+
b.record_data.should === "\000\000\000\000\000\000\001\000x"
|
242
|
+
b.to_biff.unpack('A*').should === ["\205\000\t\000\000\000\000\000\000\000\001\000x"]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
# describe ExtSSTRecord do
|
247
|
+
# it "should pack correctly" do
|
248
|
+
# b = ExtSSTRecord.new(1,[1],1)
|
249
|
+
# b.record_data.should === "\000\000"
|
250
|
+
# b.to_biff.unpack('A*').should === ["\257\001\002"]
|
251
|
+
# end
|
252
|
+
# end
|
253
|
+
|
254
|
+
describe DimensionsRecord do
|
255
|
+
it "should pack correctly" do
|
256
|
+
b = DimensionsRecord.new(0,0,5,5)
|
257
|
+
b.record_data.should === "\000\000\000\000\001\000\000\000\005\000\006\000\000\000"
|
258
|
+
b.to_biff.unpack('A*').should === ["\000\002\016\000\000\000\000\000\001\000\000\000\005\000\006"]
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
# describe MergedCellsRecord do
|
263
|
+
# it "should pack correctly" do
|
264
|
+
# b = MergedCellsRecord.new([[1,1,2,2]])
|
265
|
+
# b.record_data.should === "\345\000\n\000\001\000\001\000\001\000\002\000\002\000"
|
266
|
+
# b.to_biff.unpack('A*').should === ["\345\000\n\000\001\000\001\000\001\000\002\000\002"]
|
267
|
+
# end
|
268
|
+
# end
|
data/spec/cell_spec.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe NumberCell, "to_biff" do
|
4
|
+
before(:all) do
|
5
|
+
@w = Workbook.new
|
6
|
+
@s = @w.add_sheet('rk_tests')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should encode with rk_encode" do
|
10
|
+
TEST_VALUES.each_with_index do |x, i|
|
11
|
+
# Write original test values
|
12
|
+
@s.write(i, 0, x)
|
13
|
+
|
14
|
+
# Write test values divided by 100
|
15
|
+
@s.write(i, 3, x/100.00)
|
16
|
+
|
17
|
+
# Write negative of test values
|
18
|
+
@s.write(i, 6, x)
|
19
|
+
|
20
|
+
# Write negative test values divided by 100
|
21
|
+
@s.write(i, 9, -x/100.00)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
after(:all) do
|
26
|
+
@w.save("spec/output/cells-rk.xls")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
TEST_VALUES = [
|
31
|
+
130.63999999999999,
|
32
|
+
130.64,
|
33
|
+
-18.649999999999999,
|
34
|
+
-18.65,
|
35
|
+
137.19999999999999,
|
36
|
+
137.20,
|
37
|
+
-16.079999999999998,
|
38
|
+
-16.08,
|
39
|
+
0,
|
40
|
+
1,
|
41
|
+
2,
|
42
|
+
3,
|
43
|
+
0x1fffffff,
|
44
|
+
0x20000000,
|
45
|
+
0x20000001,
|
46
|
+
1000999999,
|
47
|
+
0x3fffffff,
|
48
|
+
0x40000000,
|
49
|
+
0x40000001,
|
50
|
+
0x7fffffff,
|
51
|
+
0x80000000,
|
52
|
+
0x80000001,
|
53
|
+
0xffffffff,
|
54
|
+
0x100000000,
|
55
|
+
0x100000001
|
56
|
+
]
|