You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to apply format to the cell range with write_array_formula() method, the format is applied only to first cell, not to the entire range.
Example:
$worksheet->write_array_formula('A1:C3', '{=2+2}', $workbook->add_format(border=>6, bold=>1));
The text was updated successfully, but these errors were encountered:
The current Excel::Writer::XLSX behaviour models Excel's behaviour which only adds formatting to the first cell.
However, Excel also adds formatted blank cells to the rest of the range. So perhaps Excel::Writer::XLSX should do the same.
I'll mark it as a bug/feature request and put it in the 0.51 milestone.
In the meantime you can work around this issue by adding formatting to the other cells in the range using write_blank() and a format. Something like this:
#!/usr/bin/perl
use strict;
use warnings;
use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new( 'array_formula.xlsx' );
my $worksheet = $workbook->add_worksheet();
my $format = $workbook->add_format( bold => 1 );
$worksheet->write( 'B1', [ [ 500, 10 ], [ 300, 15 ] ] );
$worksheet->write_array_formula( 'A1:A2', '{=SUM(B1:C1*B2:C2)}', $format );
$worksheet->write_blank( 'A2', $format );
__END__
Thank you for the very quick answer.
Let me ask here one question.
How can I set a border to the range? I mean not to every cell in the range, but to the entire range.
For example in the code below I suppose to see double border around the entire range but not on every cell in the range:
When I try to apply format to the cell range with write_array_formula() method, the format is applied only to first cell, not to the entire range.
Example:
$worksheet->write_array_formula('A1:C3', '{=2+2}', $workbook->add_format(border=>6, bold=>1));
The text was updated successfully, but these errors were encountered: