Sha256: 7b302b75d1c1a5f3f0859b50f129fe733e7f298308dad0e4659b739dfddcecfa

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/ruby -w
# -*- coding: utf-8 -*-

###############################################################################
#
# Simple example of merging cells using the WriteExcel module.
#
# This merges three cells using the "Centre Across Selection" alignment.
# This was the Excel 5 method of achieving a merge. Use the merge_range()
# worksheet method instead. See merge3.pl - merge6.pl.
#
# reverse('©'), August 2002, John McNamara, jmcnamara@cpan.org
#
# original written in Perl by John McNamara
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
#

require 'writeexcel'

# Create a new workbook and add a worksheet
workbook  = WriteExcel.new('merge1.xls')
worksheet = workbook.add_worksheet


# Increase the cell size of the merged cells to highlight the formatting.
worksheet.set_column('B:D', 20)
worksheet.set_row(2, 30)


# Create a merge format
format = workbook.add_format(:center_across => 1)


# Only one cell should contain text, the others should be blank.
worksheet.write(2, 1, "Center across selection", format)
worksheet.write_blank(2, 2,                 format)
worksheet.write_blank(2, 3,                 format)

workbook.close

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
writeexcel-1.0.9 examples/merge1.rb
writeexcel-1.0.8 examples/merge1.rb
writeexcel-1.0.7 examples/merge1.rb
writeexcel-1.0.6 examples/merge1.rb
writeexcel-1.0.5 examples/merge1.rb