Class: Dossier::Xls

Inherits:
Object
  • Object
show all
Defined in:
lib/dossier/xls.rb

Constant Summary collapse

HEADER =
%Q{<?xml version="1.0" encoding="UTF-8"?>\n<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">\n<Worksheet ss:Name="Sheet1">\n<Table>\n}
%Q{</Table>\n</Worksheet>\n</Workbook>\n}

Instance Method Summary collapse

Constructor Details

#initialize(collection, headers = nil) ⇒ Xls

Returns a new instance of Xls.



7
8
9
10
# File 'lib/dossier/xls.rb', line 7

def initialize(collection, headers = nil)
  @headers    = headers || collection.shift
  @collection = collection
end

Instance Method Details

#each {|HEADER| ... } ⇒ Object

Yields:



12
13
14
15
16
17
# 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