robust_excel_ole 1.27 → 1.32

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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +36 -2
  3. data/README.rdoc +121 -19
  4. data/___dummy_workbook.xls +0 -0
  5. data/benchmarking/creek_example.rb +1 -1
  6. data/benchmarking/reo_example.rb +1 -1
  7. data/benchmarking/reo_example1.rb +1 -1
  8. data/benchmarking/reo_example2.rb +1 -1
  9. data/benchmarking/roo_example.rb +1 -1
  10. data/benchmarking/simple_xlsx_reader_example.rb +1 -1
  11. data/benchmarking/spreadsheet_example.rb +1 -1
  12. data/bin/jreo +19 -0
  13. data/bin/reo +19 -0
  14. data/docs/README_excel.rdoc +16 -24
  15. data/docs/README_listobjects.rdoc +176 -0
  16. data/docs/README_open.rdoc +20 -16
  17. data/docs/README_ranges.rdoc +72 -55
  18. data/docs/README_save_close.rdoc +3 -3
  19. data/docs/README_sheet.rdoc +19 -20
  20. data/examples/example_ruby_library.rb +2 -2
  21. data/examples/introductory_examples/example_open.rb +11 -0
  22. data/examples/introductory_examples/example_range.rb +2 -2
  23. data/examples/modifying_sheets/example_access_sheets_and_cells.rb +6 -6
  24. data/examples/modifying_sheets/example_add_names.rb +1 -1
  25. data/examples/modifying_sheets/example_concating.rb +1 -1
  26. data/examples/modifying_sheets/example_copying.rb +2 -2
  27. data/examples/modifying_sheets/example_listobjects.rb +86 -0
  28. data/examples/modifying_sheets/example_naming.rb +1 -1
  29. data/examples/modifying_sheets/example_ranges.rb +1 -1
  30. data/examples/open_save_close/example_control_to_excel.rb +1 -1
  31. data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
  32. data/examples/open_save_close/example_if_obstructed_save.rb +3 -3
  33. data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
  34. data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
  35. data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
  36. data/examples/open_save_close/example_read_only.rb +1 -1
  37. data/examples/open_save_close/example_simple.rb +1 -1
  38. data/examples/open_save_close/example_unobtrusively.rb +3 -3
  39. data/lib/robust_excel_ole.rb +19 -16
  40. data/lib/robust_excel_ole/address_tool.rb +54 -44
  41. data/lib/robust_excel_ole/base.rb +9 -6
  42. data/lib/robust_excel_ole/bookstore.rb +3 -17
  43. data/lib/robust_excel_ole/cell.rb +17 -22
  44. data/lib/robust_excel_ole/cygwin.rb +2 -0
  45. data/lib/robust_excel_ole/excel.rb +136 -201
  46. data/lib/robust_excel_ole/general.rb +249 -238
  47. data/lib/robust_excel_ole/list_object.rb +186 -210
  48. data/lib/robust_excel_ole/list_row.rb +155 -0
  49. data/lib/robust_excel_ole/range.rb +130 -94
  50. data/lib/robust_excel_ole/range_owners.rb +54 -135
  51. data/lib/robust_excel_ole/version.rb +1 -1
  52. data/lib/robust_excel_ole/workbook.rb +230 -196
  53. data/lib/robust_excel_ole/worksheet.rb +254 -133
  54. data/lib/spec_helper.rb +1 -1
  55. data/robust_excel_ole.gemspec +4 -3
  56. data/spec/address_tool_spec.rb +2 -2
  57. data/spec/base_spec.rb +19 -17
  58. data/spec/bookstore_spec.rb +3 -4
  59. data/spec/cell_spec.rb +10 -10
  60. data/spec/cygwin_spec.rb +1 -1
  61. data/spec/data/more_data/workbook.xls +0 -0
  62. data/spec/excel_spec.rb +133 -86
  63. data/spec/general_spec.rb +79 -18
  64. data/spec/list_object_spec.rb +259 -81
  65. data/spec/list_row_spec.rb +218 -0
  66. data/spec/range_spec.rb +75 -41
  67. data/spec/spec_helper.rb +16 -2
  68. data/spec/workbook_spec.rb +87 -46
  69. data/spec/workbook_specs/workbook_all_spec.rb +9 -28
  70. data/spec/workbook_specs/workbook_close_spec.rb +1 -1
  71. data/spec/workbook_specs/workbook_misc_spec.rb +52 -45
  72. data/spec/workbook_specs/workbook_open_spec.rb +103 -50
  73. data/spec/workbook_specs/workbook_save_spec.rb +22 -23
  74. data/spec/workbook_specs/workbook_sheet_spec.rb +4 -4
  75. data/spec/workbook_specs/workbook_subclass_spec.rb +1 -1
  76. data/spec/workbook_specs/workbook_unobtr_spec.rb +553 -395
  77. data/spec/worksheet_spec.rb +544 -308
  78. metadata +38 -3
  79. data/lib/reo_console.rb +0 -42
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), './../spec_helper')
3
+ require_relative '../spec_helper'
4
4
 
