in reply to Problem filling Excel cells with Solid Colour

$cell_interior_pattern{1} = xlPatternAutomatic; $cell_interior_pattern{2} = xlPatternChecker; $cell_interior_pattern{3} = xlPatternCrissCross; $cell_interior_pattern{4} = xlPatternDown; #... for $jq (sort {$a <=> $b} keys %cell_interior_pattern) {

Did you know that Perl has arrays? You don't need to sort the index list for them and you can construct them with a list like:

my @cell_interior_pattern = (xlPatternAutomatic, xlPatternChecker, xlP +atternCrissCross, xlPatternDown);

Just remember that the index starts from 0 and you'll be fine. Less verbose code and lower memory requirements and the right tool for the job. HTH.


🦛

Replies are listed 'Best First'.
Re^2: Problem filling Excel cells with Solid Colour: Arrays
by merrymonk (Hermit) on Mar 03, 2021 at 11:04 UTC
    Thanks I did. I just did it this way to change from a hash with keys which were names to simple numbers.

      Without any further context that sounds like a really bad idea. Names convey meaning and help reduce errors.

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
      Update - I found the solution - it is in the line below where Interior can have simply Color
      $sheet->Range($rng)->Interior ->{Color} = $patterncolour;
      to fill the cell.
      However it would be good to know why the solid colour definition does not work