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

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

// Source directory
const sourceDir = dataDir + "/"; // Assuming sourceDir is stored here
// Output directory
const outputDir = dataDir + "/"; // Assuming outputDir is stored here

// Instantiating a Workbook object
// Opening the Excel file through the file stream
const workbook = new AsposeCells.Workbook(sourceDir + "Blank.xlsx");

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

// Call MatchNonBlanks function to apply the filter
worksheet.getAutoFilter().matchNonBlanks(0);

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

// Saving the modified Excel file
workbook.save(outputDir + "FilteredNonBlank.xlsx");