通过Node.js和C++显示公式而非值在工作表中,示例代码
Contents
[
Hide
]
可以在Microsoft Excel中使用“公式”功能区的“显示公式”选项,显示公式而非计算的值。启用后,Excel会在工作表中显示公式。你也可以通过Aspose.Cells for Node.js via C++实现相同的效果。
Aspose.Cells提供了一个Worksheet.getShowFormulas()属性。将其设置为true,即可让Microsoft Excel显示公式。
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, "source.xlsx");
// Load the source workbook
const workbook = new AsposeCells.Workbook(filePath);
// Access the first worksheet
const worksheet = workbook.getWorksheets().get(0);
// Show formulas of the worksheet
worksheet.setShowFormulas(true);
// Save the workbook
workbook.save(path.join(dataDir, ".out.xlsx"));