Sha256: 8dd49490b8404d195290c4cb57c4649b48cde35d590289aaa04768dd023cf78a
Contents?: true
Size: 895 Bytes
Versions: 1
Compression:
Stored size: 895 Bytes
Contents
unless defined? Mime::XLS Mime::Type.register "application/vnd.ms-excel", :xls end ActionController::Renderers.add :xls do |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) redirect_to response.url 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 controller.render({:xls => resources.last }.merge(options)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cloudxls-rails-0.4.1 | lib/cloudxls-rails/handlers/xls.rb |