简体   繁体   中英

Usage of set_row in Excel module in perl

I am learning to write in Excel with a script in perl. I am using set_row to increase height of a cell. Currently i am using below to increase the height

            $worksheet->set_row(0,40);
            $worksheet->set_row(1,40);
            ...

Is there any way to do for all rows. Also is it possible to increase assymnetric height. like 1 row 20, second row 40, third row 15 etc

Thanks in Advance

To automate the configuration of row heights, you could store all of your height information in a hash, then loop over the hash keys (ie. row numbers) and call the set_row() method using the row number along with the corresponding value in the hash (ie. row height).

my %row_height_map = (
    0   => 40,
    1   => 25,
    2   => 30
);

for my $row_number (keys %row_height_map) {
    $worksheet->set_row($row_number, $row_height_map{$row_number});
}

Note that you could also use an array to store the values, but with a hash you can arbitrarily leave out row numbers you don't want modified.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM