Class: NeatSpreadsheet::Helpers::Sheet
- Inherits:
-
Object
- Object
- NeatSpreadsheet::Helpers::Sheet
- Defined in:
- lib/neat-spreadsheet/helpers/sheet.rb
Instance Method Summary collapse
- #cell(value, options = {}) ⇒ Object
-
#initialize(workbook, options = {}) {|_self| ... } ⇒ Sheet
constructor
A new instance of Sheet.
- #row(options = {}) {|_self| ... } ⇒ Object
- #skip_cell ⇒ Object
- #skip_cells(nb) ⇒ Object
- #skip_row ⇒ Object
- #spacer(options = {}) ⇒ Object
Constructor Details
#initialize(workbook, options = {}) {|_self| ... } ⇒ Sheet
Returns a new instance of Sheet.
3 4 5 6 7 8 9 10 11 |
# File 'lib/neat-spreadsheet/helpers/sheet.rb', line 3 def initialize(workbook, ={}, &block) .reverse_merge! title: nil, columns_width: [10, 10, 10, 10, 10] init_sheet workbook, [:title] init_columns [:columns_width] init_styles yield self end |
Instance Method Details
#cell(value, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/neat-spreadsheet/helpers/sheet.rb', line 13 def cell(value, ={}) if [:colspan] [:horizontal_align] = :merge (@column_position..(@column_position+[:colspan]-1)).each do |i| current_row.set_format(i, current_format()) end else current_row.set_format(@column_position, current_format()) end set_current_column value @column_position += 1 end |
#row(options = {}) {|_self| ... } ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/neat-spreadsheet/helpers/sheet.rb', line 29 def row(={}, &block) .reverse_merge! height: nil, start_at_column: 0, style: :normal @column_position = 0 set_current_style [:style] set_current_height [:height] (0..[:start_at_column]-1).each { |i| cell(' ') } if [:start_at_column] > 0 yield self @row_position += 1 end |
#skip_cell ⇒ Object
44 45 46 |
# File 'lib/neat-spreadsheet/helpers/sheet.rb', line 44 def skip_cell skip_cells 1 end |
#skip_cells(nb) ⇒ Object
48 49 50 |
# File 'lib/neat-spreadsheet/helpers/sheet.rb', line 48 def skip_cells(nb) (@column_position..(@column_position+nb-1)).each { |i| cell(' ') } end |
#skip_row ⇒ Object
52 53 54 |
# File 'lib/neat-spreadsheet/helpers/sheet.rb', line 52 def skip_row @row_position += 1 end |
#spacer(options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/neat-spreadsheet/helpers/sheet.rb', line 56 def spacer(={}) .reverse_merge! height: 20 @column_position = 0 current_row.height = [:height] (0..@total_columns-1).each { |i| current_row.set_format(i, Spreadsheet::Format.new(horizontal_align: :merge)) } set_current_column ' ' @row_position += 1 end |