thunderboltlabs-rubyXL 1.2.10.1

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.
@@ -0,0 +1,1782 @@
1
+ require 'rubygems'
2
+ require 'rubyXL'
3
+
4
+ describe RubyXL::Worksheet do
5
+ before do
6
+ @workbook = RubyXL::Workbook.new
7
+ @worksheet = RubyXL::Worksheet.new(@workbook)
8
+ @workbook.worksheets << @worksheet
9
+ (0..10).each do |i|
10
+ (0..10).each do |j|
11
+ @worksheet.add_cell(i, j, "#{i}:#{j}")
12
+ end
13
+ end
14
+
15
+ @old_cell = Marshal.load(Marshal.dump(@worksheet[0][0]))
16
+ @old_cell_value = @worksheet[0][0].value
17
+ @old_cell_formula = @worksheet[0][0].formula
18
+ end
19
+
20
+ describe '.extract_data' do
21
+ it 'should return a 2d array of just the cell values (without style or formula information)' do
22
+ data = @worksheet.extract_data()
23
+ data[0][0].should == '0:0'
24
+ data.size.should == @worksheet.sheet_data.size
25
+ data[0].size.should == @worksheet[0].size
26
+ end
27
+ end
28
+
29
+ describe '.get_table' do
30
+ it 'should return nil if table cannot be found with specified string' do
31
+ @worksheet.get_table('TEST').should be_nil
32
+ end
33
+
34
+ it 'should return nil if table cannot be found with specified headers' do
35
+ @worksheet.get_table(['TEST']).should be_nil
36
+ end
37
+
38
+ it 'should return a hash when given an array of headers it can find, where :table points to an array of hashes (rows), where each symbol is a column' do
39
+ headers = ["0:0", "0:1", "0:4"]
40
+ table_hash = @worksheet.get_table(headers)
41
+
42
+ table_hash[:table].size.should == 10
43
+ table_hash["0:0"].size.should == 10
44
+ table_hash["0:1"].size.should == 10
45
+ table_hash["0:4"].size.should == 10
46
+ end
47
+ end
48
+
49
+ describe '.change_row_fill' do
50
+ it 'should raise error if hex color code not passed' do
51
+ lambda {
52
+ @worksheet.change_row_fill(0, 'G')
53
+ }.should raise_error
54
+ end
55
+
56
+ it 'should raise error if hex color code includes # character' do
57
+ lambda {
58
+ @worksheet.change_row_fill(3,'#FFF000')
59
+ }.should raise_error
60
+ end
61
+
62
+ it 'should make row and cell fill colors equal hex color code passed' do
63
+ @worksheet.change_row_fill(0, '111111')
64
+ @worksheet.get_row_fill(0).should == '111111'
65
+ @worksheet[0][5].fill_color.should == '111111'
66
+ end
67
+
68
+ it 'should cause error if a negative argument is passed in' do
69
+ lambda {
70
+ @worksheet.change_row_fill(-1,'111111')
71
+ }.should raise_error
72
+ end
73
+
74
+ it 'should expand matrix to fit argument if nonnegative' do
75
+ @worksheet.sheet_data.size.should == 11
76
+ @worksheet.change_row_fill(11,'111111')
77
+ @worksheet.get_row_fill(11).should == '111111'
78
+ @worksheet.sheet_data.size.should == 12
79
+ end
80
+ end
81
+
82
+ describe '.change_row_font_name' do
83
+ it 'should make row and cell font names equal font name passed' do
84
+ @worksheet.change_row_font_name(0, 'Arial')
85
+ @worksheet.get_row_font_name(0).should == 'Arial'
86
+ @worksheet[0][5].font_name.should == 'Arial'
87
+ end
88
+
89
+ it 'should cause error if a negative argument is passed in' do
90
+ lambda {
91
+ @worksheet.change_row_font_name(-1,'Arial')
92
+ }.should raise_error
93
+ end
94
+
95
+ it 'should expand matrix to fit argument if nonnegative' do
96
+ @worksheet.sheet_data.size.should == 11
97
+ @worksheet.change_row_font_name(11, 'Arial')
98
+ @worksheet.get_row_font_name(11).should == "Arial"
99
+ @worksheet.sheet_data.size.should == 12
100
+ end
101
+ end
102
+
103
+ describe '.change_row_font_size' do
104
+ it 'should make row and cell font sizes equal font number passed' do
105
+ @worksheet.change_row_font_size(0, 20)
106
+ @worksheet.get_row_font_size(0).should == 20
107
+ @worksheet[0][5].font_size.should == 20
108
+ end
109
+
110
+ it 'should cause an error if a string passed' do
111
+ lambda {
112
+ @worksheet.change_row_font_size(0, '20')
113
+ }.should raise_error
114
+ end
115
+
116
+ it 'should cause error if a negative argument is passed in' do
117
+ lambda {
118
+ @worksheet.change_row_font_size(-1,20)
119
+ }.should raise_error
120
+ end
121
+
122
+ it 'should expand matrix to fit argument if nonnegative' do
123
+ @worksheet.sheet_data.size.should == 11
124
+ @worksheet.change_row_font_size(11,20)
125
+ @worksheet.get_row_font_size(11).should == 20
126
+ @worksheet.sheet_data.size.should == 12
127
+ end
128
+ end
129
+
130
+ describe '.change_row_font_color' do
131
+ it 'should make row and cell font colors equal to font color passed' do
132
+ @worksheet.change_row_font_color(0, '0f0f0f')
133
+ @worksheet.get_row_font_color(0).should == '0f0f0f'
134
+ @worksheet[0][5].font_color.should == '0f0f0f'
135
+ end
136
+
137
+ it 'should raise error if hex color code not passed' do
138
+ lambda {
139
+ @worksheet.change_row_font_color(0, 'G')
140
+ }.should raise_error
141
+ end
142
+
143
+ it 'should raise error if hex color code includes # character' do
144
+ lambda {
145
+ @worksheet.change_row_font_color(3,'#FFF000')
146
+ }.should raise_error
147
+ end
148
+
149
+ it 'should cause error if a negative argument is passed in' do
150
+ lambda {
151
+ @worksheet.change_row_font_color(-1,'0f0f0f')
152
+ }.should raise_error
153
+ end
154
+
155
+ it 'should expand matrix to fit argument if nonnegative' do
156
+ @worksheet.sheet_data.size.should == 11
157
+ @worksheet.change_row_font_color(11,'0f0f0f')
158
+ @worksheet.get_row_font_color(11).should == '0f0f0f'
159
+ @worksheet.sheet_data.size.should == 12
160
+ end
161
+ end
162
+
163
+ describe '.change_row_italics' do
164
+ it 'should make row and cell fonts italicized when true is passed' do
165
+ @worksheet.change_row_italics(0,true)
166
+ @worksheet.is_row_italicized(0).should == true
167
+ @worksheet[0][5].is_italicized.should == true
168
+ end
169
+
170
+ it 'should cause error if a negative argument is passed in' do
171
+ lambda {
172
+ @worksheet.change_row_italics(-1,false)
173
+ }.should raise_error
174
+ end
175
+
176
+ it 'should expand matrix to fit argument if nonnegative' do
177
+ @worksheet.sheet_data.size.should == 11
178
+ @worksheet.change_row_italics(11,true)
179
+ @worksheet.is_row_italicized(11).should == true
180
+ @worksheet.sheet_data.size.should == 12
181
+ end
182
+ end
183
+
184
+ describe '.change_row_bold' do
185
+ it 'should make row and cell fonts bolded when true is passed' do
186
+ @worksheet.change_row_bold(0,true)
187
+ @worksheet.is_row_bolded(0).should == true
188
+ @worksheet[0][5].is_bolded.should == true
189
+ end
190
+
191
+ it 'should cause error if a negative argument is passed in' do
192
+ lambda {
193
+ @worksheet.change_row_bold(-1,false)
194
+ }.should raise_error
195
+ end
196
+
197
+ it 'should expand matrix to fit argument if nonnegative' do
198
+ @worksheet.sheet_data.size.should == 11
199
+ @worksheet.change_row_bold(11,true)
200
+ @worksheet.is_row_bolded(11).should == true
201
+ @worksheet.sheet_data.size.should == 12
202
+ end
203
+ end
204
+
205
+ describe '.change_row_underline' do
206
+ it 'should make row and cell fonts underlined when true is passed' do
207
+ @worksheet.change_row_underline(0,true)
208
+ @worksheet.is_row_underlined(0).should == true
209
+ @worksheet[0][5].is_underlined.should == true
210
+ end
211
+
212
+ it 'should cause error if a negative argument is passed in' do
213
+ lambda {
214
+ @worksheet.change_row_underline(-1,false)
215
+ }.should raise_error
216
+ end
217
+
218
+ it 'should expand matrix to fit argument if nonnegative' do
219
+ @worksheet.sheet_data.size.should == 11
220
+ @worksheet.change_row_underline(11,true)
221
+ @worksheet.is_row_underlined(11).should == true
222
+ @worksheet.sheet_data.size.should == 12
223
+ end
224
+ end
225
+
226
+ describe '.change_row_strikethrough' do
227
+ it 'should make row and cell fonts struckthrough when true is passed' do
228
+ @worksheet.change_row_strikethrough(0,true)
229
+ @worksheet.is_row_struckthrough(0).should == true
230
+ @worksheet[0][5].is_struckthrough.should == true
231
+ end
232
+
233
+ it 'should cause error if a negative argument is passed in' do
234
+ lambda {
235
+ @worksheet.change_row_strikethrough(-1,false)
236
+ }.should raise_error
237
+ end
238
+
239
+ it 'should expand matrix to fit argument if nonnegative' do
240
+ @worksheet.sheet_data.size.should == 11
241
+ @worksheet.change_row_strikethrough(11,true)
242
+ @worksheet.is_row_struckthrough(11).should == true
243
+ @worksheet.sheet_data.size.should == 12
244
+ end
245
+ end
246
+
247
+ describe '.change_row_height' do
248
+ it 'should make row height match number which is passed' do
249
+ @worksheet.change_row_height(0,30.0002)
250
+ @worksheet.get_row_height(0).should == 30.0002
251
+ end
252
+
253
+ it 'should make row height a number equivalent of the string passed if it is a string which is a number' do
254
+ @worksheet.change_row_height(0,'30.0002')
255
+ @worksheet.get_row_height(0).should == 30.0002
256
+ end
257
+
258
+ it 'should cause error if a string which is not a number' do
259
+ lambda {
260
+ @worksheet.change_row_height(0,'TEST')
261
+ }.should raise_error
262
+ end
263
+
264
+ it 'should cause error if a negative argument is passed in' do
265
+ lambda {
266
+ @worksheet.change_row_height(-1,30)
267
+ }.should raise_error
268
+ end
269
+
270
+ it 'should expand matrix to fit argument if nonnegative' do
271
+ @worksheet.sheet_data.size.should == 11
272
+ @worksheet.change_row_height(11,30)
273
+ @worksheet.get_row_height(11).should == 30
274
+ @worksheet.sheet_data.size.should == 12
275
+ end
276
+ end
277
+
278
+ describe '.change_row_horizontal_alignment' do
279
+ it 'should cause row and cells to horizontally align as specified by the passed in string' do
280
+ @worksheet.change_row_horizontal_alignment(0,'center')
281
+ @worksheet.get_row_horizontal_alignment(0).should == 'center'
282
+ @worksheet[0][5].horizontal_alignment.should == 'center'
283
+ end
284
+
285
+ it 'should cause error if nil, "center", "justify", "left", "right", or "distributed" is not passed' do
286
+ lambda {
287
+ @worksheet.change_row_horizontal_alignment(0,'TEST')
288
+ }.should raise_error
289
+ end
290
+
291
+ it 'should cause error if a negative argument is passed in' do
292
+ lambda {
293
+ @worksheet.change_row_horizontal_alignment(-1,'center')
294
+ }.should raise_error
295
+ end
296
+
297
+ it 'should expand matrix to fit argument if nonnegative' do
298
+ @worksheet.sheet_data.size.should == 11
299
+ @worksheet.change_row_horizontal_alignment(11,'center')
300
+ @worksheet.get_row_horizontal_alignment(11).should == 'center'
301
+ @worksheet.sheet_data.size.should == 12
302
+ end
303
+ end
304
+
305
+ describe '.change_row_vertical_alignment' do
306
+ it 'should cause row and cells to vertically align as specified by the passed in string' do
307
+ @worksheet.change_row_vertical_alignment(0,'center')
308
+ @worksheet.get_row_vertical_alignment(0).should == 'center'
309
+ @worksheet[0][5].vertical_alignment.should == 'center'
310
+ end
311
+
312
+ it 'should cause error if nil, "center", "justify", "top", "bottom", or "distributed" is not passed' do
313
+ lambda {
314
+ @worksheet.change_row_vertical_alignment(0,'TEST')
315
+ }.should raise_error
316
+ end
317
+
318
+ it 'should cause error if a negative argument is passed in' do
319
+ lambda {
320
+ @worksheet.change_row_vertical_alignment(-1,'center')
321
+ }.should raise_error
322
+ end
323
+
324
+ it 'should expand matrix to fit argument if nonnegative' do
325
+ @worksheet.sheet_data.size.should == 11
326
+ @worksheet.change_row_vertical_alignment(11,'center')
327
+ @worksheet.get_row_vertical_alignment(11).should == 'center'
328
+ @worksheet.sheet_data.size.should == 12
329
+ end
330
+ end
331
+
332
+ describe '.change_row_border_top' do
333
+ it 'should cause row and cells to have border at top of specified weight' do
334
+ @worksheet.change_row_border_top(0, 'thin')
335
+ @worksheet.get_row_border_top(0).should == 'thin'
336
+ @worksheet[0][5].border_top.should == 'thin'
337
+ end
338
+
339
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
340
+ lambda {
341
+ @worksheet.change_row_border_top(0,'TEST')
342
+ }.should raise_error
343
+ end
344
+
345
+ it 'should cause error if a negative argument is passed in' do
346
+ lambda {
347
+ @worksheet.change_row_border_top(-1,'thin')
348
+ }.should raise_error
349
+ end
350
+
351
+ it 'should expand matrix to fit argument if nonnegative' do
352
+ @worksheet.sheet_data.size.should == 11
353
+ @worksheet.change_row_border_top(11,'thin')
354
+ @worksheet.get_row_border_top(11).should == 'thin'
355
+ @worksheet.sheet_data.size.should == 12
356
+ end
357
+ end
358
+
359
+ describe '.change_row_border_left' do
360
+ it 'should cause row and cells to have border at left of specified weight' do
361
+ @worksheet.change_row_border_left(0, 'thin')
362
+ @worksheet.get_row_border_left(0).should == 'thin'
363
+ @worksheet[0][5].border_left.should == 'thin'
364
+ end
365
+
366
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
367
+ lambda {
368
+ @worksheet.change_row_border_left(0,'TEST')
369
+ }.should raise_error
370
+ end
371
+
372
+ it 'should cause error if a negative argument is passed in' do
373
+ lambda {
374
+ @worksheet.change_row_border_left(-1,'thin')
375
+ }.should raise_error
376
+ end
377
+
378
+ it 'should expand matrix to fit argument if nonnegative' do
379
+ @worksheet.sheet_data.size.should == 11
380
+ @worksheet.change_row_border_left(11,'thin')
381
+ @worksheet.get_row_border_left(11).should == 'thin'
382
+ @worksheet.sheet_data.size.should == 12
383
+ end
384
+ end
385
+
386
+ describe '.change_row_border_right' do
387
+ it 'should cause row and cells to have border at right of specified weight' do
388
+ @worksheet.change_row_border_right(0, 'thin')
389
+ @worksheet.get_row_border_right(0).should == 'thin'
390
+ @worksheet[0][5].border_right.should == 'thin'
391
+ end
392
+
393
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
394
+ lambda {
395
+ @worksheet.change_row_border_right(0,'TEST')
396
+ }.should raise_error
397
+ end
398
+
399
+ it 'should cause error if a negative argument is passed in' do
400
+ lambda {
401
+ @worksheet.change_row_border_right(-1,'thin')
402
+ }.should raise_error
403
+ end
404
+
405
+ it 'should expand matrix to fit argument if nonnegative' do
406
+ @worksheet.sheet_data.size.should == 11
407
+ @worksheet.change_row_border_right(11,'thin')
408
+ @worksheet.get_row_border_right(11).should == 'thin'
409
+ @worksheet.sheet_data.size.should == 12
410
+ end
411
+ end
412
+
413
+ describe '.change_row_border_bottom' do
414
+ it 'should cause row to have border at bottom of specified weight' do
415
+ @worksheet.change_row_border_bottom(0, 'thin')
416
+ @worksheet.get_row_border_bottom(0).should == 'thin'
417
+ @worksheet[0][5].border_bottom.should == 'thin'
418
+ end
419
+
420
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
421
+ lambda {
422
+ @worksheet.change_row_border_bottom(0,'TEST')
423
+ }.should raise_error
424
+ end
425
+
426
+ it 'should cause error if a negative argument is passed in' do
427
+ lambda {
428
+ @worksheet.change_row_border_bottom(-1,'thin')
429
+ }.should raise_error
430
+ end
431
+
432
+ it 'should expand matrix to fit argument if nonnegative' do
433
+ @worksheet.sheet_data.size.should == 11
434
+ @worksheet.change_row_border_bottom(11,'thin')
435
+ @worksheet.get_row_border_bottom(11).should == 'thin'
436
+ @worksheet.sheet_data.size.should == 12
437
+ end
438
+ end
439
+
440
+ describe '.change_row_border_diagonal' do
441
+ it 'should cause row to have border at diagonal of specified weight' do
442
+ @worksheet.change_row_border_diagonal(0, 'thin')
443
+ @worksheet.get_row_border_diagonal(0).should == 'thin'
444
+ @worksheet[0][5].border_diagonal.should == 'thin'
445
+ end
446
+
447
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
448
+ lambda {
449
+ @worksheet.change_row_border_diagonal(0,'TEST')
450
+ }.should raise_error
451
+ end
452
+
453
+ it 'should cause error if a negative argument is passed in' do
454
+ lambda {
455
+ @worksheet.change_row_border_diagonal(-1,'thin')
456
+ }.should raise_error
457
+ end
458
+
459
+ it 'should expand matrix to fit argument if nonnegative' do
460
+ @worksheet.sheet_data.size.should == 11
461
+ @worksheet.change_row_border_diagonal(11,'thin')
462
+ @worksheet.get_row_border_diagonal(11).should == 'thin'
463
+ @worksheet.sheet_data.size.should == 12
464
+ end
465
+ end
466
+
467
+ describe '.change_column_font_name' do
468
+ it 'should cause column and cell font names to match string passed in' do
469
+ @worksheet.change_column_font_name(0, 'Arial')
470
+ @worksheet.get_column_font_name(0).should == 'Arial'
471
+ @worksheet[5][0].font_name.should == 'Arial'
472
+ end
473
+
474
+ it 'should cause error if a negative argument is passed in' do
475
+ lambda {
476
+ @worksheet.change_column_font_name(-1,'Arial')
477
+ }.should raise_error
478
+ end
479
+
480
+ it 'should expand matrix to fit argument if nonnegative' do
481
+ @worksheet.sheet_data[0].size.should == 11
482
+ @worksheet.change_column_font_name(11,'Arial')
483
+ @worksheet.get_column_font_name(11).should == 'Arial'
484
+ @worksheet.sheet_data[0].size.should == 12
485
+ end
486
+ end
487
+
488
+ describe '.change_column_font_size' do
489
+ it 'should make column and cell font sizes equal font number passed' do
490
+ @worksheet.change_column_font_size(0, 20)
491
+ @worksheet.get_column_font_size(0).should == 20
492
+ @worksheet[5][0].font_size.should == 20
493
+ end
494
+
495
+ it 'should cause an error if a string passed' do
496
+ lambda {
497
+ @worksheet.change_column_font_size(0, '20')
498
+ }.should raise_error
499
+ end
500
+
501
+ it 'should cause error if a negative argument is passed in' do
502
+ lambda {
503
+ @worksheet.change_column_font_size(-1,20)
504
+ }.should raise_error
505
+ end
506
+
507
+ it 'should expand matrix to fit argument if nonnegative'do
508
+ @worksheet.sheet_data[0].size.should == 11
509
+ @worksheet.change_column_font_size(11,20)
510
+ @worksheet.get_column_font_size(11).should == 20
511
+ @worksheet.sheet_data[0].size.should == 12
512
+ end
513
+ end
514
+
515
+ describe '.change_column_font_color' do
516
+ it 'should make column and cell font colors equal to font color passed' do
517
+ @worksheet.change_column_font_color(0, '0f0f0f')
518
+ @worksheet.get_column_font_color(0).should == '0f0f0f'
519
+ @worksheet[5][0].font_color.should == '0f0f0f'
520
+ end
521
+
522
+ it 'should raise error if hex color code not passed' do
523
+ lambda {
524
+ @worksheet.change_column_font_color(0, 'G')
525
+ }.should raise_error
526
+ end
527
+
528
+ it 'should raise error if hex color code includes # character' do
529
+ lambda {
530
+ @worksheet.change_column_font_color(0,'#FFF000')
531
+ }.should raise_error
532
+ end
533
+
534
+ it 'should cause error if a negative argument is passed in' do
535
+ lambda {
536
+ @worksheet.change_column_font_color(-1,'0f0f0f')
537
+ }.should raise_error
538
+ end
539
+
540
+ it 'should expand matrix to fit argument if nonnegative'do
541
+ @worksheet.sheet_data[0].size.should == 11
542
+ @worksheet.change_column_font_color(11,'0f0f0f')
543
+ @worksheet.get_column_font_color(11).should == '0f0f0f'
544
+ @worksheet.sheet_data[0].size.should == 12
545
+ end
546
+ end
547
+
548
+ describe '.change_column_italics' do
549
+ it 'should make column and cell fonts italicized when true is passed' do
550
+ @worksheet.change_column_italics(0,true)
551
+ @worksheet.is_column_italicized(0).should == true
552
+ @worksheet[5][0].is_italicized.should == true
553
+ end
554
+
555
+ it 'should cause error if a negative argument is passed in' do
556
+ lambda {
557
+ @worksheet.change_column_italicized(-1,false)
558
+ }.should raise_error
559
+ end
560
+
561
+ it 'should expand matrix to fit argument if nonnegative'do
562
+ @worksheet.sheet_data[0].size.should == 11
563
+ @worksheet.change_column_italics(11,true)
564
+ @worksheet.is_column_italicized(11).should == true
565
+ @worksheet.sheet_data[0].size.should == 12
566
+ end
567
+ end
568
+
569
+ describe '.change_column_bold' do
570
+ it 'should make column and cell fonts bolded when true is passed' do
571
+ @worksheet.change_column_bold(0,true)
572
+ @worksheet.is_column_bolded(0).should == true
573
+ @worksheet[5][0].is_bolded.should == true
574
+ end
575
+
576
+ it 'should cause error if a negative argument is passed in' do
577
+ lambda {
578
+ @worksheet.change_column_bold(-1,false)
579
+ }.should raise_error
580
+ end
581
+
582
+ it 'should expand matrix to fit argument if nonnegative'do
583
+ @worksheet.sheet_data[0].size.should == 11
584
+ @worksheet.change_column_bold(11,true)
585
+ @worksheet.is_column_bolded(11).should == true
586
+ @worksheet.sheet_data[0].size.should == 12
587
+ end
588
+ end
589
+
590
+ describe '.change_column_underline' do
591
+ it 'should make column and cell fonts underlined when true is passed' do
592
+ @worksheet.change_column_underline(0,true)
593
+ @worksheet.is_column_underlined(0).should == true
594
+ @worksheet[5][0].is_underlined.should == true
595
+ end
596
+
597
+ it 'should cause error if a negative argument is passed in' do
598
+ lambda {
599
+ @worksheet.change_column_underline(-1,false)
600
+ }.should raise_error
601
+ end
602
+
603
+ it 'should expand matrix to fit argument if nonnegative'do
604
+ @worksheet.sheet_data[0].size.should == 11
605
+ @worksheet.change_column_underline(11,true)
606
+ @worksheet.is_column_underlined(11).should == true
607
+ @worksheet.sheet_data[0].size.should == 12
608
+ end
609
+ end
610
+
611
+ describe '.change_column_strikethrough' do
612
+ it 'should make column and cell fonts struckthrough when true is passed' do
613
+ @worksheet.change_column_strikethrough(0,true)
614
+ @worksheet.is_column_struckthrough(0).should == true
615
+ @worksheet[5][0].is_struckthrough.should == true
616
+ end
617
+
618
+ it 'should cause error if a negative argument is passed in' do
619
+ lambda {
620
+ @worksheet.change_column_strikethrough(-1,false)
621
+ }.should raise_error
622
+ end
623
+
624
+ it 'should expand matrix to fit argument if nonnegative'do
625
+ @worksheet.sheet_data[0].size.should == 11
626
+ @worksheet.change_column_strikethrough(11,true)
627
+ @worksheet.is_column_struckthrough(11).should == true
628
+ @worksheet.sheet_data[0].size.should == 12
629
+ end
630
+ end
631
+
632
+ describe '.change_column_width' do
633
+ it 'should make column width match number which is passed' do
634
+ @worksheet.change_column_width(0,30.0002)
635
+ @worksheet.get_column_width(0).should == 30.0002
636
+ end
637
+
638
+ it 'should make column width a number equivalent of the string passed if it is a string which is a number' do
639
+ @worksheet.change_column_width(0,'30.0002')
640
+ @worksheet.get_column_width(0).should == 30.0002
641
+ end
642
+
643
+ it 'should cause error if a string which is not a number' do
644
+ lambda {
645
+ @worksheet.change_column_width(0,'TEST')
646
+ }.should raise_error
647
+ end
648
+
649
+ it 'should cause error if a negative argument is passed in' do
650
+ lambda {
651
+ @worksheet.change_column_width(-1,10)
652
+ }.should raise_error
653
+ end
654
+
655
+ it 'should expand matrix to fit argument if nonnegative'do
656
+ @worksheet.sheet_data[0].size.should == 11
657
+ @worksheet.change_column_width(11,30)
658
+ @worksheet.get_column_width(11).should == 30
659
+ @worksheet.sheet_data[0].size.should == 12
660
+ end
661
+ end
662
+
663
+ describe '.change_column_fill' do
664
+ it 'should raise error if hex color code not passed' do
665
+ lambda {
666
+ @worksheet.change_column_fill(0, 'G')
667
+ }.should raise_error
668
+ end
669
+
670
+ it 'should raise error if hex color code includes # character' do
671
+ lambda {
672
+ @worksheet.change_column_fill(3,'#FFF000')
673
+ }.should raise_error
674
+ end
675
+
676
+ it 'should make column and cell fill colors equal hex color code passed' do
677
+ @worksheet.change_column_fill(0, '111111')
678
+ @worksheet.get_column_fill(0).should == '111111'
679
+ @worksheet[5][0].fill_color.should == '111111'
680
+ end
681
+
682
+ it 'should cause error if a negative argument is passed in' do
683
+ lambda {
684
+ @worksheet.change_column_fill(-1,'111111')
685
+ }.should raise_error
686
+ end
687
+
688
+ it 'should expand matrix to fit argument if nonnegative'do
689
+ @worksheet.sheet_data[0].size.should == 11
690
+ @worksheet.change_column_fill(11,'111111')
691
+ @worksheet.get_column_fill(11).should == '111111'
692
+ @worksheet.sheet_data[0].size.should == 12
693
+ end
694
+ end
695
+
696
+ describe '.change_column_horizontal_alignment' do
697
+ it 'should cause column and cell to horizontally align as specified by the passed in string' do
698
+ @worksheet.change_column_horizontal_alignment(0,'center')
699
+ @worksheet.get_column_horizontal_alignment(0).should == 'center'
700
+ @worksheet[5][0].horizontal_alignment.should == 'center'
701
+ end
702
+
703
+ it 'should cause error if nil, "center", "justify", "left", "right", or "distributed" is not passed' do
704
+ lambda {
705
+ @worksheet.change_column_horizontal_alignment(0,'TEST')
706
+ }.should raise_error
707
+ end
708
+
709
+ it 'should cause error if a negative argument is passed in' do
710
+ lambda {
711
+ @worksheet.change_column_horizontal_alignment(-1,'center')
712
+ }.should raise_error
713
+ end
714
+
715
+ it 'should expand matrix to fit argument if nonnegative'do
716
+ @worksheet.sheet_data[0].size.should == 11
717
+ @worksheet.change_column_horizontal_alignment(11,'center')
718
+ @worksheet.get_column_horizontal_alignment(11).should == 'center'
719
+ @worksheet.sheet_data[0].size.should == 12
720
+ end
721
+ end
722
+
723
+ describe '.change_column_vertical_alignment' do
724
+ it 'should cause column and cell to vertically align as specified by the passed in string' do
725
+ @worksheet.change_column_vertical_alignment(0,'center')
726
+ @worksheet.get_column_vertical_alignment(0).should == 'center'
727
+ @worksheet[5][0].vertical_alignment.should == 'center'
728
+ end
729
+
730
+ it 'should cause error if nil, "center", "justify", "top", "bottom", or "distributed" is not passed' do
731
+ lambda {
732
+ @worksheet.change_column_vertical_alignment(0,'TEST')
733
+ }.should raise_error
734
+ end
735
+
736
+ it 'should cause error if a negative argument is passed in' do
737
+ lambda {
738
+ @worksheet.change_column_vertical_alignment(-1,'center')
739
+ }.should raise_error
740
+ end
741
+
742
+ it 'should expand matrix to fit argument if nonnegative'do
743
+ @worksheet.sheet_data[0].size.should == 11
744
+ @worksheet.change_column_vertical_alignment(11,'center')
745
+ @worksheet.get_column_vertical_alignment(11).should == 'center'
746
+ @worksheet.sheet_data[0].size.should == 12
747
+ end
748
+ end
749
+
750
+ describe '.change_column_border_top' do
751
+ it 'should cause column and cells within to have border at top of specified weight' do
752
+ @worksheet.change_column_border_top(0, 'thin')
753
+ @worksheet.get_column_border_top(0).should == 'thin'
754
+ @worksheet[5][0].border_top.should == 'thin'
755
+ end
756
+
757
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
758
+ lambda {
759
+ @worksheet.change_column_border_top(0,'TEST')
760
+ }.should raise_error
761
+ end
762
+
763
+ it 'should cause error if a negative argument is passed in' do
764
+ lambda {
765
+ @worksheet.change_column_border_top(-1,'thin')
766
+ }.should raise_error
767
+ end
768
+
769
+ it 'should expand matrix to fit argument if nonnegative'do
770
+ @worksheet.sheet_data[0].size.should == 11
771
+ @worksheet.change_column_border_top(11,'thin')
772
+ @worksheet.get_column_border_top(11).should == 'thin'
773
+ @worksheet.sheet_data[0].size.should == 12
774
+ end
775
+ end
776
+
777
+ describe '.change_column_border_left' do
778
+ it 'should cause column and cells within to have border at left of specified weight' do
779
+ @worksheet.change_column_border_left(0, 'thin')
780
+ @worksheet.get_column_border_left(0).should == 'thin'
781
+ @worksheet[5][0].border_left.should == 'thin'
782
+ end
783
+
784
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
785
+ lambda {
786
+ @worksheet.change_column_border_left(0,'TEST')
787
+ }.should raise_error
788
+ end
789
+
790
+ it 'should cause error if a negative argument is passed in' do
791
+ lambda {
792
+ @worksheet.change_column_border_left(-1,'thin')
793
+ }.should raise_error
794
+ end
795
+
796
+ it 'should expand matrix to fit argument if nonnegative' do
797
+ @worksheet.sheet_data[0].size.should == 11
798
+ @worksheet.change_column_border_left(11,'thin')
799
+ @worksheet.get_column_border_left(11).should == 'thin'
800
+ @worksheet.sheet_data[0].size.should == 12
801
+ end
802
+ end
803
+
804
+ describe '.change_column_border_right' do
805
+ it 'should cause column and cells within to have border at right of specified weight' do
806
+ @worksheet.change_column_border_right(0, 'thin')
807
+ @worksheet.get_column_border_right(0).should == 'thin'
808
+ @worksheet[5][0].border_right.should == 'thin'
809
+ end
810
+
811
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
812
+ lambda {
813
+ @worksheet.change_column_border_right(0,'TEST')
814
+ }.should raise_error
815
+ end
816
+
817
+ it 'should cause error if a negative argument is passed in' do
818
+ lambda {
819
+ @worksheet.change_column_border_right(-1,'thin')
820
+ }.should raise_error
821
+ end
822
+
823
+ it 'should expand matrix to fit argument if nonnegative'do
824
+ @worksheet.sheet_data[0].size.should == 11
825
+ @worksheet.change_column_border_right(11,'thin')
826
+ @worksheet.get_column_border_right(11).should == 'thin'
827
+ @worksheet.sheet_data[0].size.should == 12
828
+ end
829
+ end
830
+
831
+ describe '.change_column_border_bottom' do
832
+ it 'should cause column and cells within to have border at bottom of specified weight' do
833
+ @worksheet.change_column_border_bottom(0, 'thin')
834
+ @worksheet.get_column_border_bottom(0).should == 'thin'
835
+ @worksheet[5][0].border_bottom.should == 'thin'
836
+ end
837
+
838
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
839
+ lambda {
840
+ @worksheet.change_column_border_bottom(0,'TEST')
841
+ }.should raise_error
842
+ end
843
+
844
+ it 'should cause error if a negative argument is passed in' do
845
+ lambda {
846
+ @worksheet.change_column_border_bottom(-1,'thin')
847
+ }.should raise_error
848
+ end
849
+
850
+ it 'should expand matrix to fit argument if nonnegative'do
851
+ @worksheet.sheet_data[0].size.should == 11
852
+ @worksheet.change_column_border_bottom(11,'thin')
853
+ @worksheet.get_column_border_bottom(11).should == 'thin'
854
+ @worksheet.sheet_data[0].size.should == 12
855
+ end
856
+ end
857
+
858
+ describe '.change_column_border_diagonal' do
859
+ it 'should cause column and cells within to have border at diagonal of specified weight' do
860
+ @worksheet.change_column_border_diagonal(0, 'thin')
861
+ @worksheet.get_column_border_diagonal(0).should == 'thin'
862
+ @worksheet[5][0].border_diagonal.should == 'thin'
863
+ end
864
+
865
+ it 'should cause error if nil, "thin", "thick", "hairline", or "medium" is not passed' do
866
+ lambda {
867
+ @worksheet.change_column_border_diagonal(0,'TEST')
868
+ }.should raise_error
869
+ end
870
+
871
+ it 'should cause error if a negative argument is passed in' do
872
+ lambda {
873
+ @worksheet.change_column_border_diagonal(-1,'thin')
874
+ }.should raise_error
875
+ end
876
+
877
+ it 'should expand matrix to fit argument if nonnegative' do
878
+ @worksheet.sheet_data[0].size.should == 11
879
+ @worksheet.change_column_border_diagonal(11,'thin')
880
+ @worksheet.get_column_border_diagonal(11).should == 'thin'
881
+ @worksheet.sheet_data[0].size.should == 12
882
+ end
883
+ end
884
+
885
+ describe '.merge_cells' do
886
+ it 'should merge cells in any valid range specified by indices' do
887
+ @worksheet.merge_cells(0,0,1,1)
888
+ @worksheet.merged_cells.include?({:attributes=>{:ref=>"A1:B2"}}).should == true
889
+ end
890
+
891
+ it 'should cause an error if a negative number is passed' do
892
+ lambda {
893
+ @worksheet.merge_cells(0,0,-1,0)
894
+ }.should raise_error
895
+ end
896
+ end
897
+
898
+ describe '.add_cell' do
899
+ it 'should add new cell where specified, even if a cell is already there (default)' do
900
+ @worksheet.add_cell(0,0,'TEST')
901
+ @worksheet[0][0].value.should_not == @old_cell_value
902
+ @worksheet[0][0].value.should == 'TEST'
903
+ end
904
+
905
+ it 'should add new cell where specified with formula, even if a cell is already there (default)' do
906
+ @worksheet.add_cell(0,0,'','SUM(A2:A10)')
907
+ @worksheet[0][0].value.should_not == @old_cell_value
908
+ @worksheet[0][0].formula.should_not == @old_cell_formula
909
+ @worksheet[0][0].value.should == ''
910
+ @worksheet[0][0].formula.should == 'SUM(A2:A10)'
911
+ end
912
+
913
+ it 'should not overwrite when a cell is present when overwrite is specified to be false' do
914
+ @worksheet.add_cell(0,0,'TEST','B2',false)
915
+ @worksheet[0][0].value.should == @old_cell_value
916
+ @worksheet[0][0].formula.should == @old_cell_formula
917
+ end
918
+
919
+ it 'should still add a new cell when there is no cell to be overwritten' do
920
+ @worksheet.add_cell(11,11,'TEST','B2',false)
921
+ @worksheet[11][11].value.should == 'TEST'
922
+ @worksheet[11][11].formula.should == 'B2'
923
+ end
924
+
925
+ it 'should cause error if a negative argument is passed in' do
926
+ lambda {
927
+ @worksheet.add_cell(-1,-1,'')
928
+ }.should raise_error
929
+ end
930
+ end
931
+
932
+ describe '.add_cell_obj' do
933
+ it 'should add already created cell object to worksheet, even if a cell is already there (default)' do
934
+ new_cell = RubyXL::Cell.new(@worksheet,0,0,'TEST','B2')
935
+ @worksheet.add_cell_obj(new_cell)
936
+ @worksheet[0][0].value.should_not == @old_cell_value
937
+ @worksheet[0][0].formula.should_not == @old_cell_formula
938
+ @worksheet[0][0].value.should == 'TEST'
939
+ @worksheet[0][0].formula.should == 'B2'
940
+ end
941
+
942
+ it 'should not add already created cell object to already occupied cell if overwrite is false' do
943
+ new_cell = RubyXL::Cell.new(@worksheet,0,0,'TEST','B2')
944
+ @worksheet.add_cell_obj(new_cell,false)
945
+ @worksheet[0][0].value.should == @old_cell_value
946
+ @worksheet[0][0].formula.should == @old_cell_formula
947
+ end
948
+
949
+ it 'should cause error if a negative argument is passed in' do
950
+ lambda {
951
+ @worksheet.add_cell_obj(-1)
952
+ }.should raise_error
953
+ end
954
+
955
+ it 'should expand matrix to fit argument if nonnegative' do
956
+ @worksheet.sheet_data.size.should == 11
957
+ new_cell = RubyXL::Cell.new(@worksheet,11,11,'TEST','B2')
958
+ @worksheet.add_cell_obj(new_cell)
959
+ @worksheet.sheet_data.size.should == 12
960
+ end
961
+ end
962
+
963
+ describe '.delete_row' do
964
+ it 'should delete a row at index specified, "pushing" everything else "up"' do
965
+ @worksheet.delete_row(0)
966
+ @worksheet[0][0].value.should == "1:0"
967
+ @worksheet[0][0].formula.should be_nil
968
+ @worksheet[0][0].row.should == 0
969
+ @worksheet[0][0].column.should == 0
970
+ end
971
+
972
+ it 'should delete a row at index specified, adjusting styles for other rows' do
973
+ @worksheet.change_row_font_name(1,"Courier")
974
+ @worksheet.delete_row(0)
975
+ @worksheet.get_row_font_name(0).should == "Courier"
976
+ end
977
+
978
+ it 'should preserve (rather than fix) formulas that reference cells in "pushed up" rows' do
979
+ @worksheet.add_cell(11,0,nil,'SUM(A1:A10)')
980
+ @worksheet.delete_row(0)
981
+ @worksheet[10][0].formula.should == 'SUM(A1:A10)'
982
+ end
983
+
984
+ it 'should cause error if a negative argument is passed in' do
985
+ lambda {
986
+ @worksheet.delete_row(-1)
987
+ }.should raise_error
988
+ end
989
+ end
990
+
991
+ describe '.insert_row' do
992
+ it 'should insert a row at index specified, "pushing" everything else "down"' do
993
+ @worksheet.insert_row(0)
994
+ @worksheet[0][0].should be_nil
995
+ @worksheet[1][0].value.should == @old_cell_value
996
+ @worksheet[1][0].formula.should == @old_cell_formula
997
+ end
998
+
999
+ it 'should insert a row at index specified, copying styles from row "above"' do
1000
+ @worksheet.change_row_font_name(0,'Courier')
1001
+ @worksheet.insert_row(1)
1002
+ @worksheet.get_row_font_name(1).should == 'Courier'
1003
+ end
1004
+
1005
+ it 'should preserve (rather than fix) formulas that reference cells "pushed down" rows' do
1006
+ @worksheet.add_cell(5,0,nil,'SUM(A1:A4)')
1007
+ @worksheet.insert_row(0)
1008
+ @worksheet[6][0].formula.should == 'SUM(A1:A4)'
1009
+ end
1010
+
1011
+ it 'should cause error if a negative argument is passed in' do
1012
+ lambda {
1013
+ @worksheet.insert_row(-1)
1014
+ }.should raise_error
1015
+ end
1016
+
1017
+ it 'should expand matrix to fit argument if nonnegative' do
1018
+ @worksheet.sheet_data.size.should == 11
1019
+ @worksheet.insert_row(11)
1020
+ @worksheet.sheet_data.size.should == 13
1021
+ end
1022
+ end
1023
+
1024
+ describe '.delete_column' do
1025
+ it 'should delete a column at index specified, "pushing" everything else "left"' do
1026
+ @worksheet.delete_column(0)
1027
+ @worksheet[0][0].value.should == "0:1"
1028
+ @worksheet[0][0].formula.should be_nil
1029
+ @worksheet[0][0].row.should == 0
1030
+ @worksheet[0][0].column.should == 0
1031
+ end
1032
+
1033
+ it 'should delete a column at index specified, "pushing" styles "left"' do
1034
+ @worksheet.change_column_font_name(1,"Courier")
1035
+ @worksheet.delete_column(0)
1036
+ @worksheet.get_column_font_name(0).should == "Courier"
1037
+ end
1038
+
1039
+ it 'should preserve (rather than fix) formulas that reference cells in "pushed left" columns' do
1040
+ @worksheet.add_cell(0,4,nil,'SUM(A1:D1)')
1041
+ @worksheet.delete_column(0)
1042
+ @worksheet[0][3].formula.should == 'SUM(A1:D1)'
1043
+ end
1044
+
1045
+ it 'should cause error if negative argument is passed in' do
1046
+ lambda {
1047
+ @worksheet.delete_column(-1)
1048
+ }.should raise_error
1049
+ end
1050
+ end
1051
+
1052
+ describe '.insert_column' do
1053
+ it 'should insert a column at index specified, "pushing" everything else "right"' do
1054
+ @worksheet.insert_column(0)
1055
+ @worksheet[0][0].should be_nil
1056
+ @worksheet[0][1].value.should == @old_cell_value
1057
+ @worksheet[0][1].formula.should == @old_cell_formula
1058
+ end
1059
+
1060
+ it 'should insert a column at index specified, copying styles from column to "left"' do
1061
+ @worksheet.change_column_font_name(0,'Courier')
1062
+ @worksheet.insert_column(1)
1063
+ @worksheet.get_column_font_name(1).should == 'Courier'
1064
+ end
1065
+
1066
+ it 'should insert a column at 0 without copying any styles, when passed 0 as column index' do
1067
+ @worksheet.change_column_font_name(0,'Courier')
1068
+ @worksheet.insert_column(0)
1069
+ @worksheet.get_column_font_name(0).should == 'Verdana' #not courier
1070
+ end
1071
+
1072
+ it 'should preserve (rather than fix) formulas that reference cells in "pushed right" column' do
1073
+ @worksheet.add_cell(0,5,nil,'SUM(A1:D1)')
1074
+ @worksheet.insert_column(0)
1075
+ @worksheet[0][6].formula.should == 'SUM(A1:D1)'
1076
+ end
1077
+
1078
+ it 'should cause error if a negative argument is passed in' do
1079
+ lambda {
1080
+ @worksheet.insert_column(-1)
1081
+ }.should raise_error
1082
+ end
1083
+
1084
+ it 'should expand matrix to fit argument if nonnegative' do
1085
+ @worksheet.sheet_data[0].size.should == 11
1086
+ @worksheet.insert_column(11)
1087
+ @worksheet.sheet_data[0].size.should == 13
1088
+ end
1089
+ end
1090
+
1091
+ describe '.insert_cell' do
1092
+ it 'should simply add a cell if no shift argument is specified' do
1093
+ @worksheet.insert_cell(0,0,'test')
1094
+ @worksheet[0][0].value.should == 'test'
1095
+ @worksheet[0][1].value.should == '0:1'
1096
+ @worksheet[1][0].value.should == '1:0'
1097
+ end
1098
+
1099
+ it 'should shift cells to the right if :right is specified' do
1100
+ @worksheet.insert_cell(0,0,'test',nil,:right)
1101
+ @worksheet[0][0].value.should == 'test'
1102
+ @worksheet[0][1].value.should == '0:0'
1103
+ @worksheet[1][0].value.should == '1:0'
1104
+ end
1105
+
1106
+ it 'should shift cells down if :down is specified' do
1107
+ @worksheet.insert_cell(0,0,'test',nil,:down)
1108
+ @worksheet[0][0].value.should == 'test'
1109
+ @worksheet[0][1].value.should == '0:1'
1110
+ @worksheet[1][0].value.should == '0:0'
1111
+ end
1112
+
1113
+ it 'should cause error if shift argument is specified whcih is not :right or :down' do
1114
+ lambda {
1115
+ @worksheet.insert_cell(0,0,'test',nil,:up)
1116
+ }.should raise_error
1117
+ end
1118
+
1119
+ it 'should cause error if a negative argument is passed in' do
1120
+ lambda {
1121
+ @worksheet.insert_cell(-1,-1)
1122
+ }.should raise_error
1123
+ end
1124
+ end
1125
+
1126
+ describe '.delete_cell' do
1127
+ it 'should make a cell nil if no shift argument specified' do
1128
+ deleted = @worksheet.delete_cell(0,0)
1129
+ @worksheet[0][0].should be_nil
1130
+ @old_cell.inspect.should == deleted.inspect
1131
+ end
1132
+
1133
+ it 'should return nil if a cell which is out of range is specified' do
1134
+ @worksheet.delete_cell(12,12).should be_nil
1135
+ end
1136
+
1137
+ it 'should cause error if a negative argument is passed in' do
1138
+ lambda {
1139
+ @worksheet.delete_cell(-1,-1)
1140
+ }.should raise_error
1141
+ end
1142
+
1143
+ it 'should shift cells to the right of the deleted cell left if :left is specified' do
1144
+ @worksheet.delete_cell(0,0,:left)
1145
+ @worksheet[0][0].value.should == '0:1'
1146
+ end
1147
+
1148
+ it 'should shift cells below the deleted cell up if :up is specified' do
1149
+ @worksheet.delete_cell(0,0,:up)
1150
+ @worksheet[0][0].value.should == '1:0'
1151
+ end
1152
+
1153
+ it 'should cause en error if an argument other than :left, :up, or nil is specified for shift' do
1154
+ lambda {
1155
+ @worksheet.delete_cell(0,0,:down)
1156
+ }.should raise_error
1157
+ end
1158
+ end
1159
+
1160
+ describe '.get_row_fill' do
1161
+ it 'should return white (ffffff) if no fill color specified for row' do
1162
+ @worksheet.get_row_fill(0).should == 'ffffff'
1163
+ end
1164
+
1165
+ it 'should correctly reflect fill color if specified for row' do
1166
+ @worksheet.change_row_fill(0, '000000')
1167
+ @worksheet.get_row_fill(0).should == '000000'
1168
+ end
1169
+
1170
+ it 'should return nil if a row which does not exist is passed in' do
1171
+ @worksheet.get_row_fill(11).should be_nil
1172
+ end
1173
+
1174
+ it 'should cause error if a negative argument is passed in' do
1175
+ lambda {
1176
+ @worksheet.get_row_fill(-1)
1177
+ }.should raise_error
1178
+ end
1179
+ end
1180
+
1181
+ describe '.get_row_font_name' do
1182
+ it 'should correctly reflect font name for row' do
1183
+ @worksheet.change_row_font_name(0,'Courier')
1184
+ @worksheet.get_row_font_name(0).should == 'Courier'
1185
+ end
1186
+
1187
+ it 'should cause error if a negative argument is passed in' do
1188
+ lambda {
1189
+ @worksheet.get_row_font_name(-1)
1190
+ }.should raise_error
1191
+ end
1192
+
1193
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1194
+ @worksheet.get_row_font_name(11).should be_nil
1195
+ end
1196
+ end
1197
+
1198
+ describe '.get_row_font_size' do
1199
+ it 'should correctly reflect font size for row' do
1200
+ @worksheet.change_row_font_size(0,30)
1201
+ @worksheet.get_row_font_size(0).should == 30
1202
+ end
1203
+
1204
+ it 'should cause error if a negative argument is passed in' do
1205
+ lambda {
1206
+ @worksheet.get_row_font_size(-1)
1207
+ }.should raise_error
1208
+ end
1209
+
1210
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1211
+ @worksheet.get_row_font_size(11).should be_nil
1212
+ end
1213
+ end
1214
+
1215
+ describe '.get_row_font_color' do
1216
+ it 'should correctly reflect font color for row' do
1217
+ @worksheet.change_row_font_color(0,'0f0f0f')
1218
+ @worksheet.get_row_font_color(0).should == '0f0f0f'
1219
+ end
1220
+
1221
+ it 'should cause error if a negative argument is passed in' do
1222
+ lambda {
1223
+ @worksheet.get_row_font_color(-1)
1224
+ }.should raise_error
1225
+ end
1226
+
1227
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1228
+ @worksheet.get_row_font_color(11).should be_nil
1229
+ end
1230
+ end
1231
+
1232
+ describe '.is_row_italicized' do
1233
+ it 'should correctly return whether row is italicized' do
1234
+ @worksheet.change_row_italics(0,true)
1235
+ @worksheet.is_row_italicized(0).should == true
1236
+ end
1237
+
1238
+ it 'should cause error if a negative argument is passed in' do
1239
+ lambda {
1240
+ @worksheet.is_row_italicized(-1)
1241
+ }.should raise_error
1242
+ end
1243
+
1244
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1245
+ @worksheet.is_row_italicized(11).should be_nil
1246
+ end
1247
+ end
1248
+
1249
+ describe '.is_row_bolded' do
1250
+ it 'should correctly return whether row is bolded' do
1251
+ @worksheet.change_row_bold(0,true)
1252
+ @worksheet.is_row_bolded(0).should == true
1253
+ end
1254
+
1255
+ it 'should cause error if a negative argument is passed in' do
1256
+ lambda {
1257
+ @worksheet.is_row_bolded(-1)
1258
+ }.should raise_error
1259
+ end
1260
+
1261
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1262
+ @worksheet.is_row_bolded(11).should be_nil
1263
+ end
1264
+ end
1265
+
1266
+ describe '.is_row_underlined' do
1267
+ it 'should correctly return whether row is underlined' do
1268
+ @worksheet.change_row_underline(0,true)
1269
+ @worksheet.is_row_underlined(0).should == true
1270
+ end
1271
+
1272
+ it 'should cause error if a negative argument is passed in' do
1273
+ lambda {
1274
+ @worksheet.is_row_underlined(-1)
1275
+ }.should raise_error
1276
+ end
1277
+
1278
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1279
+ @worksheet.is_row_underlined(11).should be_nil
1280
+ end
1281
+ end
1282
+
1283
+ describe '.is_row_struckthrough' do
1284
+ it 'should correctly return whether row is struckthrough' do
1285
+ @worksheet.change_row_strikethrough(0,true)
1286
+ @worksheet.is_row_struckthrough(0).should == true
1287
+ end
1288
+
1289
+ it 'should cause error if a negative argument is passed in' do
1290
+ lambda {
1291
+ @worksheet.is_row_struckthrough(-1)
1292
+ }.should raise_error
1293
+ end
1294
+
1295
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1296
+ @worksheet.is_row_struckthrough(11).should be_nil
1297
+ end
1298
+ end
1299
+
1300
+ describe '.get_row_height' do
1301
+ it 'should return 13 if no height specified for row' do
1302
+ @worksheet.get_row_height(0).should == 13
1303
+ end
1304
+
1305
+ it 'should correctly reflect height if specified for row' do
1306
+ @worksheet.change_row_height(0, 30)
1307
+ @worksheet.get_row_height(0).should == 30
1308
+ end
1309
+
1310
+ it 'should return nil if a row which does not exist is passed in' do
1311
+ @worksheet.get_row_height(11).should be_nil
1312
+ end
1313
+
1314
+ it 'should cause error if a negative argument is passed in' do
1315
+ lambda {
1316
+ @worksheet.get_row_height(-1)
1317
+ }.should raise_error
1318
+ end
1319
+ end
1320
+
1321
+ describe '.get_row_horizontal_alignment' do
1322
+ it 'should return nil if no alignment specified for row' do
1323
+ @worksheet.get_row_horizontal_alignment(0).should be_nil
1324
+ end
1325
+
1326
+ it 'should return nil if a row which does not exist is passed in' do
1327
+ @worksheet.get_row_horizontal_alignment(11).should be_nil
1328
+ end
1329
+
1330
+ it 'should cause error if a negative argument is passed in' do
1331
+ lambda {
1332
+ @worksheet.get_row_horizontal_alignment(-1)
1333
+ }.should raise_error
1334
+ end
1335
+
1336
+ it 'should return correct horizontal alignment if it is set for that row' do
1337
+ @worksheet.change_row_horizontal_alignment(0, 'center')
1338
+ @worksheet.get_row_horizontal_alignment(0).should == 'center'
1339
+ end
1340
+ end
1341
+
1342
+ describe '.get_row_vertical_alignment' do
1343
+ it 'should return nil if no alignment specified for row' do
1344
+ @worksheet.get_row_vertical_alignment(0).should be_nil
1345
+ end
1346
+
1347
+ it 'should return nil if a row which does not exist is passed in' do
1348
+ @worksheet.get_row_vertical_alignment(11).should be_nil
1349
+ end
1350
+
1351
+ it 'should cause error if a negative argument is passed in' do
1352
+ lambda {
1353
+ @worksheet.get_row_vertical_alignment(-1)
1354
+ }.should raise_error
1355
+ end
1356
+
1357
+ it 'should return correct vertical alignment if it is set for that row' do
1358
+ @worksheet.change_row_vertical_alignment(0, 'center')
1359
+ @worksheet.get_row_vertical_alignment(0).should == 'center'
1360
+ end
1361
+ end
1362
+
1363
+ describe '.get_row_border_top' do
1364
+ it 'should return nil if no border is specified for that row in that direction' do
1365
+ @worksheet.get_row_border_top(0).should be_nil
1366
+ end
1367
+
1368
+ it 'should return type of border that this row has on top' do
1369
+ @worksheet.change_row_border_top(0,'thin')
1370
+ @worksheet.get_row_border_top(0).should == 'thin'
1371
+ end
1372
+
1373
+ it 'should cause error if a negative argument is passed in' do
1374
+ lambda {
1375
+ @worksheet.get_row_border_top(-1)
1376
+ }.should raise_error
1377
+ end
1378
+
1379
+ it 'should return nil if a row which does not exist is passed in' do
1380
+ @worksheet.get_row_border_top(11).should be_nil
1381
+ end
1382
+ end
1383
+
1384
+ describe '.get_row_border_left' do
1385
+ it 'should return nil if no border is specified for that row in that direction' do
1386
+ @worksheet.get_row_border_left(0).should be_nil
1387
+ end
1388
+
1389
+ it 'should return type of border that this row has on left' do
1390
+ @worksheet.change_row_border_left(0,'thin')
1391
+ @worksheet.get_row_border_left(0).should == 'thin'
1392
+ end
1393
+
1394
+ it 'should cause error if a negative argument is passed in' do
1395
+ lambda {
1396
+ @worksheet.get_row_border_left(-1)
1397
+ }.should raise_error
1398
+ end
1399
+
1400
+ it 'should return nil if a row which does not exist is passed in' do
1401
+ @worksheet.get_row_border_left(11).should be_nil
1402
+ end
1403
+ end
1404
+
1405
+ describe '.get_row_border_right' do
1406
+ it 'should return nil if no border is specified for that row in that direction' do
1407
+ @worksheet.get_row_border_right(0).should be_nil
1408
+ end
1409
+
1410
+ it 'should return type of border that this row has on right' do
1411
+ @worksheet.change_row_border_right(0,'thin')
1412
+ @worksheet.get_row_border_right(0).should == 'thin'
1413
+ end
1414
+
1415
+ it 'should cause error if a negative argument is passed in' do
1416
+ lambda {
1417
+ @worksheet.get_row_border_right(-1)
1418
+ }.should raise_error
1419
+ end
1420
+
1421
+ it 'should return nil if a row which does not exist is passed in' do
1422
+ @worksheet.get_row_border_right(11).should be_nil
1423
+ end
1424
+ end
1425
+
1426
+
1427
+ describe '.get_row_border_bottom' do
1428
+ it 'should return nil if no border is specified for that row in that direction' do
1429
+ @worksheet.get_row_border_bottom(0).should be_nil
1430
+ end
1431
+
1432
+ it 'should return type of border that this row has on bottom' do
1433
+ @worksheet.change_row_border_bottom(0,'thin')
1434
+ @worksheet.get_row_border_bottom(0).should == 'thin'
1435
+ end
1436
+
1437
+ it 'should cause error if a negative argument is passed in' do
1438
+ lambda {
1439
+ @worksheet.get_row_border_bottom(-1)
1440
+ }.should raise_error
1441
+ end
1442
+
1443
+ it 'should return nil if a row which does not exist is passed in' do
1444
+ @worksheet.get_row_border_bottom(11).should be_nil
1445
+ end
1446
+ end
1447
+
1448
+ describe '.get_row_border_diagonal' do
1449
+ it 'should return nil if no border is specified for that row in that direction' do
1450
+ @worksheet.get_row_border_diagonal(0).should be_nil
1451
+ end
1452
+
1453
+ it 'should return type of border that this row has on diagonal' do
1454
+ @worksheet.change_row_border_diagonal(0,'thin')
1455
+ @worksheet.get_row_border_diagonal(0).should == 'thin'
1456
+ end
1457
+
1458
+ it 'should cause error if a negative argument is passed in' do
1459
+ lambda {
1460
+ @worksheet.get_row_border_diagonal(-1)
1461
+ }.should raise_error
1462
+ end
1463
+
1464
+ it 'should return nil if a row which does not exist is passed in' do
1465
+ @worksheet.get_row_border_diagonal(11).should be_nil
1466
+ end
1467
+ end
1468
+
1469
+ describe '.get_column_font_name' do
1470
+ it 'should correctly reflect font name for column' do
1471
+ @worksheet.change_column_font_name(0,'Courier')
1472
+ @worksheet.get_column_font_name(0).should == 'Courier'
1473
+ end
1474
+
1475
+ it 'should cause error if a negative argument is passed in' do
1476
+ lambda {
1477
+ @worksheet.get_column_font_name(-1)
1478
+ }.should raise_error
1479
+ end
1480
+
1481
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1482
+ @worksheet.get_column_font_name(11).should be_nil
1483
+ end
1484
+ end
1485
+
1486
+ describe '.get_column_font_size' do
1487
+ it 'should correctly reflect font size for column' do
1488
+ @worksheet.change_column_font_size(0,30)
1489
+ @worksheet.get_column_font_size(0).should == 30
1490
+ end
1491
+
1492
+ it 'should cause error if a negative argument is passed in' do
1493
+ lambda {
1494
+ @worksheet.get_column_font_size(-1)
1495
+ }.should raise_error
1496
+ end
1497
+
1498
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1499
+ @worksheet.get_column_font_size(11).should be_nil
1500
+ end
1501
+ end
1502
+
1503
+ describe '.get_column_font_color' do
1504
+ it 'should correctly reflect font color for column' do
1505
+ @worksheet.change_column_font_color(0,'0f0f0f')
1506
+ @worksheet.get_column_font_color(0).should == '0f0f0f'
1507
+ end
1508
+
1509
+ it 'should cause error if a negative argument is passed in' do
1510
+ lambda {
1511
+ @worksheet.get_column_font_color(-1)
1512
+ }.should raise_error
1513
+ end
1514
+
1515
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1516
+ @worksheet.get_column_font_color(11).should be_nil
1517
+ end
1518
+
1519
+ it 'should return black (000000) if no rgb font color is specified' do
1520
+ @worksheet.get_column_font_color(0).should == '000000'
1521
+ end
1522
+ end
1523
+
1524
+ describe '.is_column_italicized' do
1525
+ it 'should correctly return whether column is italicized' do
1526
+ @worksheet.change_column_italics(0,true)
1527
+ @worksheet.is_column_italicized(0).should == true
1528
+ end
1529
+
1530
+ it 'should cause error if a negative argument is passed in' do
1531
+ lambda {
1532
+ @worksheet.is_column_italicized(-1)
1533
+ }.should raise_error
1534
+ end
1535
+
1536
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1537
+ @worksheet.is_column_italicized(11).should be_nil
1538
+ end
1539
+ end
1540
+
1541
+ describe '.is_column_bolded' do
1542
+ it 'should correctly return whether column is bolded' do
1543
+ @worksheet.change_column_bold(0,true)
1544
+ @worksheet.is_column_bolded(0).should == true
1545
+ end
1546
+
1547
+ it 'should cause error if a negative argument is passed in' do
1548
+ lambda {
1549
+ @worksheet.is_column_bolded(-1)
1550
+ }.should raise_error
1551
+ end
1552
+
1553
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1554
+ @worksheet.is_column_bolded(11).should be_nil
1555
+ end
1556
+ end
1557
+
1558
+ describe '.is_column_underlined' do
1559
+ it 'should correctly return whether column is underlined' do
1560
+ @worksheet.change_column_underline(0,true)
1561
+ @worksheet.is_column_underlined(0).should == true
1562
+ end
1563
+
1564
+ it 'should cause error if a negative argument is passed in' do
1565
+ lambda {
1566
+ @worksheet.is_column_underlined(-1)
1567
+ }.should raise_error
1568
+ end
1569
+
1570
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1571
+ @worksheet.is_column_underlined(11).should be_nil
1572
+ end
1573
+ end
1574
+
1575
+ describe '.is_column_struckthrough' do
1576
+ it 'should correctly return whether column is struckthrough' do
1577
+ @worksheet.change_column_strikethrough(0,true)
1578
+ @worksheet.is_column_struckthrough(0).should == true
1579
+ end
1580
+
1581
+ it 'should cause error if a negative argument is passed in' do
1582
+ lambda {
1583
+ @worksheet.is_column_struckthrough(-1)
1584
+ }.should raise_error
1585
+ end
1586
+
1587
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1588
+ @worksheet.is_column_struckthrough(11).should be_nil
1589
+ end
1590
+ end
1591
+
1592
+ describe '.get_column_width' do
1593
+ it 'should return 10 (base column width) if no width specified for column' do
1594
+ @worksheet.get_column_width(0).should == 10
1595
+ end
1596
+
1597
+ it 'should correctly reflect width if specified for column' do
1598
+ @worksheet.change_column_width(0, 30)
1599
+ @worksheet.get_column_width(0).should == 30
1600
+ end
1601
+
1602
+ it 'should return nil if a column which does not exist is passed in' do
1603
+ @worksheet.get_column_width(11).should be_nil
1604
+ end
1605
+
1606
+ it 'should cause error if a negative argument is passed in' do
1607
+ lambda {
1608
+ @worksheet.get_column_width(-1)
1609
+ }.should raise_error
1610
+ end
1611
+ end
1612
+
1613
+ describe '.get_column_fill' do
1614
+ it 'should return white (ffffff) if no fill color specified for column' do
1615
+ @worksheet.get_column_fill(0).should == 'ffffff'
1616
+ end
1617
+
1618
+ it 'should correctly reflect fill color if specified for column' do
1619
+ @worksheet.change_column_fill(0, '000000')
1620
+ @worksheet.get_column_fill(0).should == '000000'
1621
+ end
1622
+
1623
+ it 'should return nil if a column which does not exist is passed in' do
1624
+ @worksheet.get_column_fill(11).should be_nil
1625
+ end
1626
+
1627
+ it 'should cause error if a negative argument is passed in' do
1628
+ lambda {
1629
+ @worksheet.get_column_fill(-1)
1630
+ }.should raise_error
1631
+ end
1632
+ end
1633
+
1634
+ describe '.get_column_horizontal_alignment' do
1635
+ it 'should return nil if no alignment specified for column' do
1636
+ @worksheet.get_column_horizontal_alignment(0).should be_nil
1637
+ end
1638
+
1639
+ it 'should return nil if a column which does not exist is passed in' do
1640
+ @worksheet.get_column_horizontal_alignment(11).should be_nil
1641
+ end
1642
+
1643
+ it 'should cause error if a negative argument is passed in' do
1644
+ lambda {
1645
+ @worksheet.get_column_horizontal_alignment(-1)
1646
+ }.should raise_error
1647
+ end
1648
+
1649
+ it 'should return correct horizontal alignment if it is set for that column' do
1650
+ @worksheet.change_column_horizontal_alignment(0, 'center')
1651
+ @worksheet.get_column_horizontal_alignment(0).should == 'center'
1652
+ end
1653
+ end
1654
+
1655
+ describe '.get_column_vertical_alignment' do
1656
+ it 'should return nil if no alignment specified for column' do
1657
+ @worksheet.get_column_vertical_alignment(0).should be_nil
1658
+ end
1659
+
1660
+ it 'should return nil if a column which does not exist is passed in' do
1661
+ @worksheet.get_column_vertical_alignment(11).should be_nil
1662
+ end
1663
+
1664
+ it 'should cause error if a negative argument is passed in' do
1665
+ lambda {
1666
+ @worksheet.get_column_vertical_alignment(-1)
1667
+ }.should raise_error
1668
+ end
1669
+
1670
+ it 'should return correct vertical alignment if it is set for that column' do
1671
+ @worksheet.change_column_vertical_alignment(0, 'center')
1672
+ @worksheet.get_column_vertical_alignment(0).should == 'center'
1673
+ end
1674
+ end
1675
+
1676
+ describe '.get_column_border_top' do
1677
+ it 'should return nil if no border is specified for that column in that direction' do
1678
+ @worksheet.get_column_border_top(0).should be_nil
1679
+ end
1680
+
1681
+ it 'should return type of border that this column has on top' do
1682
+ @worksheet.change_column_border_top(0,'thin')
1683
+ @worksheet.get_column_border_top(0).should == 'thin'
1684
+ end
1685
+
1686
+ it 'should cause error if a negative argument is passed in' do
1687
+ lambda {
1688
+ @worksheet.get_column_border_top(-1)
1689
+ }.should raise_error
1690
+ end
1691
+
1692
+ it 'should return nil if a column which does not exist is passed in' do
1693
+ @worksheet.get_column_border_top(11).should be_nil
1694
+ end
1695
+ end
1696
+
1697
+ describe '.get_column_border_left' do
1698
+ it 'should return nil if no border is specified for that column in that direction' do
1699
+ @worksheet.get_column_border_left(0).should be_nil
1700
+ end
1701
+
1702
+ it 'should return type of border that this column has on left' do
1703
+ @worksheet.change_column_border_left(0,'thin')
1704
+ @worksheet.get_column_border_left(0).should == 'thin'
1705
+ end
1706
+
1707
+ it 'should cause error if a negative argument is passed in' do
1708
+ lambda {
1709
+ @worksheet.get_column_border_left(-1)
1710
+ }.should raise_error
1711
+ end
1712
+
1713
+ it 'should return nil if a column which does not exist is passed in' do
1714
+ @worksheet.get_column_border_left(11).should be_nil
1715
+ end
1716
+ end
1717
+
1718
+ describe '.get_column_border_right' do
1719
+ it 'should return nil if no border is specified for that column in that direction' do
1720
+ @worksheet.get_column_border_right(0).should be_nil
1721
+ end
1722
+
1723
+ it 'should return type of border that this column has on right' do
1724
+ @worksheet.change_column_border_right(0,'thin')
1725
+ @worksheet.get_column_border_right(0).should == 'thin'
1726
+ end
1727
+
1728
+ it 'should cause error if a negative argument is passed in' do
1729
+ lambda {
1730
+ @worksheet.get_column_border_right(-1)
1731
+ }.should raise_error
1732
+ end
1733
+
1734
+ it 'should return nil if a column which does not exist is passed in' do
1735
+ @worksheet.get_column_border_right(11).should be_nil
1736
+ end
1737
+ end
1738
+
1739
+
1740
+ describe '.get_column_border_bottom' do
1741
+ it 'should return nil if no border is specified for that column in that direction' do
1742
+ @worksheet.get_column_border_bottom(0).should be_nil
1743
+ end
1744
+
1745
+ it 'should return type of border that this column has on bottom' do
1746
+ @worksheet.change_column_border_bottom(0,'thin')
1747
+ @worksheet.get_column_border_bottom(0).should == 'thin'
1748
+ end
1749
+
1750
+ it 'should cause error if a negative argument is passed in' do
1751
+ lambda {
1752
+ @worksheet.get_column_border_bottom(-1)
1753
+ }.should raise_error
1754
+ end
1755
+
1756
+ it 'should return nil if a column which does not exist is passed in' do
1757
+ @worksheet.get_column_border_bottom(11).should be_nil
1758
+ end
1759
+ end
1760
+
1761
+ describe '.get_column_border_diagonal' do
1762
+ it 'should return nil if no border is specified for that column in that direction' do
1763
+ @worksheet.get_column_border_diagonal(0).should be_nil
1764
+ end
1765
+
1766
+ it 'should return type of border that this column has on diagonal' do
1767
+ @worksheet.change_column_border_diagonal(0,'thin')
1768
+ @worksheet.get_column_border_diagonal(0).should == 'thin'
1769
+ end
1770
+
1771
+ it 'should cause error if a negative argument is passed in' do
1772
+ lambda {
1773
+ @worksheet.get_column_border_diagonal(-1)
1774
+ }.should raise_error
1775
+ end
1776
+
1777
+ it 'should return nil if a column which does not exist is passed in' do
1778
+ @worksheet.get_column_border_diagonal(11).should be_nil
1779
+ end
1780
+ end
1781
+
1782
+ end