org.apache.poi.hssf.usermodel
Class HSSFConditionalFormatting

java.lang.Object
  extended by org.apache.poi.hssf.usermodel.HSSFConditionalFormatting

public final class HSSFConditionalFormatting
extends java.lang.Object

HSSFConditionalFormatting class encapsulates all settings of Conditional Formatting. The class can be used

Use HSSFSheet#getConditionalFormattingAt(int) to get access to an instance of this class.

To create a new Conditional Formatting set use the following approach:

 
 // Define a Conditional Formatting rule, which triggers formatting
 // when cell's value is greater or equal than 100.0 and
 // applies patternFormatting defined below.
 HSSFConditionalFormattingRule rule = sheet.createConditionalFormattingRule(
     ComparisonOperator.GE, 
     "100.0", // 1st formula 
     null     // 2nd formula is not used for comparison operator GE
 );
 
 // Create pattern with red background
 HSSFPatternFormatting patternFmt = rule.cretePatternFormatting();
 patternFormatting.setFillBackgroundColor(HSSFColor.RED.index);
 
 // Define a region containing first column
 Region [] regions =
 {
     new Region(1,(short)1,-1,(short)1)
 };
     
 // Apply Conditional Formatting rule defined above to the regions  
 sheet.addConditionalFormatting(regions, rule);
 

Author:
Dmitriy Kumshayev

Method Summary
 void addRule(HSSFConditionalFormattingRule cfRule)
          add a Conditional Formatting rule.
 Region[] getFormattingRegions()
           
 int getNumberOfRules()
           
 HSSFConditionalFormattingRule getRule(int idx)
           
 void setRule(int idx, HSSFConditionalFormattingRule cfRule)
          Replaces an existing Conditional Formatting rule at position idx.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getFormattingRegions

public Region[] getFormattingRegions()
Returns:
array of Regions. never null

setRule

public void setRule(int idx,
                    HSSFConditionalFormattingRule cfRule)
Replaces an existing Conditional Formatting rule at position idx. Excel allows to create up to 3 Conditional Formatting rules. This method can be useful to modify existing Conditional Formatting rules.

Parameters:
idx - position of the rule. Should be between 0 and 2.
cfRule - - Conditional Formatting rule

addRule

public void addRule(HSSFConditionalFormattingRule cfRule)
add a Conditional Formatting rule. Excel allows to create up to 3 Conditional Formatting rules.

Parameters:
cfRule - - Conditional Formatting rule

getRule

public HSSFConditionalFormattingRule getRule(int idx)
Returns:
the Conditional Formatting rule at position idx.

getNumberOfRules

public int getNumberOfRules()
Returns:
number of Conditional Formatting rules.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright 2008 The Apache Software Foundation or its licensors, as applicable.