Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!perl -w
#
# Name:
# ole-xl-demo1.pl
#
# Purpose:
# Test Win32::OLE with Excel.
use strict;
use Win32::OLE;
# --------------------------------------------------------
my $ex;
my $xlfile = 'd:\some\path\to\an\Excel\file\file.xls';
eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
die "Excel not installed" if $@;
unless (defined $ex)
{
$ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";
}
my($book) = $ex->Workbooks->Open({FileName => $xlfile, ReadOnly=>1});
my($sheet) = $book->Worksheets(1);
# Get block D8:E9
my(@array) = $sheet->Range("D8:E9")->{'Value'};
my($i, $j);
print "Range is based on (D8:E9). \n";
print "Size of \@array: ", $#array + 1, ". \n";
for $i (0 .. $#array)
{
print "Size of \$#{\$array[\$i]}: ", $#{$array[$i]} + 1, ". \n";
&report("\$array[$i]", $array[$i]);
for $j (0 .. $#{$array[$i]})
{
&report("\$array[$i][$j]", $array[$i][$j]);
print "Live data @ ($i, $j): <", join(">\t<",
@{$array[$i][$j]}), ">. \n";
}
}
$book -> Close();
$ex -> Quit();
print "Success \n";
# exit(0);
# --------------------------------------------------------
sub report
{
my($name, $thing) = @_;
print "ref($name): ", ref($thing), ". \n" if (ref($thing) );
print "$name is not a ref. \n" if (! ref($thing) );
} # End of report;