module Sinatra::WriteExcel::Helpers

Public Instance Methods

writeexcel(template = nil, options = {}, locals = {}, &block) click to toggle source
# 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=#{options[: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