robust_excel_ole 0.6 → 0.6.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 (35) hide show
  1. data/Changelog +12 -0
  2. data/README.rdoc +5 -3
  3. data/README_detail.rdoc +1 -1
  4. data/examples/edit_sheets/example_adding_sheets.rb +1 -1
  5. data/examples/edit_sheets/example_expanding.rb +1 -1
  6. data/examples/open_save_close/example_control_to_excel.rb +2 -2
  7. data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
  8. data/examples/open_save_close/example_if_obstructed_forget.rb +1 -1
  9. data/examples/open_save_close/example_if_unsaved_accept.rb +2 -2
  10. data/examples/open_save_close/example_read_only.rb +1 -1
  11. data/examples/open_save_close/example_simple.rb +1 -1
  12. data/lib/robust_excel_ole/book.rb +89 -111
  13. data/lib/robust_excel_ole/excel.rb +49 -50
  14. data/lib/robust_excel_ole/general.rb +3 -3
  15. data/lib/robust_excel_ole/reo_common.rb +78 -1
  16. data/lib/robust_excel_ole/sheet.rb +16 -23
  17. data/lib/robust_excel_ole/version.rb +1 -1
  18. data/spec/book_spec.rb +7 -7
  19. data/spec/book_specs/book_close_spec.rb +24 -5
  20. data/spec/book_specs/book_misc_spec.rb +16 -7
  21. data/spec/book_specs/book_open_spec.rb +15 -20
  22. data/spec/book_specs/book_save_spec.rb +21 -21
  23. data/spec/book_specs/book_sheet_spec.rb +3 -3
  24. data/spec/book_specs/book_unobtr_spec.rb +1 -1
  25. data/spec/data/book_with_blank.xls +0 -0
  26. data/spec/data/different_workbook.xls +0 -0
  27. data/spec/data/refed_wb.xls +0 -0
  28. data/spec/data/reference_workbook.xls +0 -0
  29. data/spec/data/referencing_wb.xls +0 -0
  30. data/spec/data/workbook.xls +0 -0
  31. data/spec/excel_spec.rb +87 -125
  32. data/spec/general_spec.rb +2 -2
  33. data/spec/reo_common_spec.rb +1 -1
  34. data/spec/sheet_spec.rb +13 -17
  35. metadata +7 -3
data/Changelog CHANGED
@@ -1,6 +1,16 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+
5
+ ## [0.6.1] - 2016-04-09
6
+
7
+ ### Changed
8
+ - error classes
9
+
10
+ ### Added
11
+
12
+ - Excel#foremost_window
13
+
4
14
  ## [0.6] - 2016-03-08
5
15
 
6
16
  ## [0.5.2] - 2016-17-07
@@ -11,6 +21,8 @@ All notable changes to this project will be documented in this file.
11
21
  (:active, :reuse as alias)
12
22
  - Book: open: options: deleted :displayalerts
13
23
  - Excel: create, current: with options :visible, :displayalerts
24
+
25
+ ### Added
14
26
  - Excel: create, current, new: new options-value :displayalerts => :if_visible
15
27
 
16
28
  ## [0.5.1] - 2016-18-06
data/README.rdoc CHANGED
@@ -44,11 +44,13 @@ Options are
44
44
  +:default_excel+, +:force_excel+, +:if_absent+, +:if_unsaved+, +:if_obstructed+,
45
45
  +:read_only+, +:visible+, +:check_compatibility, and +:update_links+.
46
46
 
47
- Valid values for +:default_excel+ are +:current+ (or +:active+, or +:reuse+), +:new+ or some Excel instance, for +:force_excel+ : +:current+ (or +:active+, or +:reuse+), +:new+ or some Excel instance, for +:if_unsaved+ : +:raise+, +:accept+, +:forget+, +:alert+ and +:new_excel+, for +:if_obstructed+ : +:raise+, +:save+, +:close_if_saved+, +:forget+, +:alert+ and +:new_excel+ , for +:if_absent+ : +:raise+ and +:create+. The others are Boolean.
47
+ Valid values for +:default_excel+ are +:current+ (or +:active+, or +:reuse+), +:new+ or some Excel instance, for +:force_excel+ : +:current+ (or +:active+, or +:reuse+), +:new+ or some Excel instance, for +:if_unsaved+ : +:raise+, +:accept+, +:forget+, +:alert+ and +:new_excel+, for +:if_obstructed+ : +:raise+, +:save+, +:close_if_saved+, +:forget+, +:alert+ and +:new_excel+ , for +:if_absent+ : +:raise+ and +:create+, for +:update_links+ : +:never+, +:always+, +:alert+. The others are Boolean.
48
+
49
+ Remark: Doing updating links seems to be dependent on calculation mode: updates happen, if the calcultion mode is automatic, does not happen, if calculation mode is manual.
48
50
 
49
51
  Here are a few examples:
50
52
 
51
- Opening a workbook in the Excel instance where it was opened before most recently, if it was opened before and this Excel instance is alive. Otherwise opening it in a running Excel, if it exists, or in a new Excel.
53
+ Opening a workbook in the Excel instance where it was opened before most recently, if it was opened beefore and this Excel instance is alive. Otherwise opening it in a running Excel, if it exists, or in a new Excel.
52
54
 
53
55
  Opening a workbook in the Excel instance where it was opened before most recently, if it was opened before and this Excel instance is alive. Otherwise opening it in a new Excel instance.
54
56
 
