Hi Matthew,

I can't help specifically with the Spreadsheet gem (I recall trying it and
having similar issues and crashes), but there is a robust alternative.

I've had to deal with Excel files from a Rails app recently, and I found the
Ruby Excel libraries to be very under-featured or fragile.  In the end I
used JRuby and the Apache POI Java library which in my experience has been
very robust.

So you end up using Java but the pain is somewhat abated by using JRuby.  It
was an acceptable compromise for me :)

Regards,

James.

2009/3/9 Matthew Delves <[email protected]>

>
> Greetings all,
> I've been looking at the spreadsheet (http://
> spreadsheet.rubyforge.org/) gem to get data exported from my database
> to an excel document, though am running into a couple of hitches with
> it.
>
> It doesn't want to write the file correctly. The code that I currently
> have is:
>
> --
>   def excel
>     # Create a new spreadsheet
>     book = Spreadsheet::Workbook.new
>     sheet = book.create_worksheet
>     sheet.name =  'All Member Details'
>
>     # Add the header row
>     sheet.row(0).push Member.column_names
>     puts Member.column_names
>
>     # Add the content
>     Member.find(:all).each_with_index do |member, index|
>       sheet.row(index + 1).push member.attributes.values
>       puts member.attributes.values
>     end
>
>     # close the workbook
>     # book.close
>
>     # Offer up the file for download
>     downloadpath = 'downloads/members.xls'
>     book.write downloadpath
>     send_file downloadpath, :x_sendfile => true
>
>   end
> --
>
> Any help in getting this going would be greatly appreciated.
>
> Thanks,
> Matt Delves
>
>
>
> >
>


-- 
James

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to