$|=$^W = 1;
open
(ME,$0) or
die
$!;
my
$TestCount
=
grep
(/\+\+\
$Test
/,<ME>);
close
(ME);
my
(
$Excel
,
$File
);
BEGIN {
$File
= cwd .
"\\test.xls"
;
$File
=~ s
unless
(-f
$File
) {
print
"1..0 # Skipped: $File doesn't exist! Please run test 3_ole.t first\n"
;
exit
0;
}
Win32::OLE->Option(
Warn
=> 0);
$Excel
= Win32::OLE->new(
'Excel.Application'
,
'Quit'
);
Win32::OLE->Option(
Warn
=> 2);
unless
(
defined
$Excel
) {
my
$Msg
= Win32::OLE->LastError;
chomp
$Msg
;
$Msg
=~ s/\n/\n\
print
"# $Msg\n"
;
print
"1..0 # Skipped: Excel.Application not installed\n"
;
exit
0;
}
}
my
$Test
= 0;
print
"1..$TestCount\n"
;
printf
"# Excel is %s\n"
,
$Excel
;
print
"not "
unless
$Excel
eq
"Microsoft Excel"
;
printf
"ok %d\n"
, ++
$Test
;
my
$Book
=
$Excel
->Workbooks->Open(
$File
);
my
$Sheet
=
$Book
->Worksheets(
'My Sheet #1'
);
my
$Cell
=
$Sheet
->Cells(5,5);
my
$Value
=
$Cell
->{Value};
printf
"# Value is %f\n"
,
$Cell
->{Value};
print
"not "
unless
$Cell
->{Value} == 4711;
printf
"ok %d\n"
, ++
$Test
;
printf
"# Value is %f\n"
,
$Cell
;
print
"not "
unless
$Cell
== 4711;
printf
"ok %d\n"
, ++
$Test
;