#!/usr/bin/perl use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new("test.xls"); my $worksheet = $workbook->add_worksheet(); my $format_heading = $workbook->add_format(); my $condition = "a"; getFormat($condition); $worksheet->write("A1", "sometext", $format_heading); $condition = "c"; getFormat($condition); $worksheet->write("A2", "sometext", $format_heading); $condition = "d"; getFormat($condition); $worksheet->write("A3", "sometext", $format_heading); $condition = "b"; getFormat($condition); $worksheet->write("A4", "sometext", $format_heading); sub getFormat { $condition = shift; if ($condition eq 'a'){ $format_heading->set_bg_color('yellow'); } elsif ($condition eq 'b'){ $format_heading->set_bg_color('pink'); } elsif ($condition eq 'c'){ $format_heading->set_bg_color('blue'); } else { $format_heading->set_bg_color('green'); # Default color } }
In reply to Re^2: Conditional Formatting with Spreadsheet::WriteExcel
by shilpam
in thread Conditional Formatting with Spreadsheet::WriteExcel
by shilpam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |