<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl

###############################################################################
#
# Example of how to use the Excel::Writer::XLSX merge_cells() workbook
# method with complex formatting and rotation.
#
#
# Copyright 2000-2020, John McNamara, jmcnamara@cpan.org
#

use strict;
use warnings;
use Excel::Writer::XLSX;

# Create a new workbook and add a worksheet
my $workbook  = Excel::Writer::XLSX-&gt;new( 'merge5.xlsx' );
my $worksheet = $workbook-&gt;add_worksheet();


# Increase the cell size of the merged cells to highlight the formatting.
$worksheet-&gt;set_row( $_, 36 ) for ( 3 .. 8 );
$worksheet-&gt;set_column( $_, $_, 15 ) for ( 1, 3, 5 );


###############################################################################
#
# Rotation 1, letters run from top to bottom
#
my $format1 = $workbook-&gt;add_format(
    border   =&gt; 6,
    bold     =&gt; 1,
    color    =&gt; 'red',
    valign   =&gt; 'vcentre',
    align    =&gt; 'centre',
    rotation =&gt; 270,
);


$worksheet-&gt;merge_range( 'B4:B9', 'Rotation 270', $format1 );


###############################################################################
#
# Rotation 2, 90° anticlockwise
#
my $format2 = $workbook-&gt;add_format(
    border   =&gt; 6,
    bold     =&gt; 1,
    color    =&gt; 'red',
    valign   =&gt; 'vcentre',
    align    =&gt; 'centre',
    rotation =&gt; 90,
);


$worksheet-&gt;merge_range( 'D4:D9', 'Rotation 90°', $format2 );


###############################################################################
#
# Rotation 3, 90° clockwise
#
my $format3 = $workbook-&gt;add_format(
    border   =&gt; 6,
    bold     =&gt; 1,
    color    =&gt; 'red',
    valign   =&gt; 'vcentre',
    align    =&gt; 'centre',
    rotation =&gt; -90,
);


$worksheet-&gt;merge_range( 'F4:F9', 'Rotation -90°', $format3 );

$workbook-&gt;close();

__END__
</pre></body></html>