通过指定数据范围和 Sparkline 组的位置来复制 Sparkline
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"); |