5
5
 
6
6
  $VERBOSE = nil
@@ -24,7 +24,6 @@ describe Workbook do
24
24
  @different_file = @dir + '/different_workbook.xls'
25
25
  @simple_file_other_path = @dir + '/more_data/workbook.xls'
26
26
  @another_simple_file = @dir + '/another_workbook.xls'
27
- @linked_file = @dir + '/workbook_linked.xlsm'
28
27
  @simple_file_xlsm = @dir + '/workbook.xlsm'
29
28
  @simple_file_xlsx = @dir + '/workbook.xlsx'
30
29
  @simple_file1 = @simple_file
@@ -43,6 +42,10 @@ describe Workbook do
43
42
  @simple_file_hostname_share_path_other_path1 = @simple_file_hostname_share_path_other_path
44
43
  @simple_file_xlsm1 = @simple_file_xlsm
45
44
  @simple_file_xlsx1 = @simple_file_xlsx
45
+ #@linked_file = @dir + '/workbook_linked.xlsm'
46
+ #@sub_file = @dir + '/workbook_sub.xlsm'
47
+ @main_file = @dir + '/workbook_linked3.xlsm'
48
+ @sub_file = @dir + '/workbook_linked_sub.xlsm'
46
49
  @error_message_excel = "provided Excel option value is neither an Excel object nor a valid option"
47
50
  end
48
51
 
@@ -51,6 +54,45 @@ describe Workbook do
51
54
  rm_tmp(@dir)
52
55
  end
53
56
 
57
+ describe "linked workbooks" do
58
+
59
+ context "standard" do
60
+
61
+ before do
62
+ @book1 = Workbook.open(@main_file)
63
+ end
64
+
65
+ it "should open the main workbook and the linked workbook" do
66
+ @book1.should be_alive
67
+ @book1.should be_a Workbook
68
+ @book1.filename.should == @main_file
69
+ Excel.current.workbooks.map{|b| b.filename}.should == [@main_file, @sub_file]
70
+ book2 = Workbook.open(@sub_file)
71
+ book2.should be_alive
72
+ book2.should be_a Workbook
73
+ book2.filename.should == @sub_file
74
+ end
75
+
76
+ it "should close the main workbook" do
77
+ @book1.close
78
+ Excel.current.workbooks.map{|b| b.filename}.should == [@sub_file]
79
+ end
80
+
81
+ it "should raise error when trying to close the linked workbook" do
82
+ book2 = Workbook.open(@sub_file)
83
+ expect{
84
+ book2.close
85
+ }.to raise_error(WorkbookLinked)
86
+ end
87
+
88
+ it "should raise error when trying to change the read-only mode of the linked workbook" do
89
+ expect{
90
+ book2 = Workbook.open(@sub_file, :read_only => true)
91
+ }.to raise_error(WorkbookLinked)
92
+ end
93
+ end
94
+ end
95
+
54
96
  describe "basic tests with xlsx-workbooks" do
55
97
 
56
98
  context "with simple file" do
@@ -96,7 +138,7 @@ describe Workbook do
96
138
  book.should be_alive
97
139
  book.should be_a Workbook
98
140
  book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
99
- Excel.excels_number.should == 1
141
+ Excel.instance_count.should == 1
100
142
  end
101
143
  end
102
144
  end
@@ -192,7 +234,7 @@ describe Workbook do
192
234
  book.should be_alive
193
235
  book.should be_a Workbook
194
236
  book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
195
- Excel.excels_number.should == 1
237
+ Excel.instance_count.should == 1
196
238
  end
197
239
  end
198
240
  end
