robust_excel_ole 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +6 -0
  3. data/README.rdoc +1 -1
  4. data/docs/README_open.rdoc +1 -1
  5. data/docs/README_ranges.rdoc +60 -57
  6. data/docs/README_sheet.rdoc +1 -1
  7. data/examples/introducing_examples/example_introducing.rb +42 -0
  8. data/examples/introducing_examples/example_open.rb +49 -0
  9. data/examples/introducing_examples/example_range.rb +67 -0
  10. data/examples/{edit_sheets → modifying_sheets}/example_access_sheets_and_cells.rb +0 -0
  11. data/examples/{edit_sheets → modifying_sheets}/example_adding_sheets.rb +0 -0
  12. data/examples/{edit_sheets → modifying_sheets}/example_concating.rb +1 -1
  13. data/examples/{edit_sheets → modifying_sheets}/example_copying.rb +1 -1
  14. data/examples/{edit_sheets → modifying_sheets}/example_expanding.rb +1 -1
  15. data/examples/{edit_sheets → modifying_sheets}/example_naming.rb +1 -1
  16. data/examples/{edit_sheets → modifying_sheets}/example_ranges.rb +1 -1
  17. data/examples/{edit_sheets → modifying_sheets}/example_saving.rb +1 -1
  18. data/examples/open_save_close/example_control_to_excel.rb +2 -2
  19. data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
  20. data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
  21. data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
  22. data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
  23. data/examples/open_save_close/example_read_only.rb +1 -1
  24. data/examples/open_save_close/example_rename_cells.rb +1 -1
  25. data/examples/open_save_close/example_simple.rb +1 -1
  26. data/examples/open_save_close/example_unobtrusively.rb +3 -3
  27. data/lib/robust_excel_ole.rb +2 -2
  28. data/lib/robust_excel_ole/bookstore.rb +1 -1
  29. data/lib/robust_excel_ole/cell.rb +15 -2
  30. data/lib/robust_excel_ole/excel.rb +14 -12
  31. data/lib/robust_excel_ole/general.rb +12 -0
  32. data/lib/robust_excel_ole/range.rb +37 -20
  33. data/lib/robust_excel_ole/reo_common.rb +63 -37
  34. data/lib/robust_excel_ole/version.rb +1 -1
  35. data/lib/robust_excel_ole/{book.rb → workbook.rb} +35 -33
  36. data/lib/robust_excel_ole/{sheet.rb → worksheet.rb} +22 -22
  37. data/spec/bookstore_spec.rb +38 -38
  38. data/spec/cell_spec.rb +10 -10
  39. data/spec/data/another_workbook.xls +0 -0
  40. data/spec/data/workbook.xls +0 -0
  41. data/spec/excel_spec.rb +113 -105
  42. data/spec/general_spec.rb +37 -5
  43. data/spec/range_spec.rb +34 -19
  44. data/spec/reo_common_spec.rb +58 -48
  45. data/spec/{book_spec.rb → workbook_spec.rb} +198 -198
  46. data/spec/workbook_specs/workbook_all_spec.rb +33 -0
  47. data/spec/{book_specs/book_close_spec.rb → workbook_specs/workbook_close_spec.rb} +10 -10
  48. data/spec/{book_specs/book_misc_spec.rb → workbook_specs/workbook_misc_spec.rb} +148 -128
  49. data/spec/{book_specs/book_open_spec.rb → workbook_specs/workbook_open_spec.rb} +427 -427
  50. data/spec/{book_specs/book_save_spec.rb → workbook_specs/workbook_save_spec.rb} +44 -44
  51. data/spec/{book_specs/book_sheet_spec.rb → workbook_specs/workbook_sheet_spec.rb} +19 -19
  52. data/spec/{book_specs/book_subclass_spec.rb → workbook_specs/workbook_subclass_spec.rb} +5 -6
  53. data/spec/{book_specs/book_unobtr_spec.rb → workbook_specs/workbook_unobtr_spec.rb} +339 -344
  54. data/spec/{sheet_spec.rb → worksheet_spec.rb} +85 -55
  55. metadata +25 -22
  56. data/spec/book_specs/book_all_spec.rb +0 -22
@@ -24,7 +24,7 @@ begin
24
24
  name = cell.Name.Name rescue nil
25
25
  if name
26
26
  cell.Value = cell.Value.to_s + cell.Offset(0,1).Value.to_s
