通过指定迷你图组的数据范围和位置来复制迷你图
Contents
[
Hide
]
Microsoft Excel 允许您通过指定迷你图组的数据范围和位置来复制迷你图。 Aspose.Cells 支持此功能。
要将迷你图复制到 Microsoft Excel 中的其他单元格:
- 选择包含迷你图的单元格。
- 选择编辑数据来自迷你图的部分设计标签。
- 选择编辑组位置和数据.
- 指定数据范围和位置。
- 点击好的.
Aspose.Cells 提供 SparklineCollection.Add(dataRange, row, column) 方法来指定迷你图组的数据范围和位置。以下示例代码加载源 Excel 文件,如上面的屏幕截图所示,然后访问第一个迷你图组并在迷你图组中添加数据范围和位置。最后,它将输出的 Excel 文件写入磁盘,如上图所示。
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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook from source Excel file | |
Workbook workbook = new Workbook(dataDir + "source.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access the first sparkline group | |
SparklineGroup group = worksheet.SparklineGroups[0]; | |
// Add Data Ranges and Locations inside this sparkline group | |
group.Sparklines.Add("D5:O5", 4, 15); | |
group.Sparklines.Add("D6:O6", 5, 15); | |
group.Sparklines.Add("D7:O7", 6, 15); | |
group.Sparklines.Add("D8:O8", 7, 15); | |
// Save the workbook | |
workbook.Save(dataDir + "output_out.xlsx"); |