PivotFormatCondition

Inheritance: java.lang.Object

public class PivotFormatCondition

Represents a PivotTable Format Condition in PivotFormatCondition Collection.

Example

         Workbook book = new Workbook();
         Worksheet sheet = book.getWorksheets().get(0);
         Cells cells = sheet.getCells();
         cells.get(0, 0).setValue("fruit");
         cells.get(1, 0).setValue("grape");
         cells.get(2, 0).setValue("blueberry");
         cells.get(3, 0).setValue("kiwi");
         cells.get(4, 0).setValue("cherry");
         cells.get(5, 0).setValue("grape");
         cells.get(6, 0).setValue("blueberry");
         cells.get(7, 0).setValue("kiwi");
         cells.get(8, 0).setValue("cherry");
 
         cells.get(0, 1).setValue("year");
         cells.get(1, 1).setValue(2020);
         cells.get(2, 1).setValue(2020);
         cells.get(3, 1).setValue(2020);
         cells.get(4, 1).setValue(2020);
         cells.get(5, 1).setValue(2021);
         cells.get(6, 1).setValue(2021);
         cells.get(7, 1).setValue(2021);
         cells.get(8, 1).setValue(2021);
 
         cells.get(0, 2).setValue("amount");
         cells.get(1, 2).setValue(50);
         cells.get(2, 2).setValue(60);
         cells.get(3, 2).setValue(70);
         cells.get(4, 2).setValue(80);
         cells.get(5, 2).setValue(90);
         cells.get(6, 2).setValue(100);
         cells.get(7, 2).setValue(110);
         cells.get(8, 2).setValue(120);
 
         PivotTableCollection pivots = sheet.getPivotTables();
 
         int pivotIndex = pivots.add("=Sheet1!A1:C9", "A12", "TestPivotTable");
         PivotTable pivot = pivots.get(pivotIndex);
         pivot.addFieldToArea(PivotFieldType.ROW, "fruit");
         pivot.addFieldToArea(PivotFieldType.COLUMN, "year");
         pivot.addFieldToArea(PivotFieldType.DATA, "amount");
 
         pivot.setPivotTableStyleType(PivotTableStyleType.PIVOT_TABLE_STYLE_MEDIUM_10);
 
         //Add PivotFormatCondition
         int formatIndex = pivot.getPivotFormatConditions().add();
         PivotFormatCondition pfc = pivot.getPivotFormatConditions().get(formatIndex);
         FormatConditionCollection fcc = pfc.getFormatConditions();
         fcc.addArea(pivot.getDataBodyRange());
         int idx = fcc.addCondition(FormatConditionType.CELL_VALUE);
         FormatCondition fc = fcc.get(idx);
         fc.setFormula1("100");
         fc.setOperator(OperatorType.GREATER_OR_EQUAL);
         fc.getStyle().setBackgroundColor(Color.getRed());
 
         pivot.refreshData();
         pivot.calculateData();
 
         //do your business
 
         book.save("out.xlsx");

Methods

MethodDescription
addColumnAreaCondition(PivotField columnField)Adds PivotTable conditional format limit in the column fields.
addColumnAreaCondition(String fieldName)Adds PivotTable conditional format limit in the column fields.
addDataAreaCondition(PivotField dataField)Adds PivotTable conditional format limit in the data fields.
addDataAreaCondition(String fieldName)Adds PivotTable conditional format limit in the data fields.
addRowAreaCondition(PivotField rowField)Adds PivotTable conditional format limit in the row fields.
addRowAreaCondition(String fieldName)Adds PivotTable conditional format limit in the row fields.
equals(Object arg0)
getClass()
getFormatConditions()Get formatconditions for the pivot table condition format .
getRuleType()Gets rule type for the pivot table condition format .
getScopeType()Gets scope type for the pivot table condition format .
hashCode()
notify()
notifyAll()
setConditionalAreas()Sets conditional areas of PivotFormatCondition object.
setRuleType(int value)Sets rule type for the pivot table condition format .
setScopeType(int value)Sets scope type for the pivot table condition format .
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

addColumnAreaCondition(PivotField columnField)

public void addColumnAreaCondition(PivotField columnField)

Adds PivotTable conditional format limit in the column fields.

Parameters:

ParameterTypeDescription
columnFieldPivotFieldThe PivotField in the column fields.

addColumnAreaCondition(String fieldName)

public void addColumnAreaCondition(String fieldName)

Adds PivotTable conditional format limit in the column fields.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe name of PivotField.

addDataAreaCondition(PivotField dataField)

public void addDataAreaCondition(PivotField dataField)

Adds PivotTable conditional format limit in the data fields.

Parameters:

ParameterTypeDescription
dataFieldPivotFieldThe PivotField in the data fields.

addDataAreaCondition(String fieldName)

public void addDataAreaCondition(String fieldName)

Adds PivotTable conditional format limit in the data fields.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe name of PivotField.

addRowAreaCondition(PivotField rowField)

public void addRowAreaCondition(PivotField rowField)

Adds PivotTable conditional format limit in the row fields.

Parameters:

ParameterTypeDescription
rowFieldPivotFieldThe PivotField in the row fields.

addRowAreaCondition(String fieldName)

public void addRowAreaCondition(String fieldName)

Adds PivotTable conditional format limit in the row fields.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe name of PivotField.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getFormatConditions()

public FormatConditionCollection getFormatConditions()

Get formatconditions for the pivot table condition format .

Returns: FormatConditionCollection

getRuleType()

public int getRuleType()

Gets rule type for the pivot table condition format .

See PivotConditionFormatRuleType.

Returns: int

getScopeType()

public int getScopeType()

Gets scope type for the pivot table condition format .

See PivotConditionFormatScopeType.

Returns: int

hashCode()

public native int hashCode()

Returns: int

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

setConditionalAreas()

public void setConditionalAreas()

Sets conditional areas of PivotFormatCondition object.

setRuleType(int value)

public void setRuleType(int value)

Sets rule type for the pivot table condition format .

See PivotConditionFormatRuleType.

Parameters:

ParameterTypeDescription
valueint

setScopeType(int value)

public void setScopeType(int value)

Sets scope type for the pivot table condition format .

See PivotConditionFormatScopeType.

Parameters:

ParameterTypeDescription
valueint

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int