Example:
# Instantiating a Workbook object workbook = Workbook() sheet = workbook.getWorksheets().get(0) # Adds an empty conditional formatting index = sheet.getConditionalFormattings().add() fcs = sheet.getConditionalFormattings().get(index) # Sets the conditional format range. ca = CellArea() ca.StartRow = 0 ca.EndRow = 2 ca.StartColumn = 0 ca.EndColumn = 0 fcs.addArea(ca) # Adds condition. idx = fcs.addCondition(FormatConditionType.DATA_BAR) fcs.addArea(ca) cond = fcs.get(idx) # Get Databar dataBar = cond.getDataBar() dataBar.setColor(Color.getOrange()) # Set Databar properties dataBar.getMinCfvo().setType(FormatConditionValueType.PERCENTILE) dataBar.getMinCfvo().setValue(30) dataBar.setShowValue(False) # Put Cell Values cell1 = sheet.getCells().get("A1") cell1.putValue(10) cell2 = sheet.getCells().get("A2") cell2.putValue(120) cell3 = sheet.getCells().get("A3") cell3.putValue(260) # Saving the Excel file workbook.save("Book1.xlsx")
Property Getters/Setters Summary | ||
---|---|---|
method | getAxisColor() | |
method | setAxisColor(value) | |
Gets the color of the axis for cells with conditional formatting as data bars. | ||
method | getAxisPosition() | |
method | setAxisPosition(value) | |
Gets or sets the position of the axis of the data bars specified by a conditional formatting rule. The value of the property is DataBarAxisPosition integer constant. | ||
method | getBarBorder() | |
Gets an object that specifies the border of a data bar.
|
||
method | getBarFillType() | |
method | setBarFillType(value) | |
Gets or sets how a data bar is filled with color. The value of the property is DataBarFillType integer constant. | ||
method | getColor() | |
method | setColor(value) | |
Get or set this DataBar's Color. | ||
method | getDirection() | |
method | setDirection(value) | |
Gets or sets the direction the databar is displayed. The value of the property is TextDirectionType integer constant. | ||
method | getMaxCfvo() | |
Get or set this DataBar's max value object.
Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.
|
||
method | getMaxLength() | |
method | setMaxLength(value) | |
Represents the max length of data bar . | ||
method | getMinCfvo() | |
Get or set this DataBar's min value object.
Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.
|
||
method | getMinLength() | |
method | setMinLength(value) | |
Represents the min length of data bar . | ||
method | getNegativeBarFormat() | |
Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.
|
||
method | getShowValue() | |
method | setShowValue(value) | |
Get or set the flag indicating whether to show the values of the cells on which this data bar is applied. Default value is true. |
Method Summary | ||
---|---|---|
method | toImage(cell, imgOpts) | |
Render data bar in cell to image byte array.
|
Color getAxisColor() / setAxisColor(value)
int getAxisPosition() / setAxisPosition(value)
int getBarFillType() / setBarFillType(value)
int getDirection() / setDirection(value)
DataBarBorder getBarBorder()
NegativeBarFormat getNegativeBarFormat()
ConditionalFormattingValue getMinCfvo()
ConditionalFormattingValue getMaxCfvo()
Color getColor() / setColor(value)
int getMinLength() / setMinLength(value)
int getMaxLength() / setMaxLength(value)
boolean getShowValue() / setShowValue(value)