const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const sourceDir = path.join(__dirname, "data/");
const outputDir = path.join(__dirname, "output/");

// Instantiating a Workbook object
// Opening the Excel file through the file stream
const workbook = new AsposeCells.Workbook(`${sourceDir}Date.xlsx`);

// Accessing the first worksheet in the Excel file
const worksheet = workbook.getWorksheets().get(0);

// Call DynamicFilter function to apply the filter
worksheet.getAutoFilter().dynamic_Filter(0, AsposeCells.DynamicFilterType.January);

// Call refresh function to update the worksheet
worksheet.getAutoFilter().refresh();

// Saving the modified Excel file
workbook.save(`${outputDir}FilteredDynamicDate.xlsx`);