Class: ExcelSerializer::Worksheet
- Inherits:
-
Object
- Object
- ExcelSerializer::Worksheet
- Defined in:
- lib/excel_serializer/worksheet.rb
Instance Attribute Summary collapse
-
#row_counter ⇒ Object
Returns the value of attribute row_counter.
-
#sheet ⇒ Object
Returns the value of attribute sheet.
Instance Method Summary collapse
-
#initialize(current_excel, sheet_name) ⇒ Worksheet
constructor
A new instance of Worksheet.
- #write_headers(headers) ⇒ Object
- #write_row(row) ⇒ Object
Constructor Details
#initialize(current_excel, sheet_name) ⇒ Worksheet
Returns a new instance of Worksheet.
5 6 7 8 |
# File 'lib/excel_serializer/worksheet.rb', line 5 def initialize(current_excel, sheet_name) @sheet = current_excel.add_worksheet(sheet_name) @row_counter = 0 end |
Instance Attribute Details
#row_counter ⇒ Object
Returns the value of attribute row_counter.
3 4 5 |
# File 'lib/excel_serializer/worksheet.rb', line 3 def row_counter @row_counter end |
#sheet ⇒ Object
Returns the value of attribute sheet.
3 4 5 |
# File 'lib/excel_serializer/worksheet.rb', line 3 def sheet @sheet end |
Instance Method Details
#write_headers(headers) ⇒ Object
17 18 19 20 21 |
# File 'lib/excel_serializer/worksheet.rb', line 17 def write_headers(headers) headers.each_with_index do |value, current_column| @sheet.write(0, current_column, value) end end |
#write_row(row) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/excel_serializer/worksheet.rb', line 10 def write_row(row) row_index = @row_counter += 1 row.each_with_index do |value, current_column| @sheet.write(row_index, current_column, value) end end |