By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,302 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,302 IT Pros & Developers. It's quick & easy.

Exporting Information from Ruby on rails to a excel sheet.

P: 1
Hey,

Pretty new to this and I was asked to setup a application at work that stores all the information regarding all the systems in our lab. Long story short I have everything working apart form exporting the information to a excel sheet. I tried this http://www.napcsweb.com/blog/2007/01/24/excel-export-the-stupid-simple-way/#respond,
which seems very straight forward but i still come up with the error "wrong number of arguments". Any ideas on another way to do this? or a better guide to this.

thanks.
Gearoid
Jun 13 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 303
Without seeing your code, I don't know how to help you with your current error. However, this is what works for me.

I have defined the following method in my 'application' controller:

Expand|Select|Wrap|Line Numbers
  1. def download
  2.     send_data session[:csv], :filename => params[:filename]
  3. end
Then in the project controller, I have created a csv variable to store all my data elements, separated by commas, using "\n" for new lines. Then store the csv variable in the session and create a link to the download method, passing the filename:

Expand|Select|Wrap|Line Numbers
  1. session[:csv] = @csv
  2. @filename = 'filename.csv'
  3. @link = '<a href="/viewfolder/download?filename=' + @filename + 
  4. '">Download</a><br/>' + "\n"
  5.  
  6. render :text => @link
Hopefully this helps. Let me know how it works out.

Anthony
Jun 14 '07 #2

P: 4
Hey,

Pretty new to this and I was asked to setup a application at work that stores all the information regarding all the systems in our lab. Long story short I have everything working apart form exporting the information to a excel sheet. I tried this http://www.napcsweb.com/blog/2007/01/24/excel-export-the-stupid-simple-way/#respond,
which seems very straight forward but i still come up with the error "wrong number of arguments". Any ideas on another way to do this? or a better guide to this.

thanks.
Gearoid
There is also a HowTo on the Rails website, wich offers several ways. Even with the spreadsheet.gem
Sep 24 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.