Sha256: a25d37c46b86d2b9a6d6167658626fb69713337b8700c1297f77a95a5664ce68
Contents?: true
Size: 573 Bytes
Versions: 1
Compression:
Stored size: 573 Bytes
Contents
require 'spreadsheet' module Exporter class ExcelExporter < Exporter def process(data, options) raise TypeError.new unless is_active_record?(data, options) columns = options[:columns] || data[0].class.attribute_names book = Spreadsheet::Workbook.new sheet = book.create_worksheet sheet.name = options[:sheet_name] || 'sheet1' sheet.row(0).concat columns data.each_with_index do |row, index| sheet.row(index+1).concat row.attributes.values_at(*columns) end ExcelDocument.new(book) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exporter-0.1.0 | lib/exporter/exporters/excel_exporter.rb |