DataBar

Inheritance: java.lang.Object

public class DataBar

Describe the DataBar conditional formatting rule. This conditional formatting rule displays a gradated data bar in the range of cells.

Example

         //Instantiating a Workbook object
         Workbook workbook = new Workbook();
 
         Worksheet sheet = workbook.getWorksheets().get(0);
 
         //Adds an empty conditional formatting
         int index = sheet.getConditionalFormattings().add();
 
         FormatConditionCollection fcs = sheet.getConditionalFormattings().get(index);
 
         //Sets the conditional format range.
         CellArea ca = new CellArea();
 
         ca.StartRow = 0;
 
         ca.EndRow = 2;
 
         ca.StartColumn = 0;
 
         ca.EndColumn = 0;
 
         fcs.addArea(ca);
 
         //Adds condition.
         int idx = fcs.addCondition(FormatConditionType.DATA_BAR);
 
         fcs.addArea(ca);
 
         FormatCondition cond = fcs.get(idx);
 
         //Get Databar
         DataBar dataBar = cond.getDataBar();
 
         dataBar.setColor(Color.getOrange());
 
         //Set Databar properties
         dataBar.getMinCfvo().setType(FormatConditionValueType.PERCENTILE);
 
         dataBar.getMinCfvo().setValue(30);
 
         dataBar.setShowValue(false);
 
         dataBar.getBarBorder().setType(DataBarBorderType.SOLID);
 
         dataBar.getBarBorder().setColor(Color.getPlum());
 
          dataBar.setBarFillType(DataBarFillType.SOLID);
 
          dataBar.setAxisColor(Color.getRed());
 
          dataBar.setAxisPosition(DataBarAxisPosition.MIDPOINT);
 
          dataBar.getNegativeBarFormat().setColorType(DataBarNegativeColorType.COLOR);
 
          dataBar.getNegativeBarFormat().setColor(Color.getWhite());
 
          dataBar.getNegativeBarFormat().setBorderColorType(DataBarNegativeColorType.COLOR);
 
          dataBar.getNegativeBarFormat().setBorderColor(Color.getYellow());
 
         //Put Cell Values
         Cell cell1 = sheet.getCells().get("A1");
 
         cell1.putValue(10);
 
         Cell cell2 = sheet.getCells().get("A2");
 
         cell2.putValue(120);
 
         Cell cell3 = sheet.getCells().get("A3");
 
         cell3.putValue(260);
 
         //Saving the Excel file
         workbook.save("book1.xlsx");

Methods

MethodDescription
equals(Object arg0)
getAxisColor()Gets the color of the axis for cells with conditional formatting as data bars.
getAxisPosition()Gets the position of the axis of the data bars specified by a conditional formatting rule.
getBarBorder()Gets an object that specifies the border of a data bar.
getBarFillType()Gets how a data bar is filled with color.
getClass()
getColor()Gets this DataBar’s Color.
getDirection()Gets the direction the databar is displayed.
getMaxCfvo()Gets this DataBar’s max value object.
getMaxLength()Represents the max length of data bar .
getMinCfvo()Gets this DataBar’s min value object.
getMinLength()Represents the min length of data bar .
getNegativeBarFormat()Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.
getShowValue()Gets the flag indicating whether to show the values of the cells on which this data bar is applied.
hashCode()
notify()
notifyAll()
setAxisColor(Color value)Gets the color of the axis for cells with conditional formatting as data bars.
setAxisPosition(int value)Sets the position of the axis of the data bars specified by a conditional formatting rule.
setBarFillType(int value)Sets how a data bar is filled with color.
setColor(Color value)Sets this DataBar’s Color.
setDirection(int value)Sets the direction the databar is displayed.
setMaxLength(int value)Represents the max length of data bar .
setMinLength(int value)Represents the min length of data bar .
setShowValue(boolean value)Sets the flag indicating whether to show the values of the cells on which this data bar is applied.
toImage(Cell cell, ImageOrPrintOptions imgOpts)Render data bar in cell to image byte array.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getAxisColor()

public Color getAxisColor()

Gets the color of the axis for cells with conditional formatting as data bars.

Returns: Color

getAxisPosition()

public int getAxisPosition()

Gets the position of the axis of the data bars specified by a conditional formatting rule.

See DataBarAxisPosition.

Returns: int

getBarBorder()

public DataBarBorder getBarBorder()

Gets an object that specifies the border of a data bar.

Returns: DataBarBorder

getBarFillType()

public int getBarFillType()

Gets how a data bar is filled with color.

See DataBarFillType.

Returns: int

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getColor()

public Color getColor()

Gets this DataBar’s Color.

Returns: Color

getDirection()

public int getDirection()

Gets the direction the databar is displayed.

See TextDirectionType.

Returns: int

getMaxCfvo()

public ConditionalFormattingValue getMaxCfvo()

Gets this DataBar’s max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.

Returns: ConditionalFormattingValue

getMaxLength()

public int getMaxLength()

Represents the max length of data bar .

Returns: int

getMinCfvo()

public ConditionalFormattingValue getMinCfvo()

Gets this DataBar’s min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.

Returns: ConditionalFormattingValue

getMinLength()

public int getMinLength()

Represents the min length of data bar .

Returns: int

getNegativeBarFormat()

public NegativeBarFormat getNegativeBarFormat()

Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.

Returns: NegativeBarFormat

getShowValue()

public boolean getShowValue()

Gets the flag indicating whether to show the values of the cells on which this data bar is applied. Default value is true.

Returns: boolean

hashCode()

public native int hashCode()

Returns: int

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

setAxisColor(Color value)

public void setAxisColor(Color value)

Gets the color of the axis for cells with conditional formatting as data bars.

Parameters:

ParameterTypeDescription
valueColor

setAxisPosition(int value)

public void setAxisPosition(int value)

Sets the position of the axis of the data bars specified by a conditional formatting rule.

See DataBarAxisPosition.

Parameters:

ParameterTypeDescription
valueint

setBarFillType(int value)

public void setBarFillType(int value)

Sets how a data bar is filled with color.

See DataBarFillType.

Parameters:

ParameterTypeDescription
valueint

setColor(Color value)

public void setColor(Color value)

Sets this DataBar’s Color.

Parameters:

ParameterTypeDescription
valueColor

setDirection(int value)

public void setDirection(int value)

Sets the direction the databar is displayed.

See TextDirectionType.

Parameters:

ParameterTypeDescription
valueint

setMaxLength(int value)

public void setMaxLength(int value)

Represents the max length of data bar .

Parameters:

ParameterTypeDescription
valueint

setMinLength(int value)

public void setMinLength(int value)

Represents the min length of data bar .

Parameters:

ParameterTypeDescription
valueint

setShowValue(boolean value)

public void setShowValue(boolean value)

Sets the flag indicating whether to show the values of the cells on which this data bar is applied. Default value is true.

Parameters:

ParameterTypeDescription
valueboolean

toImage(Cell cell, ImageOrPrintOptions imgOpts)

public byte[] toImage(Cell cell, ImageOrPrintOptions imgOpts)

Render data bar in cell to image byte array.

Parameters:

ParameterTypeDescription
cellCellIndicate the data bar in which cell to be rendered
imgOptsImageOrPrintOptionsImageOrPrintOptions contains some property of output image

Returns: byte[] -

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