×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

A question about method set_column() in Excel::Writer::XLSX module

A question about method set_column() in Excel::Writer::XLSX module

A question about method set_column() in Excel::Writer::XLSX module

(OP)
I am trying to understand Excel::Writer::XLSX module by study the samples at CPAN site.

One of the sample code is at this link: http://search.cpan.org/~jmcnamara/Excel-Writer-XLS...

The implementation I am trying to understand listed below (my comments are in blue):

CODE

my $worksheet = $workbook->add_worksheet( 'Fonts' );

$worksheet->set_column( 0, 0, 30 ); # First row, First column, width is 30
$worksheet->set_column( 1, 1, 10 ); # Second row, Second column, width is 10 

If I modified the code above in red like below:

CODE

$worksheet->set_column( 0, 1, 10 ); 
then the width of the first column will be overwritten.

Is this the way supposed to be?

In general, please take a look at a block of codes below:

CODE

for(my $i = 0, $i < 10; $i++) {
    my $width = 20 + $i;
    $worksheet->set_column( 0, $i, $width ); # This line does not work. All columns will have the same width! 
    #$worksheet->set_column( $i, $i, $width ); # This is the correct implementation.
} 

I feel a bit odd. To me, both implementations should work.
Could someone explain it to me? Many thanks.

RE: A question about method set_column() in Excel::Writer::XLSX module

Hi

Quote (set_column())

set_column( $first_col, $last_col, $width, $format, $hidden, $level, $collapsed )
Excel::Writer::XLSX | set_column() )

CODE --> Perl

$worksheet->set_column( 0, $i, $width );  # sets columns in range 0..$i
$worksheet->set_column( $i, $i, $width ); # sets column $i 

Feherke.
http://feherke.github.com/

RE: A question about method set_column() in Excel::Writer::XLSX module

(OP)
Thanks for the explanation. I have not thought about whether there should be a way to set column's width in a range, yet.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close