use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; my $parser = new Spreadsheet::ParseExcel::SaveParser; my $sheet=1; my $template = $parser->Parse('compare_reports/38_HMI1071_cre_cdo_G.xls'); my $worksheet = $template->worksheet($sheet); my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range(); for my $col ( $col_min+2 .. $col_max ) { for my $row ( $row_min+2 .. $row_max ) { #print "\n row, col=$row,$col"; my $cell = $worksheet->get_cell($row, $col); if(!$cell){ next; } elsif($worksheet->get_cell($row,$col)->value() ne "" ){ my $cell_val=$worksheet->get_cell($row,$col)->value(); my $cell_format = $worksheet->get_cell($row,$col)->{FormatNo}; print "\n row, col=$row,$col cell_format= $cell_format, value= $cell_val"; if($cell_format eq 26){ my $left_val=$worksheet->get_cell(0,$col)->value(); my $right_val=$worksheet->get_cell(0,$col)->value(); #Format my $iF1 = $template->AddFont( Name => 'Arial', Height => 11, Bold => 0, #Bold Italic => 0, #Italic Underline => 0, Strikeout => 0, Super => 0, ); my $iFmt = $template->AddFormat( Font => $template->{Font}[$iF1], Fill => [1, 10, 0], # Filled with Red # cf. ParseExcel (@aColor) #BdrStyle => [0, 1, 1, 0], #Border Right, Top #BdrColor => [0, 11, 0, 0], # Right->Green ); $template->AddCell($sheet, 0, $col,$left_val , $iFmt); $template->AddCell($sheet, 1, $col,$right_val , $iFmt); last; } } else { next; } } } my $workbook; { local $^W = 0; $workbook = $template->SaveAs($com_path); } $workbook->close(); push(@temp_files,$_); }