For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2006 > excel conditional format









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author excel conditional format
Ed Panni

2006-07-10, 6:57 pm

Hi, This is my first post and I am not really a highly skilled
programmer . I just hack some..



Anyway I have written a script in perl to use OLE and scan some
performance log files that I created and place them into an excel spread
sheet and do performance comparisons. I have gotten most of the stuff to
work but am trying to set up a conditional formatted cell to be green if
it is >= 2% and red if it is <=2%.



I have trolled examples and don't see anything that points me in the
right direction.



I have attached the portion of the script that sets up my spreadsheet. I
have been able to make the text turn red if it is less than the
comparison number. However, like I stated above I want a conditional
format of the cell for the +-2% change



Any help would be appreciated





Regards,



Ed Panni



# Setup spreadsheet



$column = 'A';

# Set column with for Column "A"

$ex->Columns("$column:$column")->{'ColumnWidth'} = 26.0;

# Change to Arial Font

$ex->Range("$column:$column")->Font->{'Name'} = "Arial";

# Size 8

$ex->Range("$column:$column")->Font->{'Size'} = 8;



$column = 'B';

# Set column with for Column "B"

$ex->Columns("$column:$column")->{'ColumnWidth'} = 13.0;

# Change to Arial Font

$ex->Range("$column:$column")->Font->{'Name'} = "Arial";

# Size 8

$ex->Range("$column:$column")->Font->{'Size'} = 8;

# Color Column

# $ex->Range("$column:$column")->Interior->{ColorIndex} = 36; # 36
== LtYelllow

# set data format

$ex->Range("$column:$column")->{'NumberFormat'} = "0.00";



$column = 'C';

# Set column with for Column "C"

$ex->Columns("$column:$column")->{'ColumnWidth'} = 8.43;

# Change to Arial Font

$ex->Range("$column:$column")->Font->{'Name'} = "Arial";

# Size 8

$ex->Range("$column:$column")->Font->{'Size'} = 8;

# Color Column

$ex->Range("$column:$column")->Interior->{ColorIndex} = 15; # 15 ==
LtGrey

# set percentage Color and format

$ex->Range("$column:$column")->{'NumberFormat'} =
"0.00%;[Red]0.00%";

#$ex->Range("$column:$column")->{'NumberFormat'} =
"[Green]0.00%;0.00%";

#$ex->Range("$column:$column")->Borders->{'Style'} = 2;



$column = D;

# Set column with for Column "D"

$ex->Columns("$column:$column")->{'ColumnWidth'} = 13.0;

# Change to Arial Font

$ex->Range("$column:$column")->Font->{'Name'} = "Arial";

# Size 8

$ex->Range("$column:$column")->Font->{'Size'} = 8;

# Set the Font color of the Data Column to blue

# $ex->Columns("$column:$column")->Font->{'ColorIndex'} = 5;

# Color Column

# $ex->Range("$column:$column")->Interior->{ColorIndex} = 40; # 6 ==
yellow

# set data format

$ex->Range("$column:$column")->{'NumberFormat'} = "0.00";


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com