27
- sheet.add_name(name, cell.Row, cell.Column)
27
+ sheet.add_name(name, [cell.Row, cell.Column])
28
28
  end
29
29
  end
30
30
  end
@@ -33,7 +33,7 @@ begin
33
33
  cell_name = short_name ? short_name : sheet_name
34
34
  contains_named_cells = true
35
35
  new_sheet[cell.Row, cell.Column].Value = cell.Value
36
- new_sheet.add_name(cell_name, cell.Row,cell.Column)
36
+ new_sheet.add_name(cell_name, [cell.Row,cell.Column])
37
37
  end
38
38
  end
39
39
  new_sheet.Delete() unless contains_named_cells
@@ -36,7 +36,7 @@ begin
36
36
  rescue REOError => msg
37
37
  sheet_new.name = sheet_name + sheet.name if msg.message == "sheet name already exists"
38
38
  end
39
- sheet_new.add_name("name",2,2)
39
+ sheet_new.add_name("name",[2,2])
40
40
  sheet_new["name"] = sheet_name
41
41
  end
42
42
 
@@ -29,7 +29,7 @@ begin
29
29
  book.each do |sheet|
30
30
  sheet.each do |cell_orig|
31
31
  contents = cell_orig.Value
32
- sheet.add_name(contents, cell_orig.Row, cell_orig.Column) if contents && contents.is_a?(String)
32
+ sheet.add_name(contents, [cell_orig.Row, cell_orig.Column]) if contents && contents.is_a?(String)
33
33
  end
34
34
  end
35
35
  end
@@ -13,7 +13,7 @@ begin
13
13
  simple_file = dir + 'workbook.xls'
14
14
  simple_save_file = dir + 'workbook_save.xls'
15
15
  File.delete simple_save_file rescue nil
16
- book = Book.open(simple_file) # open a book
16
+ book = Workbook.open(simple_file) # open a book
17
17
  sheet = book.sheet('Sheet1') # access a sheet via the name
18
18
  row_r = sheet.row_range(1) # access the whole range of the first row
19
19
  col_r = sheet.col_range(1, 1..2) # access the first two cells of the range of the first column
@@ -16,7 +16,7 @@ begin
16
16
  suffix = ws.last
17
17
  file_name = dir + "/" + workbook_name
18
18
 
19
- Book.unobtrusively(file_name) do |book_orig|
19
+ Workbook.unobtrusively(file_name) do |book_orig|
20
20
  book_orig.each do |sheet_orig|
21
21
  file_sheet_name = dir + "/" + base_name + "_" + sheet_orig.name + "." + suffix
22
22
  Excel.current.generate_workbook(file_sheet_name)
@@ -11,14 +11,14 @@ Excel.kill_all
11
11
  begin
12
12
  dir = create_tmpdir
13
13
  file_name = dir + 'workbook.xls'
14
- book = Book.open(file_name) # open a book
14
+ book = Workbook.open(file_name) # open a book
15
15
  book.excel.visible = true # make current Excel visible
16
16
  sleep 1
17
17
  sheet = book.sheet(1) # access a sheet
18
18
  sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple" # change a cell
19
19
  sleep 1
20
20
  begin
21
- new_book = Book.open(file_name, :if_unsaved => :alert) # open another book with the same file name
21
+ new_book = Workbook.open(file_name, :if_unsaved => :alert) # open another book with the same file name
22
22
  rescue WorkbookREOError => msg # if the user chooses not open the book,
23
23
  puts "#{msg.message}" # an exeptions is raised
24
24
  end
@@ -15,7 +15,7 @@ begin
15
15
  book = Workbook.open(file_name, :visible => true) # open a book, make Excel visible
16
16
  sleep 1
17
17
  sheet = book.sheet(1)
18
- first_cell = sheet[1,1].value # access a sheet
18
+ first_cell = sheet[1,1].Value # access a sheet
19
19
  sheet[1,1] = first_cell == "simple" ? "complex" : "simple" # change a cell
20
20
  sleep 1
21
21
  new_book = Workbook.open(other_file_name, :if_obstructed => :save) # open a book with the same file name in a different path
@@ -23,7 +23,7 @@ begin
23
23
  old_book = Workbook.open(file_name, :if_obstructed => :forget ,:visible => true) # open the old book
24
24
  sleep 1
25
25
  old_sheet = old_book.sheet(1)
26
- old_first_cell = old_sheet[1,1].value
26
+ old_first_cell = old_sheet[1,1].Value
27
27
  puts "the old book was saved" unless old_first_cell == first_cell
