rubyXL 1.2.10 → 2.1.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.
Files changed (101) hide show
  1. data/Gemfile +14 -10
  2. data/Gemfile.lock +80 -21
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +88 -82
  5. data/Rakefile +7 -2
  6. data/VERSION +1 -1
  7. data/lib/rubyXL.rb +13 -7
  8. data/lib/rubyXL/cell.rb +108 -268
  9. data/lib/rubyXL/generic_storage.rb +40 -0
  10. data/lib/rubyXL/objects/border.rb +66 -0
  11. data/lib/rubyXL/objects/calculation_chain.rb +28 -0
  12. data/lib/rubyXL/objects/cell_style.rb +75 -0
  13. data/lib/rubyXL/objects/color.rb +25 -0
  14. data/lib/rubyXL/objects/column_range.rb +74 -0
  15. data/lib/rubyXL/objects/container_nodes.rb +122 -0
  16. data/lib/rubyXL/objects/data_validation.rb +43 -0
  17. data/lib/rubyXL/objects/document_properties.rb +76 -0
  18. data/lib/rubyXL/objects/extensions.rb +36 -0
  19. data/lib/rubyXL/objects/fill.rb +57 -0
  20. data/lib/rubyXL/objects/font.rb +111 -0
  21. data/lib/rubyXL/objects/formula.rb +24 -0
  22. data/lib/rubyXL/objects/ooxml_object.rb +295 -0
  23. data/lib/rubyXL/objects/reference.rb +110 -0
  24. data/lib/rubyXL/objects/relationships.rb +59 -0
  25. data/lib/rubyXL/objects/shared_strings.rb +57 -0
  26. data/lib/rubyXL/objects/sheet_data.rb +149 -0
  27. data/lib/rubyXL/objects/sheet_view.rb +71 -0
  28. data/lib/rubyXL/objects/stylesheet.rb +200 -0
  29. data/lib/rubyXL/objects/text.rb +87 -0
  30. data/lib/rubyXL/objects/theme.rb +64 -0
  31. data/lib/rubyXL/objects/workbook.rb +233 -0
  32. data/lib/rubyXL/objects/worksheet.rb +485 -0
  33. data/lib/rubyXL/parser.rb +78 -442
  34. data/lib/rubyXL/workbook.rb +216 -385
  35. data/lib/rubyXL/worksheet.rb +509 -1062
  36. data/lib/rubyXL/writer/content_types_writer.rb +104 -68
  37. data/lib/rubyXL/writer/core_writer.rb +26 -43
  38. data/lib/rubyXL/writer/generic_writer.rb +43 -0
  39. data/lib/rubyXL/writer/root_rels_writer.rb +11 -19
  40. data/lib/rubyXL/writer/styles_writer.rb +6 -398
  41. data/lib/rubyXL/writer/theme_writer.rb +321 -327
  42. data/lib/rubyXL/writer/workbook_writer.rb +63 -67
  43. data/lib/rubyXL/writer/worksheet_writer.rb +29 -218
  44. data/rdoc/created.rid +39 -0
  45. data/rdoc/fonts.css +167 -0
  46. data/rdoc/fonts/Lato-Light.ttf +0 -0
  47. data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
  48. data/rdoc/fonts/Lato-Regular.ttf +0 -0
  49. data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
  50. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  51. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  52. data/rdoc/images/add.png +0 -0
  53. data/rdoc/images/arrow_up.png +0 -0
  54. data/rdoc/images/brick.png +0 -0
  55. data/rdoc/images/brick_link.png +0 -0
  56. data/rdoc/images/bug.png +0 -0
  57. data/rdoc/images/bullet_black.png +0 -0
  58. data/rdoc/images/bullet_toggle_minus.png +0 -0
  59. data/rdoc/images/bullet_toggle_plus.png +0 -0
  60. data/rdoc/images/date.png +0 -0
  61. data/rdoc/images/delete.png +0 -0
  62. data/rdoc/images/find.png +0 -0
  63. data/rdoc/images/loadingAnimation.gif +0 -0
  64. data/rdoc/images/macFFBgHack.png +0 -0
  65. data/rdoc/images/package.png +0 -0
  66. data/rdoc/images/page_green.png +0 -0
  67. data/rdoc/images/page_white_text.png +0 -0
  68. data/rdoc/images/page_white_width.png +0 -0
  69. data/rdoc/images/plugin.png +0 -0
  70. data/rdoc/images/ruby.png +0 -0
  71. data/rdoc/images/tag_blue.png +0 -0
  72. data/rdoc/images/tag_green.png +0 -0
  73. data/rdoc/images/transparent.png +0 -0
  74. data/rdoc/images/wrench.png +0 -0
  75. data/rdoc/images/wrench_orange.png +0 -0
  76. data/rdoc/images/zoom.png +0 -0
  77. data/rdoc/js/darkfish.js +140 -0
  78. data/rdoc/js/jquery.js +18 -0
  79. data/rdoc/js/navigation.js +142 -0
  80. data/rdoc/js/search.js +109 -0
  81. data/rdoc/js/search_index.js +1 -0
  82. data/rdoc/js/searcher.js +228 -0
  83. data/rdoc/rdoc.css +580 -0
  84. data/rubyXL.gemspec +90 -34
  85. data/spec/lib/cell_spec.rb +29 -59
  86. data/spec/lib/parser_spec.rb +35 -19
  87. data/spec/lib/reference_spec.rb +29 -0
  88. data/spec/lib/stylesheet_spec.rb +29 -0
  89. data/spec/lib/workbook_spec.rb +22 -17
  90. data/spec/lib/worksheet_spec.rb +47 -202
  91. metadata +185 -148
  92. data/lib/.DS_Store +0 -0
  93. data/lib/rubyXL/Hash.rb +0 -60
  94. data/lib/rubyXL/color.rb +0 -14
  95. data/lib/rubyXL/private_class.rb +0 -265
  96. data/lib/rubyXL/writer/app_writer.rb +0 -62
  97. data/lib/rubyXL/writer/calc_chain_writer.rb +0 -33
  98. data/lib/rubyXL/writer/shared_strings_writer.rb +0 -30
  99. data/lib/rubyXL/writer/workbook_rels_writer.rb +0 -59
  100. data/lib/rubyXL/zip.rb +0 -20
  101. data/spec/lib/hash_spec.rb +0 -28
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'rubyXL'
3
+
4
+ describe RubyXL::NumberFormat do
5
+
6
+ describe '.is_date_format?' do
7
+ it 'should return true if number format = dd// yy// mm' do
8
+ RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => 'dd// yy// mm').is_date_format?().should == true
9
+ end
10
+
11
+ it 'should return true if number format = DD// YY// MM (uppercase)' do
12
+ RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => 'DD// YY// MM').is_date_format?().should == true
13
+ end
14
+
15
+ it 'should return false if number format = @' do
16
+ RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => '@').is_date_format?().should == false
17
+ RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => 'general').is_date_format?().should == false
18
+ RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => '0.00e+00').is_date_format?().should == false
19
+ end
20
+
21
+ it 'should properly detect date formats amongst default ones' do
22
+ all_formats = RubyXL::NumberFormatContainer::DEFAULT_NUMBER_FORMATS.number_formats
23
+ id_list = all_formats.collect { |fmt| fmt.num_fmt_id if fmt.is_date_format? }.compact.sort
24
+ id_list.should == [14, 15, 16, 17, 18, 19, 20, 21, 22, 45, 46, 47]
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -4,48 +4,53 @@ require 'rubyXL'
4
4
  describe RubyXL::Workbook do