@@ -273,6 +315,17 @@ describe Workbook do
273
315
  bookstore = Bookstore.new
274
316
  end
275
317
 
318
+ it "should fetch a network path file given a not via Reo opened hostname share file" do
319
+ ole_e1 = WIN32OLE.new('Excel.Application')
320
+ ws = ole_e1.Workbooks
321
+ abs_filename = General.absolute_path(@simple_file_hostname_share_path)
322
+ @ole_wb = ws.Open(abs_filename)
323
+ book2 = Workbook.open(@simple_file_network_path)
324
+ #book2.should === @ole_wb.to_reo
325
+ book2.Fullname.should == @ole_wb.Fullname
326
+ book2.excel.Workbooks.Count.should == 1
327
+ end
328
+
276
329
  it "should fetch a network path file given a hostname share file" do
277
330
  book1 = Workbook.open(@simple_file_hostname_share_path)
278
331
  book2 = Workbook.open(@simple_file_network_path)
@@ -398,7 +451,7 @@ describe Workbook do
398
451
  book.filename.should == @simple_file_network_path1
399
452
  book.Fullname.should == @ole_wb.Fullname
400
453
  book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
401
- Excel.excels_number.should == 1
454
+ Excel.instance_count.should == 1
402
455
  book.excel.Workbooks.Count.should == 1
403
456
  end
404
457
  end
@@ -414,7 +467,7 @@ describe Workbook do
414
467
  book.filename.should == @simple_file_hostname_share_path1.downcase
415
468
  book.Fullname.should == @ole_wb.Fullname
416
469
  book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
417
- Excel.excels_number.should == 1
470
+ Excel.instance_count.should == 1
418
471
  book.excel.Workbooks.Count.should == 1
419
472
  end
420
473
  end
@@ -470,7 +523,7 @@ describe Workbook do
470
523
  book.filename.should == @simple_file_network_path1
471
524
  book.Fullname.should == @ole_wb.Fullname
472
525
  book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
473
- Excel.excels_number.should == 1
526
+ Excel.instance_count.should == 1
474
527
  book.excel.Workbooks.Count.should == 1
475
528
  end
476
529
  end
@@ -486,7 +539,7 @@ describe Workbook do
486
539
  book.filename.should == @simple_file_hostname_share_path1.downcase
487
540
  book.Fullname.should == @ole_wb.Fullname
488
541
  book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
489
- Excel.excels_number.should == 1
542
+ Excel.instance_count.should == 1
490
543
  book.excel.Workbooks.Count.should == 1
491
544
  end
492
545
  end
@@ -584,11 +637,11 @@ describe Workbook do
584
637
 
585
638
  it "should connect to an unknown hostname share path workbook" do
586
639
  Workbook.open(@simple_file_hostname_share_path1) do |book|
587
- book.filename.should == @simple_file_hostname_share_path1.downcase
640
+ book.filename.should == @simple_file_network_path1
588
641
  book.should be_alive
589
642
  book.should be_a Workbook
590
643
  book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
591
- Excel.excels_number.should == 1
644
+ Excel.instance_count.should == 1
592
645
  book.excel.Workbooks.Count.should == 1
593
646
  end
594
647
  end
@@ -607,7 +660,7 @@ describe Workbook do
607
660
  book1 = Workbook.open(@simple_file1)
608
661
  book1.should be_alive
609
662
  book1.should be_a Workbook
610
- Excel.excels_number.should == 1
663
+ Excel.instance_count.should == 1
611
664
  book1.ReadOnly.should be false
612
665
  book1.excel.Visible.should be false
613
666
  book1.CheckCompatibility.should be true
@@ -626,7 +679,7 @@ describe Workbook do
626
679
  book1.should be_alive
627
680
  book1.should be_a Workbook
628
681
  book1.excel.should == excel1
629
- Excel.excels_number.should == 1
682
+ Excel.instance_count.should == 1
630
683
  book1.excel.Visible.should be false
631
684
  end
632
685
 
@@ -636,7 +689,7 @@ describe Workbook do
636
689
  book1.should be_alive
637
690
  book1.should be_a Workbook
638
691
  book1.excel.should == excel1
639
- Excel.excels_number.should == 1
692
+ Excel.instance_count.should == 1
640
693
  book1.excel.Visible.should be true
641
694
  end
642
695
 
@@ -646,7 +699,7 @@ describe Workbook do
646
699
  book1.should be_alive
