Spreadsheet gem




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,



Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question