Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Centering an image
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
rpnoble@ibksoftware.com  
View profile  
 More options Nov 3, 2:03 am
From: "rpno...@ibksoftware.com" <rpno...@ibksoftware.com>
Date: Mon, 2 Nov 2009 23:03:44 -0800 (PST)
Local: Tues, Nov 3 2009 2:03 am
Subject: Centering an image
John;

I have several png files that represent trends (up, down and no
change). They are 16px x 16px, Can they be centered using formats?
Currently they are flush left. Do I need to create the graphic as wide
as the column? Thge column width is 10 row height is 22.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jmcnamara  
View profile  
 More options Nov 3, 5:07 am
From: jmcnamara <jmcnam...@cpan.org>
Date: Tue, 3 Nov 2009 02:07:14 -0800 (PST)
Local: Tues, Nov 3 2009 5:07 am
Subject: Re: Centering an image
On Nov 3, 7:03 am, "rpno...@ibksoftware.com" <rpno...@ibksoftware.com>
wrote:

> I have several png files that represent trends (up, down and no
> change). They are 16px x 16px, Can they be centered using formats?
> Currently they are flush left. Do I need to create the graphic as wide
> as the column? Thge column width is 10 row height is 22.

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/Spreadsh...)

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.
--


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google