Spreadsheet Excel: How to merge cells?

Hello.

I’m using spreadsheet-excel-0.3.5.1 on Windows XP with Excel 2000 and
ruby 1.8.6. I’m trying to merge some cells, but don’t succeed in doing
so :confused:

Here’s my code:

require ‘spreadsheet/excel’
EXCEL_REPORT_FILE = “Report.xls”
workbook = Spreadsheet::Excel.new(EXCEL_REPORT_FILE)
worksheet = workbook.add_worksheet
format_merged = workbook.add_format(:align => “merge”)
worksheet.write(0, 0, [“Host”, “Date”, “Headertext”, “”, “”, “”,
“Something else”])
workbook.close

I would have expected (or at least that’s what I wanted to achieve…),
that the “Headertext” spans the columns C…F in row 1. But this does
not happen. What happens is, that “Headertext” is only visible in cell
C1. I uploaded the generated Excel XLS file to
http://michael-schmarck.share.s3.amazonaws.com/Report.xls.

Obviously, I’m doing something wrong here, as the cells don’t merge.

How would I do that correctly?

Thanks a lot,
Michael

format_merged = workbook.add_format(:align => “merge”)
worksheet.write(0, 0, [“Host”, “Date”, “Headertext”, “”, “”, “”, “Something else”])

you never seem to apply the format after you have defined it?! I don’t
this packages, but can you do something like:

worksheet.write(0, 3, [“Headertext”, “”, “”, “”], format_merged)