mike5091231 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am looking to make the background of and excel cell (22,31) Yellow. The following is the code i have so far. Any help would be greatly appreciated.
# get already active Excel application or open new my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); # open Excel file my $Book = $Excel->Workbooks->Open("C:\\tester.xls"); my $Sheet = $Book->Worksheets(1); $Sheet->Cells(22,31)->{'Value'} = $open;
(sorry for the repost, ahd to make an edit) (not sure if my original got posted)

Replies are listed 'Best First'.
Re: Changing the background color of an excel cell
by jonix (Friar) on Oct 28, 2005 at 14:43 UTC
Re: Changing the background color of an excel cell
by muntfish (Chaplain) on Oct 28, 2005 at 14:43 UTC

    Add the following:

    $Sheet->Cells(22,31)->{Interior}->{ColorIndex} = 6;

    Update: it should also be possible to do:

    $Sheet->Cells(22,31)->{Interior}->{Color} = $Excel->RGB(255,255,0);

    Update 2: you can pack the RGB values manually and this seems to work:

    $Sheet->Cells(1,1)->{Interior}->{Color} = ($blue << 16) + ($green << 8) + $red;

    Hope this helps!


    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&
      This is one of easiest things to do  $Sheet->Range("A4:A8")->{Interior}->{Color} = 255;