使用C++的Node.js计算数据表数组公式
Contents
[
Hide
]
你可以在Microsoft Excel中通过数据 > 假设分析 > 数据表创建数据表……。Aspose.Cells现支持计算数据表的数组公式。请正常使用Workbook.calculateFormula()以计算任何类型的公式。
在以下示例代码中,我们使用了source excel file。如果您将单元格B1的值更改为100,则填充为黄色的数据表的值将变为120,如下图所示。 示例代码生成了output PDF。
以下是用于从source excel file生成output PDF的示例代码。 请阅读注释以获取更多信息。
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Create workbook from source excel file
const workbook = new AsposeCells.Workbook(path.join(dataDir, "DataTable.xlsx"));
// Access first worksheet
const worksheet = workbook.getWorksheets().get(0);
// When you will put 100 in B1, then all Data Table values formatted as Yellow will become 120
worksheet.getCells().get("B1").putValue(100);
// Calculate formula, now it also calculates Data Table array formula
workbook.calculateFormula();
// Save the workbook in pdf format
workbook.save(path.join(dataDir, "output_out.pdf"));