5
5
  before do
6
6
  @workbook = RubyXL::Workbook.new
7
- @worksheet = RubyXL::Worksheet.new(@workbook)
8
- @workbook.worksheets << @worksheet
7
+ @worksheet = @workbook.add_worksheet('Test Worksheet')
8
+
9
9
  (0..10).each do |i|
10
10
  (0..10).each do |j|
11
11
  @worksheet.add_cell(i, j, "#{i}:#{j}")
12
12
  end
13
13
  end
14
+
14
15
  @cell = @worksheet[0][0]
15
16
  end
16
17
 
17
- describe '.write' do
18
- #method not conducive to unit tests
18
+ describe '.new' do
19
+ it 'should automatically create a blank worksheet named "Sheet1"' do
20
+ @workbook[0].sheet_name.should == 'Sheet1'
21
+ end
19
22
  end
20
23
 
21
- describe '.get_style' do
22
- it 'should return the cell_xfs object based on the passed in style index (string or number)' do
23
- @workbook.get_style('0').should == @workbook.cell_xfs[:xf][0]
24
+ describe '[]' do
25
+ it 'should properly locate worksheet by index' do
26
+ @workbook[1].sheet_name.should == 'Test Worksheet'
24
27
  end
25
28
 
26
- it 'should return nil if index out of range or string is passed in' do
27
- @workbook.get_style('20000').should be_nil
29
+ it 'should properly locate worksheet by name' do
30
+ @workbook['Test Worksheet'].sheet_name.should == 'Test Worksheet'
28
31
  end
