Hi
i wish to read and write all wanted text files in one directory into one single excelsheet which contains of multiple worksheet that represent each file. my current script only can write out into many excelsheet instead of combining all into one. Anybody has idea to improve my script to achieve that purpose?
thank you!
use Spreadsheet::WriteExcel;
use Spreadsheet::ParseExcel;
my @files = <*>;
my @files=();
while (<*>)
{
push (@files,$_) ;
}
foreach $get (@files)
{
open(I, $get) || die "Can't open file\n";
while(!eof(I)) {
$line=<I>;
$line=$` if ($line=~/\s$/);
push (@wanted, $line);
}
close(I);
$get=~s/\.txt//;
open ($OUT, ">$get.xls");
$workbook = Spreadsheet::WriteExcel->new($OUT);
$worksheet= $workbook->add_worksheet($get);
foreach $display(@wanted)
{
$worksheet->write($row, 0, "$display");
$row++;
}
$workbook->close();
close($OUT);
@wanted=();
}