647
700
  book1.should be_a Workbook
648
701
  book1.excel.should_not == excel1
649
- Excel.excels_number.should == 2
702
+ Excel.instance_count.should == 2
650
703
  end
651
704
 
652
705
  it "should set the options in a given known Excel" do
@@ -661,7 +714,7 @@ describe Workbook do
661
714
  book1 = Workbook.open(@simple_file1)
662
715
  book1.should be_alive
663
716
  book1.should be_a Workbook
664
- Excel.excels_number.should == 1
717
+ Excel.instance_count.should == 1
665
718
  book1.excel.ole_excel.Hwnd.should == ole_excel1.Hwnd
666
719
  end
667
720
 
@@ -682,7 +735,7 @@ describe Workbook do
682
735
  book.should be_alive
683
736
  book.should be_a Workbook
684
737
  book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
685
- Excel.excels_number.should == 1
738
+ Excel.instance_count.should == 1
686
739
  end
687
740
  end
688
741
 
@@ -762,7 +815,7 @@ describe Workbook do
762
815
  Workbook.open(@simple_file1) do |book|
763
816
  book.filename.should == @simple_file1
764
817
  book.excel.ole_excel.Hwnd.should == @ole_wb1.Application.Hwnd
765
- Excel.excels_number.should == 2
818
+ Excel.instance_count.should == 2
766
819
  end
767
820
  end
768
821
 
@@ -770,7 +823,7 @@ describe Workbook do
770
823
  Workbook.open(@different_file1) do |book|
771
824
  book.filename.should == @different_file1
772
825
  book.excel.ole_excel.Hwnd.should == @ole_wb2.Application.Hwnd
773
- Excel.excels_number.should == 2
826
+ Excel.instance_count.should == 2
774
827
  end
775
828
  end
776
829
 
@@ -859,9 +912,9 @@ describe Workbook do
859
912
  before do
860
913
  @book = Workbook.open(@simple_file1, :if_unsaved => :accept)
861
914
  sheet = @book.sheet(1)
862
- @old_value = sheet[1,1].Value
863
- sheet[1,1] = (sheet[1,1].Value == "foo" ? "bar" : "foo")
864
- @new_value = sheet[1,1].Value
915
+ @old_value = sheet[1,1]
916
+ sheet[1,1] = (sheet[1,1] == "foo" ? "bar" : "foo")
917
+ @new_value = sheet[1,1]
865
918
  @book.Saved.should be false
866
919
  end
867
920
 
@@ -875,7 +928,7 @@ describe Workbook do
875
928
  new_book.should be_alive
876
929
  new_book.Saved.should be false
877
930
  @book.Saved.should be false
878
- new_book.sheet(1)[1,1].Value.should == @new_value
931
+ new_book.sheet(1)[1,1].should == @new_value
879
932
  new_book.should == @book
880
933
  end
881
934
 
@@ -2546,7 +2599,7 @@ describe Workbook do
2546
2599
 
2547
2600
  it "should new_excel" do
2548
2601
  book = Workbook.open(@simple_file1)
2549
- book.sheet(1)[1,1].Value = "foo"
2602
+ book.sheet(1)[1,1] = "foo"
2550
2603
  book.Saved.should be false
2551
2604
  book2 = Workbook.open(@simple_file1, :if_unsaved => :new_excel)
2552
2605
  end
@@ -2614,24 +2667,24 @@ describe Workbook do
2614
2667
  @key_sender.puts "{right}{enter}"
2615
2668
  @key_sender.puts "{right}{enter}"
2616
2669
  @key_sender.puts "{right}{enter}"
2617
- expect{
2670
+ #expect{
2618
2671
  Workbook.open(@simple_file, :if_unsaved => :alert)
2619
- }.to raise_error(UnexpectedREOError)
2672
+ # }.to raise_error(UnexpectedREOError)
2620
2673
  @book.should be_alive
2674
+ @book.Saved.should be false
2621
2675
  end
2622
2676
 
2623
-
2624
-
2625
2677
  it "should not open the new book and not close the unsaved book, if user answers 'no'" do
2626
2678
  # "No" is right to "Yes" (the default). --> language independent
2627
2679
  # strangely, in the "no" case, the question will sometimes be repeated three time
2628
2680
  @key_sender.puts "{right}{enter}"
