Method: ExcelAbstraction::Sheet#cell

Defined in:
lib/excel_templating/excel_abstraction/sheet.rb

#cell(value, format: nil, type: :auto, **options) ⇒ Object

Fills the cell at the current pointer with the value and format or options specified

Parameters:

  • value (Object)

    Value to place in the cell.

  • options (Object)

    (optional) options to create a format object

  • format (Object) (defaults to: nil)

    (optional) The format to use when creating this cell



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/excel_templating/excel_abstraction/sheet.rb', line 25

def cell(value, format: nil, type: :auto, **options)
  format = format || _format(options)
  value = Float(value) if value.is_a?(ExcelAbstraction::Time) || value.is_a?(ExcelAbstraction::Date)

  writer = case type
           when :string then method(:write_string)
           else method(:write)
           end

  writer.call(active_cell_reference.row, active_cell_reference.col, value, format)

  if options[:new_row]
    next_row
  else
    active_cell_reference.right
  end
  self
end