Sha256: a19c8785f279da265927b19611941190d3b11d5745ee9e3ac9df30bd201f350c

Contents?: true

Size: 1.71 KB

Versions: 33

Compression:

Stored size: 1.71 KB

Contents

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

###############################################################################
#
# Simple example of merging cells using the WriteExcel module
#
# This merges two formatted 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 'rubygems'
require 'writeexcel'

# Create a new workbook and add a worksheet
workbook  = WriteExcel.new("merge2.xls")
worksheet = workbook.add_worksheet

# Increase the cell size of the merged cells to highlight the formatting.
worksheet.set_column(1, 2, 30)
worksheet.set_row(2, 40)

# Create a merged format
format = workbook.add_format(
                                        :center_across   => 1,
                                        :bold            => 1,
                                        :size            => 15,
                                        :pattern         => 1,
                                        :border          => 6,
                                        :color           => 'white',
                                        :fg_color        => 'green',
                                        :border_color    => 'yellow',
                                        :align           => 'vcenter'
                                  )

# 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)
workbook.close

Version data entries

33 entries across 33 versions & 3 rubygems

Version Path
writeexcel-1.0.4 examples/merge2.rb
writeexcel-1.0.3 examples/merge2.rb
writeexcel-1.0.2 examples/merge2.rb
writeexcel-1.0.1 examples/merge2.rb
writeexcel-1.0.0 examples/merge2.rb
writeexcel-0.6.19 examples/merge2.rb
writeexcel-0.6.18 examples/merge2.rb
writeexcel-0.6.17 examples/merge2.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.16/examples/merge2.rb
writeexcel-0.6.16 examples/merge2.rb
writeexcel-0.6.15 examples/merge2.rb
writeexcel-0.6.14 examples/merge2.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/merge2.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/merge2.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/merge2.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/merge2.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/examples/merge2.rb
writeexcel-0.6.13 examples/merge2.rb
ricardoo27-writeexcel-0.6.12.2 examples/merge2.rb
ricardoo27-writeexcel-0.6.12.1 examples/merge2.rb