Class: RobustExcelOle::Workbook

Inherits:
RangeOwners show all
Defined in:
lib/robust_excel_ole/workbook.rb

Overview

This class essentially wraps a Win32Ole Workbook object. You can apply all VBA methods (starting with a capital letter) that you would apply for a Workbook object. See docs.microsoft.com/en-us/office/vba/api/excel.workbook#methods

Constant Summary collapse

CORE_DEFAULT_OPEN_OPTS =
{
  :default => {:excel => :current}, 
  :force => {},
  :update_links => :never 
}.freeze
DEFAULT_OPEN_OPTS =
{
  :if_unsaved    => :raise,
  :if_obstructed => :raise,
  :if_absent     => :raise,
  :if_exists => :raise
}.merge(CORE_DEFAULT_OPEN_OPTS).freeze
ABBREVIATIONS =
[
  [:default,:d],
  [:force, :f],
  [:excel, :e],
  [:visible, :v],
  [:if_obstructed, :if_blocked]
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RangeOwners

#add_name, #delete_name, #name2range, #namevalue, #namevalue_glob, #range, #rename_range, #set_name, #set_namevalue, #set_namevalue_glob

Methods inherited from VbaObjects

#to_reo

Constructor Details

#initialize(file_or_workbook, opts) ⇒ Workbook

creates a new Workbook object, if a file name is given Promotes the win32ole workbook to a Workbook object, if a win32ole-workbook is given

Parameters:

  • file_or_workbook (Variant)

    file name or workbook

  • opts (Hash)

Options Hash (opts):

  • see (Symbol)

    above



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/robust_excel_ole/workbook.rb', line 150

def initialize(file_or_workbook, opts)
  if file_or_workbook.is_a? WIN32OLE
    @ole_workbook = file_or_workbook
    ole_excel = begin 
      @ole_workbook.Application
    rescue WIN32OLERuntimeError
      raise ExcelREOError, 'could not determine the Excel instance'
    end
    @excel = excel_class.new(ole_excel)
    filename = @ole_workbook.Fullname.tr('\\','/') 
  else
    filename = file_or_workbook            
    ensure_workbook(filename, opts)        
  end      
  apply_options(filename, opts)
  store_myself
  if block_given?
    begin
      yield self
    ensure
      close
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
# File 'lib/robust_excel_ole/workbook.rb', line 1045

def method_missing(name, *args) 
  if name.to_s[0,1] =~ /[A-Z]/
    raise ObjectNotAlive, 'method missing: workbook not alive' unless alive?
    if ::ERRORMESSAGE_JRUBY_BUG 
      begin
        @ole_workbook.send(name, *args)
      rescue Java::OrgRacobCom::ComFailException 
        raise VBAMethodMissingError, "unknown VBA property or method #{name.inspect}"
      end
    else
      begin
        @ole_workbook.send(name, *args)
      rescue NoMethodError 
        raise VBAMethodMissingError, "unknown VBA property or method #{name.inspect}"
      end
    end
  else
    super
  end
end

Instance Attribute Details

#excelObject (readonly)

Returns the value of attribute excel



17
18
19
# File 'lib/robust_excel_ole/workbook.rb', line 17

def excel
  @excel
end

#ole_workbookObject (readonly)

include General



16
17
18
# File 'lib/robust_excel_ole/workbook.rb', line 16

def ole_workbook
  @ole_workbook
end

#stored_filenameObject (readonly)

Returns the value of attribute stored_filename



18
19
20
# File 'lib/robust_excel_ole/workbook.rb', line 18

def stored_filename
  @stored_filename
end

Class Method Details

.close(file, opts = {:if_unsaved => :raise}) ⇒ Object

closes a given file if it is open



755
756
757
758
759
760
761
762
# File 'lib/robust_excel_ole/workbook.rb', line 755

def self.close(file, opts = {:if_unsaved => :raise})
  book = begin
    bookstore.fetch(file)
    rescue
      nil
    end
  book.close(opts) if book && book.alive?
end

.create(filename, opts = { }) ⇒ Object

creates, i.e., opens a new, empty workbook, and saves it under a given filename

Parameters:

  • filename (String)

    the filename under which the new workbook should be saved

  • opts (Hash) (defaults to: { })

    the options as in Workbook::open



482
483
484
# File 'lib/robust_excel_ole/workbook.rb', line 482

def self.create(filename, opts = { })
  open(filename, :if_absent => :create)
end

.for_modifying(arg, opts = { }, &block) ⇒ Object



553
554
555
# File 'lib/robust_excel_ole/workbook.rb', line 553

def self.for_modifying(arg, opts = { }, &block)
  unobtrusively(arg, {:writable => true}.merge(opts), &block)
end

.for_reading(arg, opts = { }, &block) ⇒ Object



549
550
551
# File 'lib/robust_excel_ole/workbook.rb', line 549

def self.for_reading(arg, opts = { }, &block)
  unobtrusively(arg, {:writable => false}.merge(opts), &block)
end

.new(file_or_workbook, opts = { }) ⇒ Workbook

opens a workbook. options: :default : if the workbook was already open before, then use (unchange) its properties,

otherwise, i.e. if the workbook cannot be reopened, use the properties stated in :default

:force : no matter whether the workbook was already open before, use the properties stated in :force :default and :force contain: :excel

:excel   :current (or :active or :reuse)
                  -> connects to a running (the first opened) Excel instance,
                     excluding the hidden Excel instance, if it exists,
                     otherwise opens in a new Excel instance.
         :new     -> opens in a new Excel instance
         <excel-instance> -> opens in the given Excel instance
:visible true, false, or nil (default)
alternatives: :default_excel, :force_excel, :visible, :d, :f, :e, :v

:if_unsaved if an unsaved workbook with the same name is open, then

:raise               -> raises an exception
:forget              -> close the unsaved workbook, open the new workbook
:accept              -> lets the unsaved workbook open
:alert or :excel     -> gives control to Excel
:new_excel           -> opens the new workbook in a new Excel instance

:if_obstructed if a workbook with the same name in a different path is open, then or :raise -> raises an exception :if_blocked :forget -> closes the old workbook, open the new workbook

:save                -> saves the old workbook, close it, open the new workbook
:close_if_saved      -> closes the old workbook and open the new workbook, if the old workbook is saved,
                        otherwise raises an exception.
:new_excel           -> opens the new workbook in a new Excel instance

:if_absent :raise -> raises an exception , if the file does not exists

:create              -> creates a new Excel file, if it does not exists

:read_only true -> opens in read-only mode :visible true -> makes the workbook visible :check_compatibility true -> check compatibility when saving :update_links true -> user is being asked how to update links, false -> links are never updated

Parameters:

  • file_or_workbook (String)

    a file name or WIN32OLE workbook

  • opts (Hash) (defaults to: { })

    the options

Options Hash (opts):

  • :default (Hash)

    or :d

  • :force (Hash)

    or :f

  • :if_unsaved (Symbol)

    :raise (default), :forget, :save, :accept, :alert, :excel, or :new_excel

  • :if_blocked (Symbol)

    :raise (default), :forget, :save, :close_if_saved, or _new_excel

  • :if_absent (Symbol)

    :raise (default) or :create

  • :read_only (Boolean)

    true (default) or false

  • :update_links (Boolean)

    :never (default), :always, :alert

  • :calculation (Boolean)

    :manual, :automatic, or nil (default)

Returns:

  • (Workbook)

    a representation of a workbook



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/robust_excel_ole/workbook.rb', line 88

def self.new(file_or_workbook, opts = { })
  process_options(opts)
  case file_or_workbook
  when NilClass
    raise FileNameNotGiven, 'filename is nil' 
  when WIN32OLE
    file = file_or_workbook.Fullname.tr('\\','/') 
  when Workbook
    file = file_or_workbook.Fullname.tr('\\','/')
  when String
    file = file_or_workbook
    raise FileNotFound, "file #{General.absolute_path(file).inspect} is a directory" if File.directory?(file)
  when ->(n){ n.respond_to? :to_path }
    file = file_or_workbook.to_path
    raise FileNotFound, "file #{General.absolute_path(file).inspect} is a directory" if File.directory?(file)
  else
    raise TypeREOError, 'given object is neither a filename, a Win32ole, nor a Workbook object'
  end
  # try to fetch the workbook from the bookstore
  set_was_open opts, file_or_workbook.is_a?(WIN32OLE)
  book = nil
  if opts[:force][:excel] != :new
    # if readonly is true, then prefer a book that is given in force_excel if this option is set              
    forced_excel = begin
      (opts[:force][:excel].nil? || opts[:force][:excel] == :current) ? 
        (excel_class.new(:reuse => true) if !::CONNECT_JRUBY_BUG) : opts[:force][:excel].to_reo.excel
    rescue NoMethodError
      raise TypeREOError, "provided Excel option value is neither an Excel object nor a valid option"
    end
    begin
      book = if File.exists?(file)
        bookstore.fetch(file, :prefer_writable => !(opts[:read_only]),
                              :prefer_excel    => (opts[:read_only] ? forced_excel : nil))
      end
    rescue
      raise
      #trace "#{$!.message}"
    end
    if book 
      set_was_open opts, book.alive?
      # drop the fetched workbook if it shall be opened in another Excel instance
      # or the workbook is an unsaved workbook that should not be accepted
      if (opts[:force][:excel].nil? || opts[:force][:excel] == :current || forced_excel == book.excel) &&
        !(book.alive? && !book.saved && (opts[:if_unsaved] != :accept))
        opts[:force][:excel] = book.excel if book.excel && book.excel.alive?
        book.ensure_workbook(file,opts)
        book.send :apply_options, file, opts
        return book
      end
    end
  end        
  super(file_or_workbook, opts)
end

.process_options(opts, proc_opts = {:use_defaults => true}) ⇒ Object



185
186
187
188
189
190
# File 'lib/robust_excel_ole/workbook.rb', line 185

def self.process_options(opts, proc_opts = {:use_defaults => true})
  translate(opts)
  default_opts = (proc_opts[:use_defaults] ? DEFAULT_OPEN_OPTS : CORE_DEFAULT_OPEN_OPTS).dup
  translate(default_opts)
  opts.merge!(default_opts) { |key, v1, v2| !v2.is_a?(Hash) ? v1 : v2.merge(v1 || {}) }
end

.save(file) ⇒ Object

saves a given file if it is open



765
766
767
768
# File 'lib/robust_excel_ole/workbook.rb', line 765

def self.save(file)
  book = bookstore.fetch(file) rescue nil
  book.save if book && book.alive?
end

.save_as(file, new_file, opts = { }) ⇒ Object

saves a given file under a new name if it is open



771
772
773
774
775
776
777
778
# File 'lib/robust_excel_ole/workbook.rb', line 771

def self.save_as(file, new_file, opts = { })
  book = begin
    bookstore.fetch(file)
  rescue 
    nil
  end
  book.save_as(new_file, opts) if book && book.alive?
end

.set_was_open(hash, value) ⇒ Object



177
178
179
# File 'lib/robust_excel_ole/workbook.rb', line 177

def self.set_was_open(hash, value)
  hash[:was_open] = value if hash.has_key?(:was_open)
end

.translate(opts) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/robust_excel_ole/workbook.rb', line 192

def self.translate(opts)
  erg = {}
  opts.each do |key,value|
    new_key = key
    ABBREVIATIONS.each { |long,short| new_key = long if key == short }
    if value.is_a?(Hash)
      erg[new_key] = {}
      value.each do |k,v|
        new_k = k
        ABBREVIATIONS.each { |l,s| new_k = l if k == s }
        erg[new_key][new_k] = v
      end
    else
      erg[new_key] = value
    end
  end
  opts.merge!(erg)
  opts[:default] ||= {}
  opts[:force] ||= {}
  force_list = [:visible, :excel]
  opts.each { |key,value| opts[:force][key] = value if force_list.include?(key) }
  opts[:default][:excel] = opts[:default_excel] unless opts[:default_excel].nil?
  opts[:force][:excel] = opts[:force_excel] unless opts[:force_excel].nil?
  opts[:default][:excel] = :current if opts[:default][:excel] == :reuse || opts[:default][:excel] == :active
  opts[:force][:excel] = :current if opts[:force][:excel] == :reuse || opts[:force][:excel] == :active
end

.unobtrusively(file_or_workbook, opts = { }, &block) ⇒ Workbook

allows to read or modify a workbook such that its state remains unchanged state comprises: open, saved, writable, visible, calculation mode, check compatibility

Parameters:

  • file_or_workbook (String)

    a file name or WIN32OLE workbook

  • opts (Hash) (defaults to: { })

    the options

Options Hash (opts):

  • :if_closed (Variant)

    :current (default), :new or an Excel instance

  • :read_only (Boolean)

    true/false (default), open the workbook in read-only/read-write modus (save changes)

  • :writable (Boolean)

    true (default)/false changes of the workbook shall be saved/not saved

  • :keep_open (Boolean)

    whether the workbook shall be kept open after unobtrusively opening (default: false)

Returns:



566
567
568
569
# File 'lib/robust_excel_ole/workbook.rb', line 566

def self.unobtrusively(file_or_workbook, opts = { }, &block)
  file = (file_or_workbook.is_a? WIN32OLE) ? file_or_workbook.Fullname.tr('\\','/') : file_or_workbook
  unobtrusively_opening(file, opts, nil, &block)
end

Instance Method Details

#==(other_book) ⇒ Boolean

Returns true, if the full workbook names and excel Instances are identical, false otherwise.

Returns:

  • (Boolean)

    true, if the full workbook names and excel Instances are identical, false otherwise



974
975
976
977
978
# File 'lib/robust_excel_ole/workbook.rb', line 974

def == other_book
  other_book.is_a?(Workbook) &&
    @excel == other_book.excel &&
    self.filename == other_book.filename
end

#[](name) ⇒ Object

returns the value of a range

Parameters:

  • name (String)

    the name of a range



887
888
889
# File 'lib/robust_excel_ole/workbook.rb', line 887

def [] name
  namevalue_glob(name)
end

#[]=(name, value) ⇒ Object

sets the value of a range

Parameters:

  • name (String)

    the name of the range

  • value (Variant)

    the contents of the range



894
895
896
# File 'lib/robust_excel_ole/workbook.rb', line 894

def []= (name, value)
  set_namevalue_glob(name, value, :color => 42)   
end

#add_or_copy_sheet(sheet = nil, opts = { }) ⇒ Worksheet

copies a sheet to another position if a sheet is given, or adds an empty sheet default: copied or empty sheet is appended, i.e. added behind the last sheet

Parameters:

  • sheet (Worksheet) (defaults to: nil)

    a sheet that shall be copied (optional)

  • opts (Hash) (defaults to: { })

    the options

Options Hash (opts):

  • :as (Symbol)

    new name of the copied or added sheet

  • :before (Symbol)

    a sheet before which the sheet shall be inserted

  • :after (Symbol)

    a sheet after which the sheet shall be inserted

Returns:



821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
# File 'lib/robust_excel_ole/workbook.rb', line 821

def add_or_copy_sheet(sheet = nil, opts = { })
  if sheet.is_a? Hash
    opts = sheet
    sheet = nil
  end
  new_sheet_name = opts.delete(:as)
  last_sheet_local = last_sheet
  after_or_before, base_sheet = opts.to_a.first || [:after, last_sheet_local]
  base_sheet_ole = base_sheet.ole_worksheet
  begin
    if !::COPYSHEETS_JRUBY_BUG          
      add_or_copy_sheet_simple(sheet, { after_or_before.to_s => base_sheet_ole })
    else
      if after_or_before == :before 
        add_or_copy_sheet_simple(sheet, base_sheet_ole)
      else
        if base_sheet.name != last_sheet_local.name
          add_or_copy_sheet_simple(sheet, base_sheet.Next)
        else
          add_or_copy_sheet_simple(sheet, base_sheet_ole)
          base_sheet.Move(ole_workbook.Worksheets.Item(ole_workbook.Worksheets.Count-1))
          ole_workbook.Worksheets.Item(ole_workbook.Worksheets.Count).Activate
        end
      end
    end
  rescue WIN32OLERuntimeError, NameNotFound, Java::OrgRacobCom::ComFailException
    raise WorksheetREOError, "could not add given worksheet #{sheet.inspect}"
  end
  new_sheet = worksheet_class.new(ole_workbook.Activesheet)
  new_sheet.name = new_sheet_name if new_sheet_name
  new_sheet
end

#add_sheet(sheet = nil, opts = { }) ⇒ Object

for compatibility to older versions



867
868
869
# File 'lib/robust_excel_ole/workbook.rb', line 867

def add_sheet(sheet = nil, opts = { })
  add_or_copy_sheet(sheet, opts)
end

#alive?Boolean

returns true, if the workbook reacts to methods, false otherwise

Returns:

  • (Boolean)


914
915
916
917
918
919
920
# File 'lib/robust_excel_ole/workbook.rb', line 914

def alive?
  @ole_workbook.Name
  true
rescue
  @ole_workbook = nil  # dead object won't be alive again
  false
end

#calculationObject



937
938
939
# File 'lib/robust_excel_ole/workbook.rb', line 937

def calculation
  @excel.properties[:calculation] if @ole_workbook
end

#close(opts = {:if_unsaved => :raise}) ⇒ Object

closes the workbook, if it is alive options:

:if_unsaved    if the workbook is unsaved
                    :raise           -> raises an exception
                    :save            -> saves the workbook before it is closed
                    :forget          -> closes the workbook
                    :keep_open       -> keep the workbook open
                    :alert or :excel -> gives control to excel

Parameters:

  • opts (Hash) (defaults to: {:if_unsaved => :raise})

    the options

Options Hash (opts):

  • :if_unsaved (Symbol)

    :raise (default), :save, :forget, :keep_open, or :alert

Raises:

  • WorkbookNotSaved if the option :if_unsaved is :raise and the workbook is unsaved

  • OptionInvalid if the options is invalid



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/robust_excel_ole/workbook.rb', line 498

def close(opts = {:if_unsaved => :raise})
  if alive? && !@ole_workbook.Saved && writable
    case opts[:if_unsaved]
    when :raise
      raise WorkbookNotSaved, "workbook is unsaved: #{File.basename(self.stored_filename).inspect}" +
      "\nHint: Use option :save or :forget to close the workbook with or without saving"
    when :save
      save
      close_workbook
    when :forget
      @excel.with_displayalerts(false) { close_workbook }
    when :keep_open
      # nothing
    when :alert, :excel
      @excel.with_displayalerts(true) { close_workbook }
    else
      raise OptionInvalid, ":if_unsaved: invalid option: #{opts[:if_unsaved].inspect}" +
      "\nHint: Valid values are :raise, :save, :keep_open, :alert, :excel"
    end
  else
    close_workbook
  end
end

#copy_sheet(sheet, opts = { }) ⇒ Object

for compatibility to older versions



872
873
874
# File 'lib/robust_excel_ole/workbook.rb', line 872

def copy_sheet(sheet, opts = { })
  add_or_copy_sheet(sheet, opts)
end

#eachObject



793
794
795
796
797
# File 'lib/robust_excel_ole/workbook.rb', line 793

def each
  @ole_workbook.Worksheets.each do |sheet|
    yield worksheet_class.new(sheet)
  end
end

#each_with_index(offset = 0) ⇒ Object



805
806
807
808
809
810
811
# File 'lib/robust_excel_ole/workbook.rb', line 805

def each_with_index(offset = 0)
  i = offset
  @ole_workbook.Worksheets.each do |sheet|
    yield worksheet_class.new(sheet), i
    i += 1
  end
end

#filenameObject

returns the full file name of the workbook



923
924
925
# File 'lib/robust_excel_ole/workbook.rb', line 923

def filename
  @ole_workbook.Fullname.tr('\\','/') rescue nil
end

#first_sheetObject



880
881
882
# File 'lib/robust_excel_ole/workbook.rb', line 880

def first_sheet
  worksheet_class.new(@ole_workbook.Worksheets.Item(1))
end

#focusObject

brings workbook to foreground, makes it available for heyboard inputs, makes the Excel instance visible



907
908
909
910
911
# File 'lib/robust_excel_ole/workbook.rb', line 907

def focus
  self.visible = true
  @excel.focus
  @ole_workbook.Activate
end

#for_modifying(opts = { }, &block) ⇒ Object



545
546
547
# File 'lib/robust_excel_ole/workbook.rb', line 545

def for_modifying(opts = { }, &block)
  unobtrusively({:writable => true}.merge(opts), &block)
end

#for_reading(opts = { }, &block) ⇒ Object



541
542
543
# File 'lib/robust_excel_ole/workbook.rb', line 541

def for_reading(opts = { }, &block)
  unobtrusively({:writable => false}.merge(opts), &block)
end

#for_this_workbook(opts) ⇒ Object

sets options

Parameters:

  • opts (Hash)


900
901
902
903
904
# File 'lib/robust_excel_ole/workbook.rb', line 900

def for_this_workbook(opts)
  return unless alive?
  self.class.process_options(opts, :use_defaults => false)
  self.send :apply_options, @stored_filename, opts
end

#last_sheetObject



876
877
878
# File 'lib/robust_excel_ole/workbook.rb', line 876

def last_sheet
  worksheet_class.new(@ole_workbook.Worksheets.Item(@ole_workbook.Worksheets.Count))
end

#retain_savedObject

keeps the saved-status unchanged



532
533
534
535
536
537
538
539
# File 'lib/robust_excel_ole/workbook.rb', line 532

def retain_saved
  saved = self.Saved
  begin
    yield self
  ensure
    self.Saved = saved
  end
end

#set_was_open(hash, value) ⇒ Object



181
182
183
# File 'lib/robust_excel_ole/workbook.rb', line 181

def set_was_open(hash, value)
  self.class.set_was_open(hash, value)
end

#sheet(name) ⇒ Object

returns a sheet, if a sheet name or a number is given

Parameters:

  • or (String)
    Number

Raises:

  • (NameNotFound)


783
784
785
786
787
# File 'lib/robust_excel_ole/workbook.rb', line 783

def sheet(name)
  worksheet_class.new(@ole_workbook.Worksheets.Item(name))
rescue WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException => msg
  raise NameNotFound, "could not return a sheet with name #{name.inspect}"
end

#unobtrusively(opts = { }, &block) ⇒ Object



571
572
573
574
# File 'lib/robust_excel_ole/workbook.rb', line 571

def unobtrusively(opts = { }, &block)
  file = @stored_filename
  self.class.unobtrusively_opening(file, opts, alive?, &block)
end

#visibleObject

returns true, if the workbook is visible, false otherwise



947
948
949
# File 'lib/robust_excel_ole/workbook.rb', line 947

def visible
  @excel.Visible && @ole_workbook.Windows(@ole_workbook.Name).Visible
end

#visible=(visible_value) ⇒ Object

makes both the Excel instance and the window of the workbook visible, or the window invisible does not do anything if geben visible_value is nil

Parameters:

  • visible_value (Boolean)

    determines whether the workbook shall be visible



954
955
956
957
958
# File 'lib/robust_excel_ole/workbook.rb', line 954

def visible= visible_value
  return if visible_value.nil?
  @excel.visible = true if visible_value
  self.window_visible = @excel.Visible ? visible_value : true
end

#window_visibleObject

returns true, if the window of the workbook is set to visible, false otherwise



961
962
963
# File 'lib/robust_excel_ole/workbook.rb', line 961

def window_visible
  @ole_workbook.Windows(@ole_workbook.Name).Visible
end

#window_visible=(visible_value) ⇒ Object

makes the window of the workbook visible or invisible

Parameters:

  • visible_value (Boolean)

    determines whether the window of the workbook shall be visible



967
968
969
970
971
# File 'lib/robust_excel_ole/workbook.rb', line 967

def window_visible= visible_value
  retain_saved do
    @ole_workbook.Windows(@ole_workbook.Name).Visible = visible_value if @ole_workbook.Windows.Count > 0
  end
end

#worksheetsObject



799
800
801
802
803
# File 'lib/robust_excel_ole/workbook.rb', line 799

def worksheets
  result = []
  each { |worksheet| result << worksheet }   
  result
end

#worksheets_countObject



789
790
791
# File 'lib/robust_excel_ole/workbook.rb', line 789

def worksheets_count
  @ole_workbook.Worksheets.Count
end