Class: ReportGenerator
- Inherits:
-
Object
- Object
- ReportGenerator
- Defined in:
- lib/sinatra/extensions/report_generator.rb
Instance Method Summary collapse
Instance Method Details
#build(report_columns, query) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sinatra/extensions/report_generator.rb', line 4 def build(report_columns,query) workbook = RubyXL::Workbook.new worksheet = workbook[0] report_columns.each_with_index do |report_column, i| worksheet.add_cell(0, i, report_column.name) end query.all.each_with_index do |element, x| report_columns.each_with_index do |report_column, y| worksheet.add_cell(x+1, y, report_column.value(element)) end end IO.copy_stream(workbook.stream, out) end |