2629
2681
  @key_sender.puts "{right}{enter}"
2630
2682
  @key_sender.puts "{right}{enter}"
2631
- expect{
2683
+ #expect{
2632
2684
  Workbook.open(@simple_file, :if_unsaved => :excel)
2633
- }.to raise_error(UnexpectedREOError)
2685
+ #}.to raise_error(UnexpectedREOError)
2634
2686
  @book.should be_alive
2687
+ @book.Saved.should be false
2635
2688
  end
2636
2689
 
2637
2690
  end
@@ -2653,9 +2706,9 @@ describe Workbook do
2653
2706
  #@sheet_count = @book.ole_workbook.Worksheets.Count
2654
2707
  sheet = @book.sheet(1)
2655
2708
  #@book.add_sheet(@sheet, :as => 'a_name')
2656
- @old_value = sheet[1,1].Value
2657
- sheet[1,1] = (sheet[1,1].Value == "foo" ? "bar" : "foo")
2658
- @new_value = sheet[1,1].Value
2709
+ @old_value = sheet[1,1]
2710
+ sheet[1,1] = (sheet[1,1] == "foo" ? "bar" : "foo")
2711
+ @new_value = sheet[1,1]
2659
2712
  @book.Saved.should be false
2660
2713
  end
2661
2714
 
@@ -2676,7 +2729,7 @@ describe Workbook do
2676
2729
  new_book.should be_alive
2677
2730
  new_book.filename.downcase.should == @simple_file.downcase
2678
2731
  old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
2679
- old_book.sheet(1)[1,1].Value.should == @old_value
2732
+ old_book.sheet(1)[1,1].should == @old_value
2680
2733
  end
2681
2734
 
2682
2735
  it "should save the old book, close it, and open the new book, if :if_obstructed is :save" do
@@ -2685,7 +2738,7 @@ describe Workbook do
2685
2738
  new_book.should be_alive
2686
2739
  new_book.filename.downcase.should == @simple_file1.downcase
2687
2740
  old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
2688
- old_book.sheet(1)[1,1].Value.should == @new_value
2741
+ old_book.sheet(1)[1,1].should == @new_value
2689
2742
  #old_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
2690
2743
  old_book.close
2691
2744
  end
@@ -2701,7 +2754,7 @@ describe Workbook do
2701
2754
  new_book.should be_alive
2702
2755
  new_book.filename.downcase.should == @simple_file1.downcase
2703
2756
  old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
2704
- old_book.sheet(1)[1,1].Value.should == @new_value
2757
+ old_book.sheet(1)[1,1].should == @new_value
2705
2758
  #old_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
2706
2759
  old_book.close
2707
2760
  end
@@ -2716,11 +2769,11 @@ describe Workbook do
2716
2769
  new_book = Workbook.open(@simple_file1, :if_obstructed => :new_excel)
2717
2770
  @book.should be_alive
2718
2771
  @book.Saved.should be false
2719
- @book.sheet(1)[1,1].Value.should == @new_value
2772
+ @book.sheet(1)[1,1].should == @new_value
2720
2773
  new_book.should be_alive
2721
2774
  new_book.filename.should_not == @book.filename
2722
2775
  new_book.excel.should_not == @book.excel
2723
- new_book.sheet(1)[1,1].Value.should == @book.sheet(1)[1,1].Value
2776
+ new_book.sheet(1)[1,1].should == @book.sheet(1)[1,1]
2724
2777
  end
2725
2778
 
2726
2779
  it "should raise an error, if :if_obstructed is default" do
@@ -2866,8 +2919,8 @@ describe Workbook do
2866
2919
  book.ReadOnly.should be true
2867
2920
  book.should be_alive
2868
2921
  sheet = book.sheet(1)
2869
- old_cell_value = sheet[1,1].Value
2870
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2922
+ old_cell_value = sheet[1,1]
2923
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
2871
2924
  book.Saved.should be false
