插入时间轴
Contents
[
Hide
]
可能的使用场景
与调整筛选器以显示日期不同,您可以使用透视表时间轴——一种动态筛选器选项,它可让您轻松按日期/时间进行筛选,并使用滑块控件放大您想要的时间段。Microsoft Excel允许您通过选择一个透视表然后单击插入 > 时间轴来创建时间轴。Aspose.Cells还允许您使用Worksheet.Timelines.Add()方法创建时间轴。
创建时间轴到透视表
请参阅以下示例代码。它加载包含透视表的示例Excel文件,然后根据第一个基本透视字段创建时间轴。最后,它以output XLSX格式保存工作簿。以下截图显示了Aspose.Cells在输出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
// Load sample Excel file containing pivot table. | |
Workbook wb = new Workbook("input.xlsx"); | |
// Access second worksheet. | |
Worksheet sheet = wb.Worksheets[1]; | |
// Access first pivot table inside the worksheet. | |
PivotTable pivot = sheet.PivotTables[0]; | |
// Add timeline relating to pivot table | |
int index = sheet.Timelines.Add(pivot, 15, 1, "Ship Date"); | |
// Access the newly added timeline from timeline collection. | |
Timeline timeline = sheet.Timelines[index]; | |
wb.Save("output.xlsx"); |