28
28
  new_book.close # close the books
29
29
  old_book.close
@@ -13,7 +13,7 @@ begin
13
13
  file_name = dir + 'workbook.xls'
14
14
  book = Workbook.open(file_name) # open a book
15
15
  sheet = book.sheet(1) # access a sheet
16
- sheet[1,1] = sheet[1,1].value == "simple" ? "complex" : "simple" # change a cell
16
+ sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple" # change a cell
17
17
  begin
18
18
  new_book = Workbook.open(file_name) # open another book with the same file name
19
19
  rescue WorkbookNotSaved => msg # by default: raises an exception:
@@ -16,7 +16,7 @@ begin
16
16
  #book.excel.visible = true # make current Excel visible
17
17
  sleep 1
18
18
  sheet = book.sheet(1) # access a sheet
19
- first_cell = sheet[1,1].value
19
+ first_cell = sheet[1,1].Value
20
20
  sheet[1,1] = first_cell == "simple" ? "complex" : "simple" # change a cell
21
21
  sleep 1
22
22
  puts "new_book: before"
@@ -25,11 +25,11 @@ begin
25
25
  # and close the unsaved book without saving it
26
26
  puts "new_book: after"
27
27
  sheet_new_book = new_book.sheet(1)
28
- if (not book.alive?) && new_book.alive? && sheet_new_book[1,1].value == first_cell then # check whether the unsaved book
28
+ if (not book.alive?) && new_book.alive? && sheet_new_book[1,1].Value == first_cell then # check whether the unsaved book
29
29
  puts "open with :if_unsaved => :forget : the unsaved book is closed and not saved." # is closed and was not saved
30
30
  end
31
31
  sleep 1
32
- sheet_new_book[1,1] = sheet_new_book[1,1].value == "simple" ? "complex" : "simple" # change a cell
32
+ sheet_new_book[1,1] = sheet_new_book[1,1].Value == "simple" ? "complex" : "simple" # change a cell
33
33
  # open another book in a new Excel application, and make Excel visible, leaving the unsaved book open
34
34
  another_book = Workbook.open(file_name, :if_unsaved => :new_excel, :visible => true)
35
35
  sleep 3 # leaving the unsaved book open
@@ -14,21 +14,21 @@ begin
14
14
  book = Workbook.open(file_name) # open a book
15
15
  #book.excel.visible = true # make current Excel visible
16
16
  sheet = book.sheet(1) # access a sheet
17
- first_cell = sheet[1,1].value
17
+ first_cell = sheet[1,1].Value
18
18
  sheet[1,1] = first_cell == "simple" ? "complex" : "simple" # change a cell
19
19
  sleep 1
20
20
  new_book = Workbook.open(file_name, :if_unsaved => :new_excel, :visible => true) # open another book with the same file name in a new Excel
21
21
  sheet_new_book = new_book.sheet(1)
22
- if (not book.alive?) && new_book.alive? && sheet_new_book[1,1].value == first_cell then # check whether the unsaved book
22
+ if (not book.alive?) && new_book.alive? && sheet_new_book[1,1].Value == first_cell then # check whether the unsaved book
23
23
  puts "open with :if_unsaved => :forget : the unsaved book is closed and not saved." # is closed and was not saved
24
24
  end
25
25
  sleep 1
26
- sheet_new_book[1,1] = sheet_new_book[1,1].value == "simple" ? "complex" : "simple" # change a cell
26
+ sheet_new_book[1,1] = sheet_new_book[1,1].Value == "simple" ? "complex" : "simple" # change a cell
27
27
  # open another book in the running Excel application, and make Excel visible, closing the unsaved book
28
28
  another_book = Workbook.open(file_name, :if_unsaved => :forget, :visible => true)
29
29
  sleep 1
30
30
  sheet_another_book = another_book.sheet(1)
31
- sheet_another_book[1,1] = sheet_another_book[1,1].value == "simple" ? "complex" : "simple" # change a cell
31
+ sheet_another_book[1,1] = sheet_another_book[1,1].Value == "simple" ? "complex" : "simple" # change a cell
32
32
  another_book.close(:if_unsaved => :forget ) # close the last book without saving it.
33
33
  book.close(:if_unsaved => :save) # close the first book and save it before
34
34
  ensure
@@ -14,7 +14,7 @@ begin
14
14
  book = Workbook.open(file_name, :read_only => true, :visible => true) # open a book with read_only and make Excel visible
