Exporting Information from Ruby on rails to a excel sheet.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • max power
    New Member
    • Jun 2007
    • 1

    #1

    Exporting Information from Ruby on rails to a excel sheet.

    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.co m/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
  • improvcornartist
    Recognized Expert Contributor
    • May 2007
    • 303

    #2
    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:

    Code:
    def download
    	send_data session[:csv], :filename => params[:filename]
    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:

    Code:
    session[:csv] = @csv
    @filename = 'filename.csv'
    @link = '<a href="/viewfolder/download?filename=' + @filename + 
    '">Download</a><br/>' + "\n"
    
    render :text => @link
    Hopefully this helps. Let me know how it works out.

    Anthony

    Comment

    • johnnyDispo
      New Member
      • Sep 2007
      • 4

      #3
      Originally posted by max power
      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.co m/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

      Comment

      Working...