Module: Sinatra::WriteExcel::Helpers

Defined in:
lib/sinatra/writeexcel.rb

Instance Method Summary collapse

Instance Method Details

#writeexcel(template = nil, options = {}, locals = {}, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/sinatra/writeexcel.rb', line 7

def writeexcel(template = nil, options = {}, locals = {}, &block)
  headers(
    'Content-Type' => 'application/vnd.ms-excel',
    'Content-Disposition' => "attachment; filename=#{template}.xls"
  )
  options, template = template, nil if template.is_a?(Hash)
  template = -> { block } if template.nil?
  options[:layout] = false
  render :rxls, template, options, locals
end