use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; my $parser = Spreadsheet::ParseExcel->new(); my $workbook_parse = $parser->Parse( 'Report.xls' ); my $worksheet_parse = $workbook_parse->Worksheet( "Health_Report" ); my ( $col_min, $col_max ) = $worksheet_parse->col_range(); my ( $row_min, $row_max ) = $worksheet_parse->row_range(); my $workbook = Spreadsheet::WriteExcel->new( "Report_new.xls" ); my $worksheet = $workbook->addworksheet( "Health_Report" ); my $bkgd_color = $workbook->addformat(); for my $col ( $col_min .. $col_max ) { for my $row ( $row_min .. $row_max ) { # Return the cell object at $row and $col my $cell = $worksheet_parse->get_cell( $row, $col ); next unless $cell; my $value = $cell->value(); my $format = $cell->get_format(); my $backgroundcolor = $format->{Fill}->[2]; print "Row, Col = ($row, $col) "; print "Value = $value\n"; print "Format = $backgroundcolor\n"; $bkgd_color->set_bg_color( $backgroundcolor ); ### Here trying to rewrite into Excel and apply the ### same background color which the cell had previously $worksheet->write( $row, $col, $value, $bkgd_color ); } } #### Format = 65 Row, Col = (25, 4) Value = -115966 Format = 65 Row, Col = (10, 5) Value = 20170417 Format = 65 Row, Col = (11, 5) Value = 0 Format = 64 Row, Col = (16, 5) Value = 0 Format = 64