通过 C++ 在 Node.js 中释放工作簿的非托管资源

Contents
[ ]

Workbook 对象现在实现了 System.IDisposable 接口,该接口包含唯一的方法 Workbook.dispose()。你可以直接调用 Workbook.dispose() 方法,或者使用 Using 语句自动调用此方法。

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

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.xlsx");
// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(filePath);

// Create workbook object
const wb1 = new AsposeCells.Workbook();

// Call Dispose method
wb1.dispose();

// Call Dispose method via a scoped approach
(async () => {
const wb2 = new AsposeCells.Workbook();
// Any other code goes here
wb2.dispose();
})();