2872
2925
  expect{
2873
2926
  new_book = Workbook.open(@simple_file1, :read_only => false, :if_unsaved => :accept)
@@ -2879,8 +2932,8 @@ describe Workbook do
2879
2932
  book.ReadOnly.should be false
2880
2933
  book.should be_alive
2881
2934
  sheet = book.sheet(1)
2882
- old_cell_value = sheet[1,1].Value
2883
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2935
+ old_cell_value = sheet[1,1]
2936
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
2884
2937
  book.Saved.should be false
2885
2938
  expect{
2886
2939
  new_book = Workbook.open(@simple_file1, :read_only => true, :if_unsaved => :accept)
@@ -2892,8 +2945,8 @@ describe Workbook do
2892
2945
  book.ReadOnly.should be true
2893
2946
  book.should be_alive
2894
2947
  sheet = book.sheet(1)
2895
- old_cell_value = sheet[1,1].Value
2896
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2948
+ old_cell_value = sheet[1,1]
2949
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
2897
2950
  book.Saved.should be false
2898
2951
  new_book = Workbook.open(@simple_file1, :read_only => false, :if_unsaved => :forget)
2899
2952
  new_book.ReadOnly.should be false
@@ -2901,7 +2954,7 @@ describe Workbook do
2901
2954
  book.should_not be_alive
2902
2955
  new_book.should_not == book
2903
2956
  new_sheet = new_book.sheet(1)
2904
- new_cell_value = new_sheet[1,1].Value
2957
+ new_cell_value = new_sheet[1,1]
2905
2958
  new_cell_value.should == old_cell_value
2906
2959
  end
2907
2960
 
@@ -2910,8 +2963,8 @@ describe Workbook do
2910
2963
  book.ReadOnly.should be false
2911
2964
  book.should be_alive
2912
2965
  sheet = book.sheet(1)
2913
- old_cell_value = sheet[1,1].Value
2914
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2966
+ old_cell_value = sheet[1,1]
2967
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
2915
2968
  book.Saved.should be false
2916
2969
  expect{
2917
2970
  Workbook.open(@simple_file1, :read_only => true, :if_unsaved => :accept)
@@ -2923,13 +2976,13 @@ describe Workbook do
2923
2976
  book.ReadOnly.should be false
2924
2977
  book.should be_alive
2925
2978
  sheet = book.sheet(1)
2926
- old_cell_value = sheet[1,1].Value
2927
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2979
+ old_cell_value = sheet[1,1]
2980
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
2928
2981
  book.Saved.should be false
2929
2982
  new_book = Workbook.open(@simple_file1, :read_only => true, :if_unsaved => :save)
2930
2983
  new_book.ReadOnly.should be true
2931
2984
  new_sheet = new_book.sheet(1)
2932
- new_cell_value = new_sheet[1,1].Value
2985
+ new_cell_value = new_sheet[1,1]
2933
2986
  new_cell_value.should_not == old_cell_value
2934
2987
  end
2935
2988
 
@@ -2973,7 +3026,7 @@ describe Workbook do
2973
3026
  context "with various file formats" do
2974
3027
 
2975
3028
  it "should open linked workbook" do
2976
- book = Workbook.open(@linked_file, :visible => true)
3029
+ book = Workbook.open(@main_file, :visible => true)
2977
3030
  book.close
2978
3031
  end
2979
3032
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), './../spec_helper')
3
+ require_relative '../spec_helper'
4
4
 
5
5
 
6
6
  $VERBOSE = nil
@@ -213,8 +213,8 @@ describe Workbook do
213
213
  file.puts "garbage"
214
214
  end
215
215
  sheet = @book.sheet(1)
216
- cell_value = sheet[1,1].Value
217
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
216
+ cell_value = sheet[1,1]
217
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
218
218
  @book.Saved.should be false
219
219
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_blocked => :forget)
220
220
  @book.should_not be_alive
@@ -225,7 +225,7 @@ describe Workbook do
225
225
  new_book.close
226
226
  old_book = Workbook.open(@simple_file1)
227
227
  old_sheet = old_book.sheet(1)
228
- old_sheet[1,1].Value.should == cell_value
228
+ old_sheet[1,1].should == cell_value
229
229
  old_book.close
230
230
  end
231
231
 
@@ -235,8 +235,8 @@ describe Workbook do
235
235
  file.puts "garbage"
236
236
  end
237
237
  sheet = @book.sheet(1)
238
- cell_value = sheet[1,1].Value
239
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
238
+ cell_value = sheet[1,1]
239
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
240
240
  @book.Saved.should be false
241
241
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_blocked => :save)
242
242
  @book.should_not be_alive
@@ -247,7 +247,7 @@ describe Workbook do
247
247
  new_book.close
248
248
  old_book = Workbook.open(@simple_file1)
