Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Javix
RE: Help with merging cells [ reply ]  
2010-03-02 10:04
Sorry,my mistake.I forgot to put my data text in the right cell:
[code]
for i in 2..5
test_row.set_format(i,bold_heading)
end
test_row[2] = data #recentlu there was test_row[0]
Thanks again

By: Javix
RE: Help with merging cells [ reply ]  
2010-03-02 10:00
It works fine but how to merge cells in a specified range? Your example makes it possible to merge celles starting from the 1st column only. Itried to change it like that:
[code]
for i in 2..5
test_row.set_format(i,bold_heading)
end
[/code]
Butin this case nothing happens.Please, help.Thks a lot!

By: Sam Gelbart
RE: Help with merging cells [ reply ]  
2009-02-16 12:00
Hi Hannes,

I have actually got it to work ... :-)

Here is the test script I wrote:

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)

5.times do |i|
test_row.set_format(i,bold_heading)
end

test_row[0] = data

book.write '/Users/sam/tmp/testing.xls'

Is the recommended way of doing it or is there a better way to get this behaviour?

Many thanks for your prompt reply.

Regards,

Sam

By: Hannes Wyss
RE: Help with merging cells [ reply ]  
2009-02-16 08:06
Sam,

Merging cells is not fully implemented yet, but planned for 0.7.0. That said, it is true that there is an :align => :merge attribute - can you post your code, so I have somewhere to start from?

Finally: You can also try working with a 'template':
Create an xls that contains all the fancy formatting that you need, but none of the dynamic data.
Then, open your template using Spreadsheet.open, populate it with data, and write to a different file using Workbook#write.

hth

cheers
Hannes

By: Sam Gelbart
Help with merging cells [ reply ]  
2009-02-15 07:36
Can you please help me in creating the correct formatting for a set of 5 cells acting as a heading?

This is to happen on row(0) for columns 0..4.

I am not sure how to tell the format to only apply itself to the first 5 cells on row 0, my previous attempt at using the ':align => :merge' attribute resulted in the entire row being merged.

Any assistance would be appreciated.