class Xlsxtream::Worksheet

Public Class Methods

new(io, options = {}) click to toggle source
# File lib/xlsxtream/worksheet.rb, line 7
def initialize(io, options = {})
  @io = io
  @rownum = 1
  @closed = false
  @options = options

  write_header
end

Public Instance Methods

<<(row) click to toggle source
# File lib/xlsxtream/worksheet.rb, line 16
def <<(row)
  @io << Row.new(row, @rownum, @options).to_xml
  @rownum += 1
end
Also aliased as: add_row
add_row(row)
Alias for: <<
close() click to toggle source
# File lib/xlsxtream/worksheet.rb, line 22
def close
  write_footer
  @closed = true
end
closed?() click to toggle source
# File lib/xlsxtream/worksheet.rb, line 27
def closed?
  @closed
end
id() click to toggle source
# File lib/xlsxtream/worksheet.rb, line 31
def id
  @options[:id]
end
name() click to toggle source
# File lib/xlsxtream/worksheet.rb, line 35
def name
  @options[:name]
end

Private Instance Methods

write_header() click to toggle source
# File lib/xlsxtream/worksheet.rb, line 41
    def write_header
      @io << XML.header
      @io << XML.strip(<<-XML)
        <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
      XML

      columns = Array(@options[:columns])
      unless columns.empty?
        @io << Columns.new(columns).to_xml
      end

      @io << XML.strip(<<-XML)
          <sheetData>
      XML
    end