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;

In reply to Re: Need help converting Excel color scale conditional formatting macro to perl by WheelbarrowRacers
in thread Need help converting Excel color scale conditional formatting macro to perl by WheelbarrowRacers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.