in reply to Re: Perl 2 Excel
in thread Perl 2 Excel
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.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl 2 Excel
by Aldebaran (Curate) on Aug 21, 2018 at 21:11 UTC | |
by pryrt (Abbot) on Aug 21, 2018 at 21:35 UTC | |
by Eily (Monsignor) on Aug 21, 2018 at 22:39 UTC | |
|
Re^3: Perl 2 Excel
by newperlbie (Acolyte) on Aug 21, 2018 at 13:37 UTC | |
by holli (Abbot) on Aug 21, 2018 at 15:04 UTC | |
by newperlbie (Acolyte) on Aug 22, 2018 at 09:53 UTC | |
by holli (Abbot) on Aug 24, 2018 at 16:57 UTC |