15
15
  sheet = book.sheet(1) # access a sheet
16
16
  sleep 1
17
- sheet[1,1] = sheet[1,1].value == "simple" ? "complex" : "simple" # change a cell
17
+ sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple" # change a cell
18
18
  sleep 1
19
19
  begin
20
20
  book.save # simple save.
@@ -17,7 +17,7 @@ begin
17
17
  workbook = book.ole_workbook
18
18
  fullname = workbook.Fullname
19
19
  puts "fullname: #{fullname}"
20
- sheet.add_name("a_name",1,1) # rename cell A1 to "a_name"
20
+ sheet.add_name("a_name",[1,1]) # rename cell A1 to "a_name"
21
21
  number = workbook.Names.Count
22
22
  puts "number of name objects :#{number}"
23
23
  name_object = workbook.Names("a_name")
@@ -20,7 +20,7 @@ begin
20
20
  book.excel.visible = true # make current Excel visible
21
21
  sheet = book.sheet(1) # access a sheet
22
22
  sleep 1
23
- sheet[1,1] = sheet[1,1].value == "simple" ? "complex" : "simple" # change a cell
23
+ sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple" # change a cell
24
24
  sleep 1
25
25
  book.save # simple save
26
26
  begin
@@ -12,14 +12,14 @@ begin
12
12
  simple_file = dir + 'workbook.xls'
13
13
  book = Workbook.open(simple_file, :visible => true) # open a book, make Excel visible
14
14
  old_sheet = book.sheet(1)
15
- p "1st cell: #{old_sheet[1,1].value}"
15
+ p "1st cell: #{old_sheet[1,1].Value}"
16
16
  sleep 2
17
17
  Workbook.unobtrusively(simple_file) do |book| # modify the book and keep its status unchanged
18
18
  sheet = book.sheet(1)
19
- sheet[1,1] = sheet[1,1].value == "simple" ? "complex" : "simple"
19
+ sheet[1,1] = sheet[1,1].Value == "simple" ? "complex" : "simple"
20
20
  end
21
21
  new_sheet = book.sheet(1)
22
- p "1st cell: #{new_sheet[1,1].value}"
22
+ p "1st cell: #{new_sheet[1,1].Value}"
23
23
  p "book saved" if book.Saved
24
24
  book.close # close the book
25
25
  ensure
@@ -3,8 +3,8 @@ require File.join(File.dirname(__FILE__), 'robust_excel_ole/reo_common')
3
3
  require File.join(File.dirname(__FILE__), 'robust_excel_ole/general')
4
4
  require File.join(File.dirname(__FILE__), 'robust_excel_ole/excel')
5
5
  require File.join(File.dirname(__FILE__), 'robust_excel_ole/bookstore')
6
- require File.join(File.dirname(__FILE__), 'robust_excel_ole/book')
7
- require File.join(File.dirname(__FILE__), 'robust_excel_ole/sheet')
6
+ require File.join(File.dirname(__FILE__), 'robust_excel_ole/workbook')
7
+ require File.join(File.dirname(__FILE__), 'robust_excel_ole/worksheet')
8
8
  require File.join(File.dirname(__FILE__), 'robust_excel_ole/cell')
9
9
  require File.join(File.dirname(__FILE__), 'robust_excel_ole/range')
10
10
  require File.join(File.dirname(__FILE__), 'robust_excel_ole/cygwin') if RUBY_PLATFORM =~ /cygwin/
@@ -59,7 +59,7 @@ module RobustExcelOle
59
59
  end
60
60
 
61
61
  # stores a workbook
62
- # @param [Book] book a given book
62
+ # @param [Workbook] book a given book
63
63
  def store(book)
64
64
  filename_key = General::canonize(book.filename)
65
65
  if book.stored_filename
@@ -12,8 +12,21 @@ module RobustExcelOle
12
12
  end
13
13
  end
14
14
 
15
- def method_missing(id, *args) # :nodoc: #
16
- @cell.send(id, *args)
15
+ def method_missing(name, *args) # :nodoc: #
16
+ if name.to_s[0,1] =~ /[A-Z]/
17
+ begin
18
+ @cell.send(name, *args)
19
+ rescue WIN32OLERuntimeError => msg
20
+ if msg.message =~ /unknown property or method/
21
+ raise VBAMethodMissingError, "unknown VBA property or method #{name.inspect}"
22
+ else
23
+ raise msg
24
+ end
25
+ end
26
+ else
27
+ super
28
+ end
17
29
  end