29
32
  end
30
33
 
31
- describe '.get_style_attributes' do
32
- it 'should return the attributes of the style object when passed the style object itself' do
33
- @workbook.get_style_attributes(@workbook.get_style(0)).should == @workbook.cell_xfs[:xf][0][:attributes]
34
+ describe '.add_worksheet' do
35
+ it 'when not given a name, it should automatically pick a name "SheetX" that is not taken yet' do
36
+ @workbook.add_worksheet
37
+ @workbook['Sheet2'].sheet_name.should == 'Sheet2'
34
38
  end
39
+ end
35
40
 
36
- it 'should cause an error if nil is passed' do
37
- lambda {@workbook.get_style_attributes(nil)}.should raise_error
38
- end
41
+ describe '.write' do
42
+ #method not conducive to unit tests
39
43
  end
40
44
 
41
45
  describe '.get_fill_color' do
42
46
  it 'should return the fill color of a particular style attribute' do
43
47
  @cell.change_fill('000000')
44
- @workbook.get_fill_color(@workbook.get_style_attributes(@workbook.get_style(@cell.style_index))).should == '000000'
48
+ @workbook.get_fill_color(@workbook.cell_xfs[@cell.style_index]).should == '000000'
45
49
  end
46
50
 
47
51
  it 'should return white (ffffff) if no fill color is specified in style' do
48
- @workbook.get_fill_color(@workbook.get_style_attributes(@workbook.get_style(@cell.style_index))).should == 'ffffff'
52
+ @workbook.get_fill_color(@workbook.cell_xfs[@cell.style_index]).should == 'ffffff'
49
53
  end
50
54
  end
55
+
51
56
  end
@@ -4,8 +4,8 @@ require 'rubyXL'
4
4
  describe RubyXL::Worksheet do
5
5
  before do
6
6
  @workbook = RubyXL::Workbook.new
7
- @worksheet = RubyXL::Worksheet.new(@workbook)
8
- @workbook.worksheets << @worksheet
7
+ @worksheet = @workbook.add_worksheet
8
+
9
9
  (0..10).each do |i|
10
10
  (0..10).each do |j|
11
11
  @worksheet.add_cell(i, j, "#{i}:#{j}")
@@ -47,7 +47,7 @@ describe RubyXL::Worksheet do
47
47
  end
48
48
 
49
49
  describe '.change_row_fill' do
50
- it 'should raise error if hex color code not passed' do
50
+ it 'should raise error if hex color code not passed' do
51
51
  lambda {
52
52
  @worksheet.change_row_fill(0, 'G')
53
53
  }.should raise_error
@@ -59,13 +59,13 @@ describe RubyXL::Worksheet do
59
59
  }.should raise_error
60
60
  end
61
61
 
62
- it 'should make row and cell fill colors equal hex color code passed' do
63
- @worksheet.change_row_fill(0, '111111')
62
+ it 'should make row and cell fill colors equal hex color code passed' do
63
+ @worksheet.change_row_fill(0, '111111')
64
64
  @worksheet.get_row_fill(0).should == '111111'
65
65
  @worksheet[0][5].fill_color.should == '111111'
66
- end
66
+ end
67
67
 
