Sparkline is organized into sparkline group. A SparklineGroup contains a variable number of sparkline items.
A sparkline group specifies the type, display settings and axis settings for the sparklines.
Example:
Workbook book = new Workbook();
Worksheet sheet = book.getWorksheets().get(0);
sheet.getCells().get("A1").putValue(5);
sheet.getCells().get("B1").putValue(2);
sheet.getCells().get("C1").putValue(1);
sheet.getCells().get("D1").putValue(3);
// Define the CellArea
CellArea ca = new CellArea();
ca.StartColumn = 4;
ca.EndColumn = 4;
ca.StartRow = 0;
ca.EndRow = 0;
int idx = sheet.getSparklineGroupCollection().add(com.aspose.cells.SparklineType.LINE, "A1:D1", false, ca);
SparklineGroup group = sheet.getSparklineGroupCollection().get(idx);
group.getSparklineCollection().add(sheet.getName() + "!A1:D1", 0, 4);
// Create CellsColor
CellsColor clr = book.createCellsColor();
clr.setColor(Color.getOrange());
group.setSeriesColor(clr);
// set the high points are colored green and the low points are colored red
group.setShowHighPoint(true);
group.setShowLowPoint(true);
group.getHighPointColor().setColor(Color.getGreen());
group.getLowPointColor().setColor(Color.getRed());
// set line weight
group.setLineWeight(1.0);
book.save("output.xlsx", SaveFormat.XLSX);
Resets the data range and location range of the sparkline group.
This method will clear original sparkline items in the group and creates new sparkline items for the new ranges.
Property Getters/Setters Detail
getPresetStyle/setPresetStyle
public int getPresetStyle() / public void setPresetStyle(int value)
Gets and sets the preset style type of the sparkline group.
The value of the property is SparklinePresetStyleType integer constant.
public int getVerticalAxisMinValueType() / public void setVerticalAxisMinValueType(int value)
Represents the vertical axis minimum value type.
The value of the property is SparklineAxisMinMaxType integer constant.
getVerticalAxisMinValue/setVerticalAxisMinValue
public double getVerticalAxisMinValue() / public void setVerticalAxisMinValue(double value)
Gets and sets the custom minimum value for the vertical axis.
Method Detail
resetRanges
public void resetRanges(java.lang.String dataRange, boolean isVertical, CellArea locationRange)
Resets the data range and location range of the sparkline group.
This method will clear original sparkline items in the group and creates new sparkline items for the new ranges.
Parameters:
dataRange - Specifies the new data range of the sparkline group.
isVertical - Specifies whether to plot the sparklines from the new data range by row or by column.
locationRange - Specifies where the sparklines to be placed.