Class: Excelgrip::Worksheet

Inherits:
GripWrapper show all
Defined in:
lib/excelgrip.rb

Overview

Worksheet Class ==============

Instance Method Summary collapse

Methods inherited from GripWrapper

#initialize, #inspect, #raw

Constructor Details

This class inherits a constructor from Excelgrip::GripWrapper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Excelgrip::GripWrapper

Instance Method Details

#[](cell_1) ⇒ Object



177
178
179
180
181
182
183
# File 'lib/excelgrip.rb', line 177

def [](cell_1)
  begin
    range(cell_1)
  rescue WIN32OLERuntimeError
    raise $!,$!.message, caller
  end
end

#cells(v_pos, h_pos) ⇒ Object



168
169
170
171
172
173
174
175
# File 'lib/excelgrip.rb', line 168

def cells(v_pos, h_pos)
  begin
    raw_range = @raw_object.Cells(v_pos, h_pos)
  rescue WIN32OLERuntimeError
    raise $!,$!.message, caller
  end
  Range.new(raw_range)
end

#deleteObject



185
186
187
188
# File 'lib/excelgrip.rb', line 185

def delete
  @raw_object.delete
  @raw_object = nil
end

#name=(sheet_name) ⇒ Object



190
191
192
# File 'lib/excelgrip.rb', line 190

def name=(sheet_name)
  @raw_object.name = sheet_name
end

#parentObject



194
195
196
# File 'lib/excelgrip.rb', line 194

def parent
  Workbook.new(@raw_object.parent)
end

#range(cell_1, cell_2 = nil) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/excelgrip.rb', line 155

def range(cell_1, cell_2=nil)
  if cell_1.class == String
    begin
      raw_range = @raw_object.range(cell_1)
    rescue WIN32OLERuntimeError
      raise $!,$!.message, caller
    end
  else
    raw_range = @raw_object.range(cell_1.raw, cell_2.raw)
  end
  Range.new(raw_range)
end