249
249
  old_sheet = old_book.sheet(1)
250
- old_sheet[1,1].Value.should_not == cell_value
250
+ old_sheet[1,1].should_not == cell_value
251
251
  old_book.close
252
252
  end
253
253
 
@@ -268,8 +268,8 @@ describe Workbook do
268
268
 
269
269
  it "should raise an error if the blocking workbook was unsaved with :if_blocked => :close_if_saved" do
270
270
  sheet = @book.sheet(1)
271
- cell_value = sheet[1,1].Value
272
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
271
+ cell_value = sheet[1,1]
272
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
273
273
  @book.Saved.should be false
274
274
  expect{
275
275
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_blocked => :close_if_saved)
@@ -363,8 +363,8 @@ describe Workbook do
363
363
  file.puts "garbage"
364
364
  end
365
365
  sheet = @book.sheet(1)
366
- cell_value = sheet[1,1].Value
367
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
366
+ cell_value = sheet[1,1]
367
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
368
368
  @book.Saved.should be false
369
369
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :forget)
370
370
  @book.should_not be_alive
@@ -375,7 +375,7 @@ describe Workbook do
375
375
  new_book.close
376
376
  old_book = Workbook.open(@simple_file1)
377
377
  old_sheet = old_book.sheet(1)
378
- old_sheet[1,1].Value.should == cell_value
378
+ old_sheet[1,1].should == cell_value
379
379
  old_book.close
380
380
  end
381
381
 
@@ -385,8 +385,8 @@ describe Workbook do
385
385
  file.puts "garbage"
386
386
  end
387
387
  sheet = @book.sheet(1)
388
- cell_value = sheet[1,1].Value
389
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
388
+ cell_value = sheet[1,1]
389
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
390
390
  @book.Saved.should be false
391
391
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :save)
392
392
  @book.should_not be_alive
@@ -397,7 +397,7 @@ describe Workbook do
397
397
  new_book.close
398
398
  old_book = Workbook.open(@simple_file1)
399
399
  old_sheet = old_book.sheet(1)
400
- old_sheet[1,1].Value.should_not == cell_value
400
+ old_sheet[1,1].should_not == cell_value
401
401
  old_book.close
402
402
  end
403
403
 
@@ -418,8 +418,8 @@ describe Workbook do
418
418
 
419
419
  it "should raise an error if the blocking workbook was unsaved with :if_blocked => :close_if_saved" do
420
420
  sheet = @book.sheet(1)
421
- cell_value = sheet[1,1].Value
422
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
421
+ cell_value = sheet[1,1]
422
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
423
423
  @book.Saved.should be false
424
424
  expect{
425
425
  @book2.save_as(@simple_file_other_path1, :if_exists => :overwrite, :if_obstructed => :close_if_saved)
@@ -509,12 +509,12 @@ describe Workbook do
509
509
 
510
510
  it "should simple save if file name is equal to the old one with :if_exists => :overwrite" do
511
511
  sheet = @book.sheet(1)
512
- sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
513
- new_value = sheet[1,1].Value
512
+ sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
513
+ new_value = sheet[1,1]
514
514
  @book.save_as(@simple_file1, :if_exists => :overwrite)
515
515
  new_book = Workbook.open(@simple_file1)
516
516
  new_sheet = new_book.sheet(1)
517
- new_sheet[1,1].Value.should == new_value
517
+ new_sheet[1,1].should == new_value
518
518
  new_book.close
519
519
  end
520
520
 
@@ -550,8 +550,8 @@ describe Workbook do
550
550
  it "should save if user answers 'yes'" do
551
551
  # "Yes" is to the left of "No", which is the default. --> language independent
552
552
  @key_sender.puts "{right}{right}{right}{enter}" #, :initial_wait => 0.2, :if_target_missing=>"Excel window not found")
553
- #@key_sender.puts "{left}{enter}"
554
- #@key_sender.puts "{left}{enter}"
553
+ @key_sender.puts "{left}{enter}"
554
+ @key_sender.puts "{left}{enter}"
555
555
  @book.save_as(@simple_save_file1, :if_exists => :alert)
556
556
  File.exist?(@simple_save_file1).should be true
557
557
  File.size?(@simple_save_file1).should > @garbage_length
@@ -683,4 +683,3 @@ describe Workbook do
683
683
  end
684
684
  end
685
685
  end
686
-