Topic: Spreadsheet gem - adding new font

Hi, 

I am using spreadsheet gem and I need to change the font of my rows/columns to "calibri" size 10.  Is it possible to do that?

Also I need to change my header background to a specific hex color code.

I would appreciate some direction.  thanks

Last edited by railslist (2011-06-30 04:15:21)

Re: Spreadsheet gem - adding new font

- first, create a format you need and then just apply it to the row or cell:

book = Spreadsheet::Workbook.new
sheet = book.create_worksheet :name => "Test Sheet"

bold_heading = Spreadsheet::Format.new(:weight => :bold, :size => 14, :align => :merge)
data = "A TEST HEADING"
test_row = sheet.row(0)
for i in 2..5
  puts "my index=> #{i}"
  test_row.set_format(i,bold_heading)
end
test_row[2] = data




book.write '/path/to/your/excel_file.xls'

you can find more options when looking the API of spreadsheet gem: http://spreadsheet.rubyforge.org/file.GUIDE.html

Last edited by Javix (2011-06-30 06:11:04)