For those interested I decided to play around with simply finding a
specific sheet and see what happens if i started with the most basic
calling by name. the following is my code/errors. On the two times that it
asked if there was an added sheet, it created a new workbook instead and
did not create a named sheet.
At least this gives a way to get a sheet already present.
I'm wondering, has anyone started putting together a sheet on OLE or
OLE/Excel functions and syntaxes? Does anyone know of one?
-Josh
-----code-----
#! /usr/bin/perl
use strict;
use Win32::OLE qw(in with); # use base OLE
use Win32::OLE::Const 'Microsoft Excel'; # use OLE/Excel
# $Win32::OLE::Warn = 3; # die on errors...
my $dessheet=shift(@ARGV);
my $fcell='';
my $workbook='W:/lab reports/tester.xls';
unless(-e $workbook){
print "cant find the workbook\n";
}else{
my $Excel = Win32::OLE -> GetActiveObject('Excel.Application')
|| Win32::OLE -> new('Excel.Application', 'Quit');
$Excel -> {'Visible'} = 1;
my $report = $Excel->Workbooks->Open("$workbook");
my $ws = $report->Worksheets("$dessheet");
if($ws){
$fcell = $ws -> Range("A1") -> {'Value'};
print "\$ws: $ws\n\t\$fcell: $fcell\n";
}else{
$workbook = $Excel -> Workbooks -> Add();
$ws = $workbook -> Worksheets(1);
$ws -> { 'Name' } = "new sheet";
$ws -> Range("A2") -> {'Value'} = "was i successful?";
print "added sheet?\n";
}
$Excel -> Workbooks -> Save(); # save file
$Excel -> Workbooks -> Quit(); # leave excel
}
----errors------
W:\lab reports>perl sheettest.pl test
$ws: Win32::OLE=HASH(0x19febd8)
$fcell: wooooT got test!
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156.
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156.
W:\lab reports>perl sheettest.pl missing
added sheet?
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156.
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156.
W:\lab reports>perl sheettest.pl 'a name'
added sheet?
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156.
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156.
W:\lab reports>perl sheettest.pl "a name"
$ws: Win32::OLE=HASH(0x19febd8)
$fcell: there's a name????
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156.
retrying default method at C:/Perl/site/lib/Win32/OLE/Lite.pm line 156.
W:\lab reports>
-----------------------------------------
PLEASE NOTE:
SeaChange International headquarters in Maynard, MA is moving!
Effective March 1, 2006, our new headquarters address will be:
SeaChange International
50 Nagog Park
Acton, MA 01720 USA
All telephone numbers remain the same:
Main Corporate Telephone: 978-897-0100
Customer Service Telephone: 978-897-7300
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs