Class: Excel::WorkSheet
- Inherits:
-
Object
- Object
- Excel::WorkSheet
- Defined in:
- lib/Excel/worksheet.rb
Class Method Summary collapse
- .get_cell_value(cell) ⇒ Object
- .get_values_in_range(from, to) ⇒ Object
- .new(wb, ws_name) ⇒ Object
- .set_cell_value(cell, value) ⇒ Object
Class Method Details
.get_cell_value(cell) ⇒ Object
16 17 18 |
# File 'lib/Excel/worksheet.rb', line 16 def self.get_cell_value(cell) @workbook.app_object.workbooks[@workbook.workbook_name].worksheets[@worksheet_name].cells[cell].value.get end |
.get_values_in_range(from, to) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/Excel/worksheet.rb', line 20 def self.get_values_in_range(from, to) from = from.match(/^([a-zA-Z]+)([0-9]+)$/) from = {column: from[1], row: from[2].to_i} to = to.match(/^([a-zA-Z]+)([0-9]+)$/) to = {column: to[1], row: to[2].to_i} return_hash = Hash.new{|h,k| h[k] = Hash.new} (from[:column]..to[:column]).each do |column| (from[:row]..to[:row]).each do |row| return_hash[column][row] = get_cell_value("#{column}#{row}") end end return_hash end |
.new(wb, ws_name) ⇒ Object
6 7 8 9 10 |
# File 'lib/Excel/worksheet.rb', line 6 def self.new(wb, ws_name) @workbook = wb @worksheet_name = ws_name self end |
.set_cell_value(cell, value) ⇒ Object
12 13 14 |
# File 'lib/Excel/worksheet.rb', line 12 def self.set_cell_value(cell, value) @workbook.app_object.set(@workbook.app_object.workbooks[@workbook.workbook_name].worksheets[@worksheet_name].cells[cell].value, {:to => value}) end |