I think you're running out of space in whatever table is used internally for ->add_format(). Compare the results of these two files:
#!/usr/bin/perl
use warnings;
use strict;
use Spreadsheet::WriteExcel;
many_formats: {
my $wb = Spreadsheet::WriteExcel->new('output_many.xls');
my $sheet = $wb->add_worksheet("overview");
foreach my $row (0..100) {
local $\ = "\n";
print my $line = join('', map { ('A'..'Z')[rand 26] } 0 .. ran
+d 16);
my $header1 = $wb->add_format(bold=>0, color=>'green', size=>1
+0, merge=>0);
$sheet->set_column(1,1,30);
$sheet->write($row, 1, $line, $header1);
}
undef $wb;
}
shared_format: {
my $wb = Spreadsheet::WriteExcel->new('output_shared.xls');
my $header1 = $wb->add_format(bold=>0, color=>'green', size=>10, m
+erge=>0);
my $sheet = $wb->add_worksheet("overview");
foreach my $row (0..100) {
local $\ = "\n";
print my $line = join('', map { ('A'..'Z')[rand 26] } 0 .. ran
+d 16);
$sheet->set_column(1,1,30);
$sheet->write($row, 1, $line, $header1);
}
undef $wb;
}
The only difference between the code is that in the first, like you, I create a new format for every row. That stops formatting after about 40 rows. For the second, I create one format, and apply it to every row... and when I open output_shared.xls in Excel, all the rows are properly formatted.
(Also, since the documentation shows ->add_format(), that's what I used here, instead of the ->addformat() you used, though it didn't seem to affect my experiments, that I noticed.) |