Spreadsheet gem

Discussion in 'Ruby' started by johan.tempelman@bt.com, Oct 13, 2010.

  1. Guest

    Hi,

    Here is a newbie question on the spreadsheet gem.

    I have the following simple test code in a controller action :

    require "spreadsheet"

    @csd =3D cns_period_conv(params[:date][:year],params[:period_start])
    book =3D Spreadsheet::Workbook.new
    sheet1 =3D book.create_worksheet #default sheet name Worksheet1
    sheet1.name =3D 'My First Worksheet'
    sheet2 =3D book.create_worksheet :name =3D> 'My Second Worksheet'
    sheet1.row(0).concat %w{Name Country Acknowlegement}
    sheet1[1,0] =3D 'Japan' #get the Cell at row 1, column 0
    sheet1.row(0).height =3D 40
    format_1 =3D Spreadsheet::Format.new :rotation=3D> 90, :vertical_align =
    =3D> :center, :horizontal_align=3D>:center
    sheet1.row(0).set_format(0, format_1);
    sheet1.row(2).push 'One','Two','Three'

    sheet1.column(2).width =3D "Acknoledgements".length
    format_2 =3D Spreadsheet::Format.new :horizontal_align=3D> :center
    sheet1.row(0).set_format(2, format_2);

    book.write 'Excel.xls'

    I would like to open this file in Excel instead of saving it to the harddis=
    k. What have I missed?

    Best regards,

    Johan
     
    , Oct 13, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Austin 7873
    Replies:
    5
    Views:
    208
    Eric Hodel
    Jan 27, 2007
  2. Jim Burgess
    Replies:
    2
    Views:
    144
    Jim Burgess
    Jan 16, 2009
  3. Alan Claughan

    Spreadsheet Manipulation Gem

    Alan Claughan, Jun 16, 2009, in forum: Ruby
    Replies:
    0
    Views:
    103
    Alan Claughan
    Jun 16, 2009
  4. Jim ..
    Replies:
    0
    Views:
    126
    Jim ..
    Dec 19, 2009
  5. Dominic Sisneros

    Spreadsheet gem errors

    Dominic Sisneros, Oct 21, 2010, in forum: Ruby
    Replies:
    0
    Views:
    100
    Dominic Sisneros
    Oct 21, 2010
Loading...

Share This Page