I try to create Excel files with the gem "axlsx". But i work for the first time with this gem and i try one Test.
I make one link_to to an controller action.
There is no Error, but i didnt find a complete excel file.
Link_to :
<%= link_to "Test", { :controller => :orders, :action => :invoices_generate }, { class: "btn btn-primary btn-lg", style: "width: 100%;", format: 'xlsx'} %>
My Controller :
def invoices_generate
respond_to do |format|
format.xlsx
end
end
invoices_generate.xlsx.axlsx :
if examples.include? :basic
wb.add_worksheet(:name => "Basic Worksheet") do |sheet|
sheet.add_row ["First Column", "Second", "Third"]
sheet.add_row [1, 2, 3]
sheet.add_row [' preserving whitespace']
end
end
Copyright Notice:Content Author:「Drextor」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/37522759/create-excel-file-in-ruby-on-rails-with-axlsx