On Nov 3, 7:03 am, "
rpno...@ibksoftware.com" <
rpno...@ibksoftware.com>
wrote:
Hi Rob,
Images (and other objects) are layered on top of a worksheet so they
aren't in general controlled by formatting.
In the case of images you will need to specify your own offsets to
centre the image using the optional $x, $y parameters in insert_image
().
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm#insert_image($row,_$col,_$filename,_$x,_$y,_$scale_x,_$scale_y)
The default cell width is 64 pixels and the default height is 17
pixels. So to centre a 16x16 image you will need the following
offsets:
x = int( ( 64 - 16) / 2 ) = 24
y = int ( ( 17 - 16) /2 ) = 0
Here is an example:
#!/usr/bin/perl
use strict;
use warnings;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new('test.xls');
my $worksheet = $workbook->add_worksheet();
# Left top align.
$worksheet->insert_image('B3', '16x16.png');
# Centred. x = int( ( 64 - 16) / 2 ), y = int ( ( 17 - 16) /2 ).
$worksheet->insert_image('B5', '16x16.png', 24, 0);
# Right bottom align. x = ( 64 - 16), y = ( 17 - 16).
$worksheet->insert_image('B7', '16x16.png', 48, 1);
__END__
John.
--