class Dossier::Xls
Constants
- FOOTER
- HEADER
Public Class Methods
new(collection, headers = nil)
click to toggle source
# File lib/dossier/xls.rb, line 7 def initialize(collection, headers = nil) @headers = headers || collection.shift @collection = collection end
Public Instance Methods
each() { |HEADER| ... }
click to toggle source
# File lib/dossier/xls.rb, line 12 def each yield HEADER yield as_row(@headers) @collection.each { |record| yield as_row(record) } yield FOOTER end
Private Instance Methods
as_cell(el)
click to toggle source
# File lib/dossier/xls.rb, line 21 def as_cell(el) %{<Cell><Data ss:Type="String">#{el}</Data></Cell>} end
as_row(array)
click to toggle source
# File lib/dossier/xls.rb, line 25 def as_row(array) my_array = array.map{|a| as_cell(a)}.join("\n") "<Row>\n" + my_array + "\n</Row>\n" end