in reply to Perl 2 Excel

Hello newperlbie, there are a few issues with your post that makes it harder to give you an answer:
You didn't provide any input data, which means we can't reproduce the issue in the same conditions as you. Your sample of code also doesn't compile because it doesn't include the use Spreadsheet::WriteExcel; line. Asking if your includes are correct without showing them makes little sense. Also please do something about your identation, don't mix tabs and spaces, and align your code properly.

More info on those points in How do I post a question effectively?

That being said, I did reproduce the defect with 300 lines of dummy data (I replaced the regex by /./ because I was too lazy to write valid data). I took a wild guess: Excel somehow doesn't support that many formats (or there's a bug with adding so many formats), so I moved the format declaration out of the loop (it's always the same, so why redeclare it each time?).

use strict; use warnings; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new("output.xls"); my $worksheet = $workbook->add_worksheet("overview"); my $colCount = 0; my $rowCount = 0; open my $tf, "<", "input.txt" or die "Cannot open file: $!"; my $header1 = $workbook->addformat(bold => 0, color => 'green', size => 10, merge => 0, ); while(my $line = <$tf>) { if ( $line =~ /\w/) { $worksheet->set_column($colCount, $colCount, 30); print $line; #this is a dummy line $worksheet->write($rowCount,$colCount,$line,$header1); $rowCount++; } }
It looks like it solved the issue. (BTW, you should indicate that you open the input file for reading with "<". And why did you name your input file "output.txt"?)

Replies are listed 'Best First'.
Re^2: Perl 2 Excel
by newperlbie (Acolyte) on Aug 21, 2018 at 13:36 UTC
    Thank you!I moved the formatting out of the loop and it worked. the file is the output of another program, so!!

      So every program should have it's output named 'output' by default? :P