Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Spreadsheet Excel: How to merge cells?

Reply
Thread Tools

Spreadsheet Excel: How to merge cells?

 
 
Michael Schmarck
Guest
Posts: n/a
 
      01-29-2008
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 :/

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
 
Reply With Quote
 
 
 
 
melampus
Guest
Posts: n/a
 
      01-29-2008
> 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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to Load SpreadSheet in AxSpreadSheet object in VB.NET or C#.NET tushar.n.patel@gmail.com ASP .Net 0 12-07-2005 07:26 AM
Is there anyway with VB.net to force closing of a spreadsheet in E =?Utf-8?B?TmVpbA==?= ASP .Net 1 04-27-2005 03:14 PM
Writing to an Excel Spreadsheet FSD Perl 0 02-19-2005 12:49 AM
Spreadsheet::WriteExcel Fabio Perl 2 03-04-2004 08:37 AM



Advertisments