Insert Timeline

Possible Usage Scenarios

Instead of adjusting filters to show dates, you can use a PivotTable Timeline——a dynamic filter option that lets you easily filter by date/time, and zoom in on the period you want with a slider control. Microsoft Excel allows you to create timeline by selecting a pivot table and then clicking the Insert > Timeline. Aspose.Cells for Node.js via C++ also allows you to create timeline using the Worksheet.getTimelines().add() method.

Create Timeline to a Pivot Table

Please see the following sample code. It loads the sample Excel file that contains the pivot table. It then creates the timeline based on the first base pivot field. Finally, it saves the workbook in output XLSX format. The following screenshot shows the timeline created by Aspose.Cells for Node.js via C++ in the output Excel file.

todo:image_alt_text

Sample Code

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");