插入迷你图
Contents
[
Hide
]
插入火花线
火花线是工作表单元格中的微小图表,用于提供数据的可视化表示。使用火花线来显示一系列值的趋势,如季节性增加或减少、经济周期或突出最大和最小值。将火花线放置在其数据附近以获得最大的影响。火花线有三种类型:折线、柱状和堆叠。
使用以下示例代码,利用Aspose.Cells轻松创建一个火花线:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Instantiating a Workbook object | |
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(SparklineType.LINE, "!A1:D1", false, ca); | |
SparklineGroup group = sheet.getSparklineGroupCollection().get(idx); | |
group.getSparklineCollection().add("!A1:D1", 0, 4); | |
// Saving the Excel file | |
book.Save("output.xlsx"); |