Hi Poj

Thanks a lot ! I could able to see the rows getting filled with green but I am having another requirement also , if the row matches "In Progress" , it should fill that form with Orange color. I have written below code but it is not filling the entire row which is matching with "In Progress" and only half of the row is getting filled.

#!/usr/bin/perl -w use strict; use Spreadsheet::ParseExcel; use Spreadsheet::WriteExcel; my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse('Homestead_status.xls'); if ( !defined $workbook ) { die $parser->error(), ".\n"; } my $workbook1 = Spreadsheet::WriteExcel->new('Report.xls'); my $format1 = $workbook1->add_format(bg_color => 'green'); my $format2 = $workbook1->add_format(bg_color => 'orange'); for my $worksheet ( $workbook->worksheets() ) { my $worksheet1 = $workbook1->add_worksheet(); my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range(); for my $row ( $row_min .. $row_max ) { my @value1 = (); my @value2 = (); my $fmt1; # format for complete row my $fmt2; # format for complete row # store row in array for my $col ( $col_min .. $col_max ) { my $cell = $worksheet->get_cell( $row, $col ); if (defined $cell) { $value1[$col] = $cell->value() ; $value2[$col] = $cell->value() ; $fmt1 = $format1 if ($value1[$col] =~ m/Completed/i); $fmt2 = $format2 if ($value2[$col] =~ m/In Progress/i) } } # write row for my $col ( $col_min .. $col_max ) { $worksheet1->write($row, $col, $value1[$col],$fmt1); $worksheet1->write($row, $col, $value2[$col],$fmt2); } } }

In reply to Re^2: Perl script to fill the entire row of Excel file with color based on pattern match by kshitij
in thread Perl script to fill the entire row of Excel file with color based on pattern match by kshitij

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.