in reply to Need help converting Excel color scale conditional formatting macro to perl

So, here is the whole program in case it may prove useful to others:
#!c:\perl\bin use strict; use OLE; $Win32::OLE::Warn = 3; # Die on errors. # Start an instance of the Excel application my $excel = CreateObject OLE "Excel.Application"; # Make Excel visible or not $excel->{visible}=1; # 1=True, 0=False # Create a new workbook (Excel file) my $workbook = $excel->Workbooks->Add(); # Create and name a worksheet my $worksheet = $workbook->Worksheets("Sheet1"); $worksheet->Activate(); $worksheet->{Name} = "Color Scale Example"; # Put some values in a range of cells in Column A $worksheet->Range("a1")->{Value} = 87; $worksheet->Range("a2")->{Value} = 74; $worksheet->Range("a3")->{Value} = 16; $worksheet->Range("a4")->{Value} = 24; $worksheet->Range("a5")->{Value} = 48; # Select the cells with the values to be color scaled my $selection = $worksheet->Range("A1:A5"); # Add conditional formatting my $formatConditions = $selection->{'FormatConditions'}; $formatConditions->AddColorScale({ColorScaleType=>3}); $formatConditions->{$formatConditions->{'Count'}}->SetFirstPriority; # Set the color scale criteria which has three components my $colorScaleCriteria = $formatConditions->{1}->{'ColorScaleCriteria' +}; $colorScaleCriteria->{1}->{'Type'} = 'xlConditionValueLowestValue'; $colorScaleCriteria->{1}->{'FormatColor'}->{'Color'}=8109667; $colorScaleCriteria->{1}->{'FormatColor'}->{'TintAndShade'}=0; $colorScaleCriteria->{2}->{'Type'} = 'xlConditionValuePercentile'; $colorScaleCriteria->{2}->{'Value'}=50; $colorScaleCriteria->{2}->{'FormatColor'}->{'Color'}=8711167; $colorScaleCriteria->{2}->{'FormatColor'}->{'TintAndShade'}=0; $colorScaleCriteria->{3}->{'Type'} = 'xlConditionValueHighestValue'; $colorScaleCriteria->{3}->{'FormatColor'}->{'Color'}=7039480; $colorScaleCriteria->{3}->{'FormatColor'}->{'TintAndShade'}=0;
  • Comment on Re: Need help converting Excel color scale conditional formatting macro to perl
  • Download Code