in reply to Re^3: Converting a txt file to excel file
in thread Converting a txt file to excel file
First, you are saving only one row. Fix it with something like:
Second, you are setting and/or incrementing the row and column indexes inappropriately (you also have an extraneous write right before the first loop); fix it with something like:foreach $line ( <INFILE> ) { if( $line =~ /^Name/ ) { @columnNames = split(/\t/, $line); } else { push @rowValues, [ split(/\t/, $line) ]; } }
Third, you are not using strict (q.v.), and are therefore heading for a world of pain.$row = 0; $count = 0; foreach $element(@columnNames) { $worksheet->write($row,$count,$element); $count++; } ++$row; foreach my $rv (@rowValues) { $count = 0; foreach my $element (@$rv) { $worksheet->write($row,$count,$element); $count++; } $row++; }
Im normally a java programmer and cant seem to see a way forward...
If you think the problems with the code you posted had something to do with it being in Perl rather than Java I think you are missing the boat; the most serious errors in it are pretty generic.
the lowliest monk
|
|---|