use strict; use warnings; use diagnostics; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add(); for (2..$wb->Sheets->{Count}) { $wb->Sheets(2)->Delete; } $wb->Names->Add({Name=>"Fmt", RefersToR1C1=>"=RC>0"}); #Comment 1 my $A1 = $wb->Sheets(1)->Cells(1, 1); my $A2 = $wb->Sheets(1)->Cells(2, 1); $A1->FormatConditions->Add({Type=>2, Formula1=>"=Fmt"}); #Comment 2 $A1->FormatConditions(1)->Interior->{Color} = 255; $A1->Copy($A2); PrintStatus(); $A1->{Value} = 1; PrintStatus(); $A2->{Value} = 1; PrintStatus(); $A1->{Value} = -1; PrintStatus(); sub PrintStatus { my $seln = $xl->Selection; $A1->Select; #Comment 3 print $xl->Evaluate("Fmt") . " "; $A2->Select; print $xl->Evaluate("Fmt") . "\n"; $seln->Select; }