Sha256: d6040582a77d1667e72800002c7db1325036cdaf2a49e7b60081bb422812ee1c
Contents?: true
Size: 792 Bytes
Versions: 1
Compression:
Stored size: 792 Bytes
Contents
require 'action_controller' unless defined? Mime::XLSX Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx end ActionController::Renderers.add :xlsx do |filename, options| if filename =~ /^\/([^\/]+)\/(.+)$/ options[:prefixes][0] = $1 filename = $2 end options[:template] = filename disposition = options.delete(:disposition) || 'attachment' download_name = options.delete(:filename) || "#{filename}.xlsx" download_name += ".xlsx" unless download_name =~ /\.xlsx$/ send_data render_to_string(options), :filename => download_name, :type => Mime::XLSX, :disposition => disposition end # For respond_to default class ActionController::Responder def to_xlsx controller.render :xlsx => controller.action_name end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axlsx_rails-0.1.3 | lib/axlsx_rails/action_controller.rb |