30
+
18
31
  end
19
32
  end
@@ -10,6 +10,8 @@ end
10
10
 
11
11
  module RobustExcelOle
12
12
 
13
+ # see https://docs.microsoft.com/en-us/office/vba/api/excel.application(object)#methods
14
+
13
15
  class Excel < RangeOwners
14
16
 
15
17
  attr_accessor :ole_excel
@@ -124,7 +126,7 @@ module RobustExcelOle
124
126
  self.displayalerts = opts[:displayalerts]
125
127
  self.calculation = opts[:calculation]
126
128
  if opts[:reopen_workbooks]
127
- books = book_class.books
129
+ books = workbook_class.books
128
130
  books.each do |book|
129
131
  book.reopen if ((not book.alive?) && book.excel.alive? && book.excel == self)
130
132
  end
@@ -224,7 +226,7 @@ module RobustExcelOle
224
226
  end
225
227
 
226
228
  # closes all Excel instances
227
- # @return [Fixnum,Fixnum] number of closed Excel instances, number of errors
229
+ # @return [Integer,Integer] number of closed Excel instances, number of errors
228
230
  # remark: the returned number of closed Excel instances is valid only for known Excel instances
229
231
  # if there are unknown Excel instances (opened not via this class), then they are counted as 1
230
232
  # @param [Hash] options the options
@@ -359,7 +361,7 @@ module RobustExcelOle
359
361
  end
360
362
 
361
363
  # kill all Excel instances
362
- # @return [Fixnum] number of killed Excel processes
364
+ # @return [Integer] number of killed Excel processes
363
365
  def self.kill_all
364
366
  number = 0
365
367
  WIN32OLE.connect("winmgmts:\\\\.").InstancesOf("win32_process").each do |p|
@@ -528,7 +530,7 @@ module RobustExcelOle
528
530
  def calculation= calculation_mode
529
531
  return if calculation_mode.nil?
530
532
  @calculation = calculation_mode
531
- calc_mode_changable = @ole_excel.Workbooks.Count > 0 && @ole_excel.Calculation.is_a?(Fixnum)
533
+ calc_mode_changable = @ole_excel.Workbooks.Count > 0 && @ole_excel.Calculation.is_a?(Integer)
532
534
  if calc_mode_changable
533
535
  if calculation_mode == :manual then
534
536
  saved = []
@@ -562,7 +564,7 @@ module RobustExcelOle
562
564
  self.calculation = calculation_mode
563
565
  yield self
564
566
  ensure
565
- @ole_excel.Calculation = old_calculation_mode if @ole_excel.Calculation.is_a?(Fixnum)
567
+ @ole_excel.Calculation = old_calculation_mode if @ole_excel.Calculation.is_a?(Integer)
566
568
  end
567
569
  end
568
570
 
@@ -587,7 +589,7 @@ module RobustExcelOle
587
589
  end
588
590
  end
589
591
  ole_workbooks.each do |ole_workbook|
590
- book_class.open(ole_workbook).for_this_workbook(options)
592
+ workbook_class.open(ole_workbook).for_this_workbook(options)
591
593
  end
592
594
  end
593
595
 
@@ -622,17 +624,17 @@ module RobustExcelOle
622
624
  self.to_s
623
625
  end
624
626
 
625
- def self.book_class # :nodoc: #
626
- @book_class ||= begin
627
+ def self.workbook_class # :nodoc: #
628
+ @workbook_class ||= begin
627
629
  module_name = self.parent_name
628
- "#{module_name}::Book".constantize
630
+ "#{module_name}::Workbook".constantize
629
631
  rescue NameError => e
630
- book
632
+ Workbook
631
633
  end
632
634
  end
633
635
 
634
- def book_class # :nodoc: #
635
- self.class.book_class
636
+ def workbook_class # :nodoc: #
637
+ self.class.workbook_class
636
638
  end
637
639
 
638
640
  include MethodHelpers
@@ -29,6 +29,18 @@ module General
29
29
  end
30
30
 
31
31
  class WIN32OLE
32
+
33
+ # promoting WIN32OLE objects to RobustExcelOle objects
34
+ def to_reo
35
+ case self.ole_type.name
36
+ when "Range" then RobustExcelOle::Range.new(self)
37
+ when "_Worksheet" then Worksheet.new(self)
38
+ when "_Workbook" then Workbook.new(self)
39
+ when "_Application" then Excel.new(self)
40
+ else
41
+ self
42
+ end
43
+ end
32
44
  end
