otism has asked for the wisdom of the Perl Monks concerning the following question:
Esteemed brethren of the code,
I have a some code I've thrown together to read through an Excel 2007 spreadsheet - which is working just fine to a point. I can open the file - read the values - print some out - and close the file. Everything seems absolutely peachy on the surface.
The problem is that in the background EXCEL.EXE in the task manager just will not go away! If I have other worksheets open in the background, THEY will close and the app window go away, but the process called from the script remains.
Does anyone have any ideas what I can do to cause this process to go away?
PC - Windows XP Pro SP 2 ( VDI )
MS Office Excel 2007
Perl details:
C:\>perl -V Summary of my perl5 (5.0 patchlevel 5 subversion 03) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-object uname='' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cl.exe', optimize='-Od -MD -DNDEBUG -TP -GX', gccversion= cppflags='-DWIN32' ccflags ='-Od -MD -DNDEBUG -TP -GX -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_OBJECT' stdchar='char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -release -libpath:"C:\Perl\lib\C ORE" -machine:x86' libpth="C:\Perl\lib\CORE" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32. lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock 32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib PerlCRT.lib libc=C:\Perl\lib\CORE\PerlCRT.lib, so=dll, useshrplib=yes, libperl=perlcore. lib Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -libpath:"C: \Perl\lib\CORE" -machine:x86' Characteristics of this binary (from libperl): Locally applied patches: ActivePerl Build 522 Built under MSWin32 Compiled at Nov 2 1999 09:52:28 @INC: C:/Perl/lib C:/Perl/site/lib
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 = <RDR0>){ chomp($listread); my $ExcelFile = $curpath.$listread; print "*Loading $ExcelFile*\n"; my $Book = $Excel->Workbooks->Open($ExcelFile) || die("Unable to o +pen $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);
|
|---|