Module: RubyXL::LegacyWorksheet
Instance Method Summary collapse
-
#[](row = 0) ⇒ Object
allows for easier access to sheet_data.
- #add_cell(row_index = 0, column_index = 0, data = '', formula = nil, overwrite = true) ⇒ Object
- #add_row(row_index = 0, params = {}) ⇒ Object
- #each ⇒ Object
- #initialize(params = {}) ⇒ Object
Instance Method Details
#[](row = 0) ⇒ Object
allows for easier access to sheet_data
18 19 20 |
# File 'lib/rubyXL/worksheet.rb', line 18 def [](row = 0) sheet_data[row] end |
#add_cell(row_index = 0, column_index = 0, data = '', formula = nil, overwrite = true) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rubyXL/worksheet.rb', line 32 def add_cell(row_index = 0, column_index = 0, data = '', formula = nil, overwrite = true) validate_workbook validate_nonnegative(row_index) validate_nonnegative(column_index) row = sheet_data.rows[row_index] || add_row(row_index) c = row.cells[column_index] if overwrite || c.nil? c = RubyXL::Cell.new c.worksheet = self c.row = row_index c.column = column_index c.raw_value = data c.datatype = RubyXL::DataType::RAW_STRING unless formula || data.is_a?(Numeric) c.formula = RubyXL::Formula.new(:expression => formula) if formula range = cols && cols.locate_range(column_index) c.style_index = row.style_index || (range && range.style_index) || 0 row.cells[column_index] = c end c end |
#add_row(row_index = 0, params = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/rubyXL/worksheet.rb', line 26 def add_row(row_index = 0, params = {}) new_row = RubyXL::Row.new(params) new_row.worksheet = self sheet_data.rows[row_index] = new_row end |
#each ⇒ Object
22 23 24 |
# File 'lib/rubyXL/worksheet.rb', line 22 def each sheet_data.rows.each { |row| yield(row) } end |
#initialize(params = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rubyXL/worksheet.rb', line 5 def initialize(params = {}) super self.workbook = params[:workbook] self.sheet_name = params[:sheet_name] self.sheet_id = params[:sheet_id] self.sheet_data = RubyXL::SheetData.new self.cols = RubyXL::ColumnRanges.new @comments = [] # Do not optimize! These are arrays, so they will share the pointer! @printer_settings = [] @generic_storage = [] end |