Sha256: ccf04581d1869af65f45c89774390c621b1bded7b66e7230bfc48a44c427edc9
Contents?: true
Size: 604 Bytes
Versions: 2
Compression:
Stored size: 604 Bytes
Contents
require 'axlsx' module Dumpster module Excel class Writer def initialize(model) @model = model end def write_to_string file = Tempfile.new('dumpster_excel_export.xlsx') write_to_file(file.path) File.read(file.path) end def write_to_file(path) package = Axlsx::Package.new workbook = package.workbook workbook.add_worksheet(:name => "Worksheet 1") do |sheet| @model.each do |row| sheet.add_row(row) end end package.serialize(path) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dumpster-0.3.0 | lib/dumpster/excel.rb |
dumpster-0.2.0 | lib/dumpster/excel.rb |