68
- it 'should cause error if a negative argument is passed in' do
68
+ it 'should cause error if a negative argument is passed in' do
69
69
  lambda {
70
70
  @worksheet.change_row_fill(-1,'111111')
71
71
  }.should raise_error
@@ -282,11 +282,6 @@ describe RubyXL::Worksheet do
282
282
  @worksheet[0][5].horizontal_alignment.should == 'center'
283
283
  end
284
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
285
 
291
286
  it 'should cause error if a negative argument is passed in' do
292
287
  lambda {
@@ -309,12 +304,6 @@ describe RubyXL::Worksheet do
309
304
  @worksheet[0][5].vertical_alignment.should == 'center'
310
305
  end
311
306
 
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
307
  it 'should cause error if a negative argument is passed in' do
319
308
  lambda {
320
309
  @worksheet.change_row_vertical_alignment(-1,'center')
@@ -336,12 +325,6 @@ describe RubyXL::Worksheet do
336
325
  @worksheet[0][5].border_top.should == 'thin'
337
326
  end
338
327
 
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
328
  it 'should cause error if a negative argument is passed in' do
346
329
  lambda {
347
330
  @worksheet.change_row_border_top(-1,'thin')
@@ -363,12 +346,6 @@ describe RubyXL::Worksheet do
363
346
  @worksheet[0][5].border_left.should == 'thin'
364
347
  end
365
348
 
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
349
  it 'should cause error if a negative argument is passed in' do
373
350
  lambda {
374
351
  @worksheet.change_row_border_left(-1,'thin')
@@ -390,12 +367,6 @@ describe RubyXL::Worksheet do
390
367
  @worksheet[0][5].border_right.should == 'thin'
391
368
  end
392
369
 
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
370
  it 'should cause error if a negative argument is passed in' do
400
371
  lambda {
401
372
  @worksheet.change_row_border_right(-1,'thin')
@@ -417,12 +388,6 @@ describe RubyXL::Worksheet do
417
388
  @worksheet[0][5].border_bottom.should == 'thin'
418
389
  end
419
390
 
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
391
  it 'should cause error if a negative argument is passed in' do
427
392
  lambda {
428
393
  @worksheet.change_row_border_bottom(-1,'thin')
@@ -444,12 +409,6 @@ describe RubyXL::Worksheet do
444
409
  @worksheet[0][5].border_diagonal.should == 'thin'
445
410
  end
446
411
 
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
412
  it 'should cause error if a negative argument is passed in' do
454
413
  lambda {
455
414
  @worksheet.change_row_border_diagonal(-1,'thin')
@@ -635,17 +594,6 @@ describe RubyXL::Worksheet do
635
594
  @worksheet.get_column_width(0).should == 30.0002
636
595
  end
637
596
 
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
597
  it 'should cause error if a negative argument is passed in' do
650
598
  lambda {
651
599
  @worksheet.change_column_width(-1,10)
@@ -700,12 +648,6 @@ describe RubyXL::Worksheet do
700
648
  @worksheet[5][0].horizontal_alignment.should == 'center'
701
649
  end
702
650
 
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
651
  it 'should cause error if a negative argument is passed in' do
710
652
  lambda {
711
653
  @worksheet.change_column_horizontal_alignment(-1,'center')
@@ -727,12 +669,6 @@ describe RubyXL::Worksheet do
727
669
  @worksheet[5][0].vertical_alignment.should == 'center'
728
670
  end
729
671
 
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
672
  it 'should cause error if a negative argument is passed in' do
737
673
  lambda {
738
674
  @worksheet.change_column_vertical_alignment(-1,'center')
@@ -754,12 +690,6 @@ describe RubyXL::Worksheet do
754
690
  @worksheet[5][0].border_top.should == 'thin'
755
691
  end
756
692
 
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
693
  it 'should cause error if a negative argument is passed in' do
764
694
  lambda {
765
695
  @worksheet.change_column_border_top(-1,'thin')
@@ -781,12 +711,6 @@ describe RubyXL::Worksheet do
781
711
  @worksheet[5][0].border_left.should == 'thin'
782
712
  end
783
713
 
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
714
  it 'should cause error if a negative argument is passed in' do
791
715
  lambda {
792
716
  @worksheet.change_column_border_left(-1,'thin')
@@ -808,12 +732,6 @@ describe RubyXL::Worksheet do
808
732
  @worksheet[5][0].border_right.should == 'thin'
809
733
  end
810
734
 
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
735
  it 'should cause error if a negative argument is passed in' do
818
736
  lambda {
819
737
  @worksheet.change_column_border_right(-1,'thin')
@@ -835,12 +753,6 @@ describe RubyXL::Worksheet do
835
753
  @worksheet[5][0].border_bottom.should == 'thin'
836
754
  end
837
755
 
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
756
  it 'should cause error if a negative argument is passed in' do
845
757
  lambda {
846
758
  @worksheet.change_column_border_bottom(-1,'thin')
@@ -862,12 +774,6 @@ describe RubyXL::Worksheet do
862
774
  @worksheet[5][0].border_diagonal.should == 'thin'
863
775
  end
864
776
 
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
777
  it 'should cause error if a negative argument is passed in' do
872
778
  lambda {
873
779
  @worksheet.change_column_border_diagonal(-1,'thin')
@@ -884,14 +790,8 @@ describe RubyXL::Worksheet do
884
790
 
885
791
  describe '.merge_cells' do
886
792
  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
793
+ @worksheet.merge_cells(0, 0, 1, 1)
794
+ @worksheet.merged_cells.collect{ |r| r.ref.to_s }.should == ["A1:B2"]
895
795
  end
896
796
  end
897
797
 
@@ -929,37 +829,6 @@ describe RubyXL::Worksheet do
929
829
  end
930
830
  end
931
831
 
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
832
  describe '.delete_row' do
964
833
  it 'should delete a row at index specified, "pushing" everything else "up"' do
965
834
  @worksheet.delete_row(0)
@@ -1064,7 +933,7 @@ describe RubyXL::Worksheet do
1064
933
  end
1065
934
 
1066
935
  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')
936
+ @worksheet.change_column_font_name(0, 'Courier')
1068
937
  @worksheet.insert_column(0)
1069
938
  @worksheet.get_column_font_name(0).should == 'Verdana' #not courier
1070
939
  end
@@ -1170,12 +1039,6 @@ describe RubyXL::Worksheet do
1170
1039
  it 'should return nil if a row which does not exist is passed in' do
1171
1040
  @worksheet.get_row_fill(11).should be_nil
1172
1041
  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
1042
  end
1180
1043
 
1181
1044
  describe '.get_row_font_name' do
@@ -1184,12 +1047,6 @@ describe RubyXL::Worksheet do
1184
1047
  @worksheet.get_row_font_name(0).should == 'Courier'
1185
1048
  end
1186
1049
 
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
1050
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1194
1051
  @worksheet.get_row_font_name(11).should be_nil
1195
1052
  end
@@ -1201,12 +1058,6 @@ describe RubyXL::Worksheet do
1201
1058
  @worksheet.get_row_font_size(0).should == 30
1202
1059
  end
1203
1060
 
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
1061
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1211
1062
  @worksheet.get_row_font_size(11).should be_nil
1212
1063
  end
@@ -1218,12 +1069,6 @@ describe RubyXL::Worksheet do
1218
1069
  @worksheet.get_row_font_color(0).should == '0f0f0f'
1219
1070
  end
1220
1071
 
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
1072
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1228
1073
  @worksheet.get_row_font_color(11).should be_nil
1229
1074
  end
@@ -1235,12 +1080,6 @@ describe RubyXL::Worksheet do
1235
1080
  @worksheet.is_row_italicized(0).should == true
1236
1081
  end
1237
1082
 
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
1083
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1245
1084
  @worksheet.is_row_italicized(11).should be_nil
1246
1085
  end
@@ -1252,12 +1091,6 @@ describe RubyXL::Worksheet do
1252
1091
  @worksheet.is_row_bolded(0).should == true
1253
1092
  end
1254
1093
 
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
1094
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1262
1095
  @worksheet.is_row_bolded(11).should be_nil
1263
1096
  end
@@ -1269,12 +1102,6 @@ describe RubyXL::Worksheet do
1269
1102
  @worksheet.is_row_underlined(0).should == true
1270
1103
  end
1271
1104
 
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
1105
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1279
1106
  @worksheet.is_row_underlined(11).should be_nil
1280
1107
  end
@@ -1286,12 +1113,6 @@ describe RubyXL::Worksheet do
1286
1113
  @worksheet.is_row_struckthrough(0).should == true
1287
1114
  end
1288
1115
 
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
1116
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1296
1117
  @worksheet.is_row_struckthrough(11).should be_nil
1297
1118
  end
@@ -1486,7 +1307,7 @@ describe RubyXL::Worksheet do
1486
1307
  describe '.get_column_font_size' do
1487
1308
  it 'should correctly reflect font size for column' do
1488
1309
  @worksheet.change_column_font_size(0,30)
1489
- @worksheet.get_column_font_size(0).should == 30
1310
+ @worksheet.get_column_font_size(0).should == 30
1490
1311
  end
1491
1312
 
1492
1313
  it 'should cause error if a negative argument is passed in' do
@@ -1503,7 +1324,7 @@ describe RubyXL::Worksheet do
1503
1324
  describe '.get_column_font_color' do
1504
1325
  it 'should correctly reflect font color for column' do
1505
1326
  @worksheet.change_column_font_color(0,'0f0f0f')
1506
- @worksheet.get_column_font_color(0).should == '0f0f0f'
1327
+ @worksheet.get_column_font_color(0).should == '0f0f0f'
1507
1328
  end
1508
1329
 
1509
1330
  it 'should cause error if a negative argument is passed in' do
@@ -1524,7 +1345,7 @@ describe RubyXL::Worksheet do
1524
1345
  describe '.is_column_italicized' do
1525
1346
  it 'should correctly return whether column is italicized' do
1526
1347
  @worksheet.change_column_italics(0,true)
1527
- @worksheet.is_column_italicized(0).should == true
1348
+ @worksheet.is_column_italicized(0).should == true
1528
1349
  end
1529
1350
 
1530
1351
  it 'should cause error if a negative argument is passed in' do
@@ -1541,7 +1362,7 @@ describe RubyXL::Worksheet do
1541
1362
  describe '.is_column_bolded' do
1542
1363
  it 'should correctly return whether column is bolded' do
1543
1364
  @worksheet.change_column_bold(0,true)
1544
- @worksheet.is_column_bolded(0).should == true
1365
+ @worksheet.is_column_bolded(0).should == true
1545
1366
  end
1546
1367
 
1547
1368
  it 'should cause error if a negative argument is passed in' do
@@ -1558,7 +1379,7 @@ describe RubyXL::Worksheet do
1558
1379
  describe '.is_column_underlined' do
1559
1380
  it 'should correctly return whether column is underlined' do
1560
1381
  @worksheet.change_column_underline(0,true)
1561
- @worksheet.is_column_underlined(0).should == true
1382
+ @worksheet.is_column_underlined(0).should == true
1562
1383
  end
1563
1384
 
1564
1385
  it 'should cause error if a negative argument is passed in' do
@@ -1575,7 +1396,7 @@ describe RubyXL::Worksheet do
1575
1396
  describe '.is_column_struckthrough' do
1576
1397
  it 'should correctly return whether column is struckthrough' do
1577
1398
  @worksheet.change_column_strikethrough(0,true)
1578
- @worksheet.is_column_struckthrough(0).should == true
1399
+ @worksheet.is_column_struckthrough(0).should == true
1579
1400
  end
1580
1401
 
1581
1402
  it 'should cause error if a negative argument is passed in' do
@@ -1617,7 +1438,7 @@ describe RubyXL::Worksheet do
1617
1438
 
1618
1439
  it 'should correctly reflect fill color if specified for column' do
1619
1440
  @worksheet.change_column_fill(0, '000000')
1620
- @worksheet.get_column_fill(0).should == '000000'
1441
+ @worksheet.get_column_fill(0).should == '000000'
1621
1442
  end
1622
1443
 
1623
1444
  it 'should return nil if a column which does not exist is passed in' do
@@ -1680,7 +1501,7 @@ describe RubyXL::Worksheet do
1680
1501
 
1681
1502
  it 'should return type of border that this column has on top' do
1682
1503
  @worksheet.change_column_border_top(0,'thin')
1683
- @worksheet.get_column_border_top(0).should == 'thin'
1504
+ @worksheet.get_column_border_top(0).should == 'thin'
1684
1505
  end
1685
1506
 
1686
1507
  it 'should cause error if a negative argument is passed in' do
@@ -1701,7 +1522,7 @@ describe RubyXL::Worksheet do
1701
1522
 
1702
1523
  it 'should return type of border that this column has on left' do
1703
1524
  @worksheet.change_column_border_left(0,'thin')
1704
- @worksheet.get_column_border_left(0).should == 'thin'
1525
+ @worksheet.get_column_border_left(0).should == 'thin'
1705
1526
  end
1706
1527
 
1707
1528
  it 'should cause error if a negative argument is passed in' do
@@ -1722,7 +1543,7 @@ describe RubyXL::Worksheet do
1722
1543
 
1723
1544
  it 'should return type of border that this column has on right' do
1724
1545
  @worksheet.change_column_border_right(0,'thin')
1725
- @worksheet.get_column_border_right(0).should == 'thin'
1546
+ @worksheet.get_column_border_right(0).should == 'thin'
1726
1547
  end
1727
1548
 
1728
1549
  it 'should cause error if a negative argument is passed in' do
@@ -1736,7 +1557,6 @@ describe RubyXL::Worksheet do
1736
1557
  end
1737
1558
  end
1738
1559
 
1739
-
1740
1560
  describe '.get_column_border_bottom' do
1741
1561
  it 'should return nil if no border is specified for that column in that direction' do
1742
1562
  @worksheet.get_column_border_bottom(0).should be_nil
@@ -1744,7 +1564,7 @@ describe RubyXL::Worksheet do
1744
1564
 
1745
1565
  it 'should return type of border that this column has on bottom' do
1746
1566
  @worksheet.change_column_border_bottom(0,'thin')
1747
- @worksheet.get_column_border_bottom(0).should == 'thin'
1567
+ @worksheet.get_column_border_bottom(0).should == 'thin'
1748
1568
  end
1749
1569
 
1750
1570
  it 'should cause error if a negative argument is passed in' do
@@ -1765,7 +1585,7 @@ describe RubyXL::Worksheet do
1765
1585
 
1766
1586
  it 'should return type of border that this column has on diagonal' do
1767
1587
  @worksheet.change_column_border_diagonal(0,'thin')
1768
- @worksheet.get_column_border_diagonal(0).should == 'thin'
1588
+ @worksheet.get_column_border_diagonal(0).should == 'thin'
1769
1589
  end
1770
1590
 
1771
1591
  it 'should cause error if a negative argument is passed in' do
@@ -1779,4 +1599,29 @@ describe RubyXL::Worksheet do
1779
1599
  end
1780
1600
  end
1781
1601
 
1602
+
1603
+ describe '@column_range' do
1604
+ it 'should properly handle range addition and modification' do
1605
+ # Ranges should be empty for brand new worskeet
1606
+ @worksheet.cols.column_ranges.size.should == 0
1607
+
1608
+ # Range should be created if the column has not been touched before
1609
+ @worksheet.change_column_width(0, 30)
1610
+ @worksheet.get_column_width(0).should == 30
1611
+ @worksheet.cols.column_ranges.size.should == 1
1612
+
1613
+ # Range should be reused if the column has not been touched before
1614
+ @worksheet.change_column_width(0, 20)
1615
+ @worksheet.get_column_width(0).should == 20
1616
+ @worksheet.cols.column_ranges.size.should == 1
1617
+
1618
+ # Creation of the new range should not affect previously changed columns
1619
+ @worksheet.change_column_width(1, 999)
1620
+ @worksheet.get_column_width(1).should == 999
1621
+ @worksheet.get_column_width(0).should == 20
1622
+ @worksheet.cols.column_ranges.size.should == 2
1623
+ end
1624
+
1625
+ end
1626
+
1782
1627
  end