use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); use FindBin qw($Bin); $Win32::OLE::Warn = 3; my $Excel = Win32::OLE->new('Excel.Application','Quit'); my $curpath = "$Bin/"; undef my $j; for $j (0 .. length($curpath)){ if(substr($curpath,$j,1)eq '/'){substr($curpath,$j,1) = '\\';} } undef my $listfile; $listfile = "filelist.txt"; my $syscmd = "dir \/b *.xlsx > ".$listfile; system($syscmd); sleep 2; close(STDERR); open(STDERR, ">load_error_log.txt"); open(RDR0, $listfile); undef my $listread; while ($listread = ){ chomp($listread); my $ExcelFile = $curpath.$listread; print "*Loading $ExcelFile*\n"; my $Book = $Excel->Workbooks->Open($ExcelFile) || die("Unable to open $ExcelFile ", Win32::OLE->LastError()); sleep 5; my $Sheet = $Book->Worksheets(1); my $LastRow = $Sheet->UsedRange->Find({What=>"*", SearchDirection=>xlPrevious, SearchOrder=>xlByRows})->{Row}; my $LastColumn = $Sheet->UsedRange->Find({What=>"*", SearchDirection=>xlPrevious, SearchOrder=>xlByColumns})->{Column}; my $RangeVal; for $j(65 .. (65 + $LastColumn)){ $RangeVal = chr($j)."1"; print $Sheet->Range($RangeVal)->{Value}."\t"; } print "\n"; $Book->Close(0); $Excel->Quit(); undef $Book; undef $Excel; } close(RDR0); close(WRT0); close(STDERR);