Sha256: 5124695b99d25fab9cee4046b935a14a116dbb7e582e0859115a53dc103216d9
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
unless defined? Mime::XLS Mime::Type.register "application/vnd.ms-excel", :xls end # CloudXLSRails::XLSResponder module CloudXLSRails class XLSResponder def self.redirect!(controller, scope, options) columns = options.fetch(:columns, nil) xdata = options[:data] || {} unless (xdata.has_key?(:text) || xdata.has_key?(:url ) || xdata.has_key?(:file) ) xdata[:text] = CloudXLS::CSVWriter.text(scope, {:columns => columns}) end xopts = {:data => xdata} xopts[:sheet] = options[:sheet] if options[:sheet] xopts[:doc] = options[:doc] if options[:doc] response = CloudXLS.xpipe(xopts) controller.redirect_to response.url end end end # For respond_to default class ActionController::Responder def to_xls if options[:stream] == true options[:data] ||= {} options[:data][:url] ||= controller.request.url.gsub(/xls\Z/, "csv") end CloudXLSRails::XLSResponder.redirect!(controller, resources.last, options) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cloudxls-rails-0.4.2 | lib/cloudxls-rails/handlers/xls.rb |