Ruby Spreadsheet 合并单元格方法

原文出处:http://rubyforge.org/forum/message.php?msg_id=64873


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'



关键点:为你要合并的所有单元格设置:align => :merge

比如你要合并 a:1 a:2这两个单元格,那么这两个都设置:align => :merge属性

你可能感兴趣的:(PHP,Ruby)