33
45
 
34
46
  class ::String # :nodoc: #
@@ -1,6 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module RobustExcelOle
3
3
 
4
+ # see https://docs.microsoft.com/en-us/office/vba/api/excel.worksheet#methods
5
+
4
6
  class Range < REOCommon
5
7
  include Enumerable
6
8
  attr_reader :ole_range
@@ -8,7 +10,7 @@ module RobustExcelOle
8
10
 
9
11
  def initialize(win32_range)
10
12
  @ole_range = win32_range
11
- @worksheet = sheet_class.new(self.Parent)
13
+ @worksheet = worksheet_class.new(self.Parent)
12
14
  end
13
15
 
14
16
  def each
@@ -21,7 +23,7 @@ module RobustExcelOle
21
23
  # @params [Range] a range
22
24
  # @returns [Array] the values
23
25
  def values(range = nil)
24
- result = self.map{|x| x.value}.flatten
26
+ result = self.map{|x| x.Value}.flatten
25
27
  if range
26
28
  relevant_result = []
27
29
  result.each_with_index{ |row_or_column, i| relevant_result << row_or_column if range.include?(i) }
@@ -37,44 +39,59 @@ module RobustExcelOle
37
39
  end
38
40
 
39
41
  # copies a range
40
- # @params [Fixnum,Range] row or range of the rows
41
- # @params [Fixnum,Range] column or range of columns
42
- # @options [Sheet] the worksheet in which to copy
43
- def copy(int_range1, int_range2, sheet = :__not_provided)
44
- int_range1 = int_range1 .. int_range1 if int_range1.is_a?(Fixnum)
45
- int_range2 = int_range2 .. int_range2 if int_range2.is_a?(Fixnum)
42
+ # @params [Address] address of a range
43
+ # @options [Worksheet] the worksheet in which to copy
44
+ def copy(address, sheet = :__not_provided, third_argument_deprecated = :__not_provided)
45
+ if third_argument_deprecated != :__not_provided
46
+ address = [address,sheet]
47
+ sheet = third_argument_deprecated
48
+ end
49
+ address = Address.new(address)
46
50
  sheet = @worksheet if sheet == :__not_provided
51
+ destination_range = sheet.range([address.rows.min..address.rows.max,
52
+ address.columns.min..address.columns.max]).ole_range
47
53
  if sheet.workbook.excel == @worksheet.workbook.excel
48
54
  begin
49
- self.Copy(:destination => sheet.range(int_range1.min..int_range1.max,
50
- int_range2.min..int_range2.max).ole_range)
55
+ self.Copy(:destination => destination_range)
51
56
  rescue WIN32OLERuntimeError
52
57
  raise RangeNotCopied, "cannot copy range"
53
58
  end
54
59
  else
55
60
  self.Select
56
61
  self.Copy
57
- sheet.Paste(sheet.range(int_range1.min..int_range1.max,int_range2.min..int_range2.max).ole_range)
62
+ sheet.Paste(destination_range)
58
63
  end
59
64
  end
60
65
 
61
- def self.sheet_class # :nodoc: #
62
- @sheet_class ||= begin
66
+ def self.worksheet_class # :nodoc: #
67
+ @worksheet_class ||= begin
63
68
  module_name = self.parent_name
64
- "#{module_name}::Sheet".constantize
69
+ "#{module_name}::Worksheet".constantize
65
70
  rescue NameError => e
66
- Sheet
71
+ Worksheet
67
72
  end
68
73
  end
69
74
 
70
- def sheet_class # :nodoc: #
71
- self.class.sheet_class
75
+ def worksheet_class # :nodoc: #
76
+ self.class.worksheet_class
72
77
  end
73
78
 
74
79
  private
75
-
76
- def method_missing(id, *args) # :nodoc: #
77
- @ole_range.send(id, *args)
80
+ def method_missing(name, *args) # :nodoc: #
81
+ if name.to_s[0,1] =~ /[A-Z]/
82
+ begin
83
+ @ole_range.send(name, *args)
84
+ rescue WIN32OLERuntimeError => msg
85
+ if msg.message =~ /unknown property or method/
86
+ raise VBAMethodMissingError, "unknown VBA property or method #{name.inspect}"
87
+ else
88
+ raise msg
89
+ end
90
+ end
91
+ else
92
+ super
93
+ end
78
94
  end
95
+
79
96
  end
80
97
  end