public class DataBar
extends java.lang.Object
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");
| Modifier and Type | Method and Description |
|---|---|
Color |
getAxisColor()
Gets the color of the axis for cells with conditional formatting as data bars.
|
int |
getAxisPosition()
Gets the position of the axis of the data bars specified by a conditional formatting rule.
|
DataBarBorder |
getBarBorder()
Gets an object that specifies the border of a data bar.
|
int |
getBarFillType()
Gets how a data bar is filled with color.
|
Color |
getColor()
Gets this DataBar's Color.
|
int |
getDirection()
Gets the direction the databar is displayed.
|
ConditionalFormattingValue |
getMaxCfvo()
Gets this DataBar's max value object.
|
int |
getMaxLength()
Represents the max length of data bar .
|
ConditionalFormattingValue |
getMinCfvo()
Gets this DataBar's min value object.
|
int |
getMinLength()
Represents the min length of data bar .
|
NegativeBarFormat |
getNegativeBarFormat()
Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.
|
boolean |
getShowValue()
Gets the flag indicating whether to show the values of the cells on which this data bar is applied.
|
void |
setAxisColor(Color value)
Gets the color of the axis for cells with conditional formatting as data bars.
|
void |
setAxisPosition(int value)
Sets the position of the axis of the data bars specified by a conditional formatting rule.
|
void |
setBarFillType(int value)
Sets how a data bar is filled with color.
|
void |
setColor(Color value)
Sets this DataBar's Color.
|
void |
setDirection(int value)
Sets the direction the databar is displayed.
|
void |
setMaxLength(int value)
Represents the max length of data bar .
|
void |
setMinLength(int value)
Represents the min length of data bar .
|
void |
setShowValue(boolean value)
Sets the flag indicating whether to show the values of the cells on which this data bar is applied.
|
byte[] |
toImage(Cell cell,
ImageOrPrintOptions imgOpts)
Render data bar in cell to image byte array.
|
public Color getAxisColor()
public void setAxisColor(Color value)
public int getAxisPosition()
See DataBarAxisPosition.
public void setAxisPosition(int value)
See DataBarAxisPosition.
public int getBarFillType()
See DataBarFillType.
public void setBarFillType(int value)
See DataBarFillType.
public int getDirection()
See TextDirectionType.
public void setDirection(int value)
See TextDirectionType.
public DataBarBorder getBarBorder()
public NegativeBarFormat getNegativeBarFormat()
public ConditionalFormattingValue getMinCfvo()
public ConditionalFormattingValue getMaxCfvo()
public Color getColor()
public void setColor(Color value)
public int getMinLength()
public void setMinLength(int value)
public int getMaxLength()
public void setMaxLength(int value)
public boolean getShowValue()
public void setShowValue(boolean value)
public byte[] toImage(Cell cell, ImageOrPrintOptions imgOpts)
cell - Indicate the data bar in which cell to be renderedimgOpts - ImageOrPrintOptions contains some property of output imageSee Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.