Create Excel file in Ruby on Rails with Axlsx
NickName:Drextor Ask DateTime:2016-05-30T17:58:23

Create Excel file in Ruby on Rails with Axlsx

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

More about “Create Excel file in Ruby on Rails with Axlsx” related questions

Issue with opening the generated file in MS Excel using axlsx_rails

I am using axlsx_rails in my Rails project to generate an excel file with validations and dropdowns. After generating the File, I tried to open the file in MS Excel and it said that it needs to rep...

Show Detail

Create Excel file in Ruby on Rails with Axlsx

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

Show Detail

axlsx / axlsx_rails dependancy / conflict issues

I am trying to add simple Excel file downloads to my Rails app with https://github.com/randym/axlsx and https://github.com/straydogstudio/axlsx_rails but I can't seem to get the dependancies sorted...

Show Detail

How to set auto width of Excel columns using axlsx gem in Ruby on rails

Is there a way to set the column width to adjust based on the text length for all the columns in an excel (that is generated using the axlsx gem in Ruby on rails)? Please help!

Show Detail

UTF-8 error when generating Excel file using axlsx gem

I am trying to use the axlsx gem to generate an Excel file. This is a Ruby Rails application where the user views a report in the browser and can click a link to export the data to Excel. However...

Show Detail

Include canvas to generated file from axlsx rails gem

Not to be confused with this, is there a way to include canvas element into excel file generated by axls_rails gem? I've been digging around axls_rails gem documentation and stackoverflow, still ha...

Show Detail

Generating Password protected excel file in Ruby Rails

Is it possible to create a password protected Excel file in Ruby. The following Gem: https://github.com/randym/axlsx helps in "write-protecting" a cell with Password. However, the requirement is t...

Show Detail

Axlsx performance reduction after rails 5.2 upgrade

I was using axlsx to create a workbook , stream and write to a downloadable xlsx file with rails 4.2. It used to take less than 60 seconds to create a downloadable xlsx file with 40,000 records, al...

Show Detail

Using axlsx partials

I am using axlxs and axlsx_rails. I can create inline spreadsheets no problem - for example I have an index.xlsx.axlsx file etc. The problem is I have another action the uses the exact same code ...

Show Detail

Unable to freeze the header pane using axlsx with Rails

I am Using the Axlsx gem with rails to create the Excel sheet. I need the header to be fixed and frozen. The header to should be always visible even we scroll down. rails version 3.2.1 gem 'axlsx' ...

Show Detail