How can I format a specific cell using the Ruby Spreadsheet library?

Formatting a column or row does not seem to be a problem. I put the documentation in a heap, did some searches, and looked at the result of the β€œmethods” on some objects in the spreadsheet, and I cannot figure out how to format a specific cell. Has anyone done this?

The spreadsheet library is here: http://spreadsheet.rubyforge.org/ http://spreadsheet.rubyforge.org/GUIDE_txt.html

+7
source share
1 answer

Use the set_format method:

require 'spreadsheet' book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet format = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 18 row = sheet1.row(0) row[0] = 'test0' row[1] = 'test1' row.set_format(0, format) # set format for the first cell book.write 'C:\\test.xls' 
+14
source

All Articles