my $funky = $workbook->add_format( color => 42 ); # ... $worksheet->write( $i, $j, $val, $val < 0 ? $funky : () );