插入时间轴
Contents
[
Hide
]
可能的使用场景
你可以使用数据透视表时间线——一种动态筛选选项,轻松按日期/时间筛选,并用滑块控制放大你想要的时间段。微软Excel允许你通过选择数据透视表然后点击插入>时间线来创建时间线。Aspose.Cells for Node.js via C++还允许你使用Worksheet.getTimelines().add()方法创建时间线。
创建时间轴到透视表
请查看以下示例代码。它加载包含数据透视表的示例Excel文件。然后根据第一个基础数据透视字段创建时间线。最后,将工作簿保存为输出XLSX。下方截图显示了由Aspose.Cells for Node.js via C++在输出Excel文件中创建的时间线。
示例代码
This file contains hidden or 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
const AsposeCells = require("aspose.cells.node"); | |
// Load sample Excel file containing pivot table. | |
var wb = new AsposeCells.Workbook("input.xlsx"); | |
// Access second worksheet. | |
var sheet = wb.getWorksheets().get(1); | |
// Access first pivot table inside the worksheet. | |
var pivot = sheet.getPivotTables().get(0); | |
// Add timeline relating to pivot table | |
var index = sheet.getTimelines().add(pivot, 15, 1, "Ship Date"); | |
// Access the newly added timeline from timeline collection. | |
var timeline = sheet.getTimelines().get(index); | |
wb.save("output.xlsx"); |