@@ -428,7 +430,7 @@ Closing the Excel instance, saving unsaved workbooks and terminating the Excel p
428
430
 
429
431
  excel.close(:if_unsaved => :save, :hard => true)
430
432
 
431
- === Closing all Excel instances.
433
+ === Closing Excel instances opened via RobustExcelOle.
432
434
 
433
435
  Excel.close_all
434
436
 
data/README_detail.rdoc CHANGED
@@ -507,7 +507,7 @@ Closing the Excel instance, saving unsaved workbooks and terminating the Excel p
507
507
 
508
508
  excel.close(:if_unsaved => :save, :hard => true)
509
509
 
510
- === Closing all Excel instances.
510
+ === Closing Excel instances opened via RobustExcelOle
511
511
 
512
512
  Excel.close_all
513
513
 
@@ -56,7 +56,7 @@ begin
56
56
  puts"adding a copy of the 2nd sheet and name it again 'second_sheet_copy'"
57
57
  begin
58
58
  @book.add_sheet(sheet, :as => 'second_sheet_copy')
59
- rescue ExcelErrorSheet => msg
59
+ rescue NameAlreadyExists => msg
60
60
  puts "error: add_sheet: #{msg.message}"
61
61
  end
62
62
 
@@ -33,7 +33,7 @@ begin
33
33
  sheet_new = book.add_sheet sheet
34
34
  begin
35
35
  sheet_new.name = sheet_name
36
- rescue ExcelErrorSheet => msg
36
+ rescue REOError => msg
37
37
  sheet_new.name = sheet_name + sheet.name if msg.message == "sheet name already exists"
38
38
  end
39
39
  sheet_new.set_name("name", 2, 2)
@@ -26,13 +26,13 @@ begin
26
26
  Excel.current.visible = true
27
27
  begin
28
28
  book.close(:if_unsaved => :alert) # close the unsaved book.
29
- rescue ExcelUserCanceled => msg # user is asked whether the unsaved book shall be saved
29
+ rescue WorkbookError => msg # user is asked whether the unsaved book shall be saved
30
30
  puts "#{msg.message}" # if the user chooses to cancel, then an expeption is raised
31
31
  end
32
32
  if new_book then
33
33
  begin
34
34
  new_book.save_as(file_name, :if_exists => :alert) # save the new book, if it was opened
35
- rescue ExcelErrorSave => msg # user is asked, whether the existing file shall be overwritten
35
+ rescue WorkbookError => msg # user is asked, whether the existing file shall be overwritten
36
36
  puts "save_as: #{msg.message}" # if the user chooses "no" or "cancel", an exception is raised
37
37
  end
38
38
 
@@ -20,7 +20,7 @@ begin
20
20
  sleep 1
21
21
  begin
22
22
  new_book = Book.open(other_file_name, :if_obstructed => :close_if_saved) # raises an exception since the file is not saved
23
- rescue ExcelErrorOpen => msg
23
+ rescue WorkbookNotSaved => msg
24
24
  puts "error: open: #{msg.message}"
25
25
  end
26
26
  book.save # save the unsaved book
@@ -16,7 +16,7 @@ begin
16
16
  sleep 3
17
17
  begin
18
18
  new_book = Book.open(other_file_name) # open a book with the same file name in a different path
19
- rescue ExcelErrorOpen => msg # by default: raises an exception
19
+ rescue WorkbookBlocked => msg # by default: raises an exception
20
20
  puts "error: open: #{msg.message}"
21
21
  end
22
22
  # open a new book with the same file name in a different path. close the old book before.
@@ -16,7 +16,7 @@ begin
16
16
  sheet[1,1] = sheet[1,1].value == "simple" ? "complex" : "simple" # change a cell
17
17
  begin
18
18
  new_book = Book.open(file_name) # open another book with the same file name
19
- rescue ExcelErrorOpen => msg # by default: raises an exception:
19
+ rescue WorkbookBeingUsed => msg # by default: raises an exception:
20
20
  puts "error: open: #{msg.message}" # a book with the same name is already open and unsaved
21
21
  end
22
22
  new_book = Book.open(file_name, :if_unsaved => :accept) # open another book with the same file name
@@ -29,7 +29,7 @@ begin
29
29
  end
30
30
  begin
31
31
  book.close # close the book. by default: raises an exception:
32
- rescue ExcelErrorClose => msg # book is unsaved
32
+ rescue WorkbookNotSaved => msg # book is unsaved
33
33
  puts "close error: #{msg.message}"
34
34
  end
35
35
  book.close(:if_unsaved => :save) # save the book before closing it
@@ -18,7 +18,7 @@ begin
18
18
  sleep 1
19
19
  begin
20
20
  book.save # simple save.
21
- rescue ExcelErrorSave => msg # raises an exception because book is opened in read_only mode
21
+ rescue WorkbookReadOnly => msg # raises an exception because book is opened in read_only mode
22
22
  puts "error: save_as: #{msg.message}"
23
23
  end
24
24
  book.close # close the book without saving it
@@ -25,7 +25,7 @@ begin
25
25
  book.save # simple save
26
26
  begin
27
27
  book.save_as(other_file_name) # save_as : default :if_exists => :raise
28
- rescue ExcelErrorSave => msg
28
+ rescue FileAlreadyExists => msg
29
29
  puts "error: save_as: #{msg.message}"
30
30
  end
31
31
  book.save_as(other_file_name, :if_exists => :overwrite) # save_as with :if_exists => :overwrite