in reply to Re: Conditional Formatting with Spreadsheet::WriteExcel
in thread Conditional Formatting with Spreadsheet::WriteExcel
#!/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 } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Conditional Formatting with Spreadsheet::WriteExcel
by jmcnamara (Monsignor) on Jan 04, 2006 at 10:14 UTC | |
|
Re^3: Conditional Formatting with Spreadsheet::WriteExcel
by prasadbabu (Prior) on Jan 04, 2006 at 09:34 UTC |