# in a controller
def show
@operation = @account.operations.find(params[:id])
report = OperationReport.new
output = report.to_pdf(@operation)
respond_to do |format|
format.pdf do
send_data output, type: :pdf, disposition: "inline"
end
end
end
# comments_controller.rb
def index
@comments = @commentable.comments
book = ExcelReport.new(@comments).export
file_contents = StringIO.new
book.write file_contents
respond_to do |format|
format.xls do
send_data file_contents.string, type: 'application/vnd.ms-excel', filename: 'comments.xls'
end
end
end
Mime::Type.register "application/vnd.ms-excel", :xls