slick.user has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use Win32::OLE; use Win32::OLE qw(in with); my $EXCEL = Win32::OLE->new("Excel.Application","Quit"); $EXCEL->{"Visible"} = 1; $EXCEL->{DisplayAlerts}= 0; my $outfile = "C:\\test\\file1.xls"; $EXCEL -> {"SheetsInNewWorkBook"} = 1; my $Workbook = $EXCEL -> Workbooks -> Add(); my $CurrentSheet = $Workbook -> Worksheets(1); $CurrentSheet->Range("A1")->{"Value"} = "DataA"; $CurrentSheet->Range("A2")->{"Value"} = "abs"; $CurrentSheet->Range("A3")->{"Value"} = "FALSE"; $CurrentSheet->Range("A4")->{"Value"} = "TRUE"; $CurrentSheet->Range("A5")->{"Value"} = "ABC"; $CurrentSheet->Range("A6")->{"Value"} = "xyz"; $CurrentSheet->Range("A7")->{"Value"} = "123"; $CurrentSheet->Range("A8")->{"Value"} = "-99999"; $CurrentSheet->Range("A9")->{"Value"} = "TRUE"; $CurrentSheet->Range("A10")->{"Value"} = "10"; $CurrentSheet->Range("B1")->{"Value"} = "DataB"; $CurrentSheet->Range("B2")->{"Value"} = "absx"; $CurrentSheet->Range("B3")->{"Value"} = "FALSE"; $CurrentSheet->Range("B4")->{"Value"} = "TRUE"; $CurrentSheet->Range("B5")->{"Value"} = "ABCx"; $CurrentSheet->Range("B6")->{"Value"} = "xyzx"; $CurrentSheet->Range("B7")->{"Value"} = "123x"; $CurrentSheet->Range("B8")->{"Value"} = "-99999x"; $CurrentSheet->Range("B9")->{"Value"} = "TRUE"; $CurrentSheet->Range("B10")->{"Value"} = "10x"; $CurrentSheet->Range("C1")->{"Value"} = "A=B?"; #my $rangeFormat = $CurrentSheet->Range("A4"); #$rangeFormat->Interior->{Color} = 255; # Columns("A:A").Select # Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNot +Equal, _ # Formula1:="=TRUE" # Selection.FormatConditions(Selection.FormatConditions.Count).SetF +irstPriority # With Selection.FormatConditions(1).Font # .Color = -16776961 # .TintAndShade = 0 # End With # Selection.FormatConditions(1).StopIfTrue = True my $rangeFormat = $CurrentSheet->Range("A:A"); $rangeFormat->FormatConditions->Add({Type=>"xlCellValue", Operator=>"x +lNotEqual", Formula1=>"=TRUE"}); $rangeFormat->FormatConditions(1)->Font->{Color} = -16776961; $Workbook->SaveAs({FileName => $outfile, FileFormat => -4143}); $Workbook -> Save(); $EXCEL->Quit(); Win32::OLE->FreeUnusedLibraries();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::OLE Excel Conditional Formatting error
by pryrt (Abbot) on Feb 29, 2024 at 20:23 UTC | |
by slick.user (Acolyte) on Feb 29, 2024 at 21:32 UTC | |
|
Re: Win32::OLE Excel Conditional Formatting error
by Danny (Chaplain) on Feb 29, 2024 at 17:15 UTC | |
|
Re: Win32::OLE Excel Conditional Formatting error
by Danny (Chaplain) on Feb 29, 2024 at 18:54 UTC | |
by slick.user (Acolyte) on Feb 29, 2024 at 19:04 UTC | |
by Danny (Chaplain) on Feb 29, 2024 at 20:23 UTC | |
by slick.user (Acolyte) on Feb 29, 2024 at 21:29 UTC | |
by Anonymous Monk on Feb 29, 2024 at 19:01 UTC | |
|
Re: Win32::OLE Excel Conditional Formatting error
by InfiniteSilence (Curate) on Mar 02, 2024 at 17:38 UTC |