数据表的数组公式计算

计算数据表的数组公式

在下面的示例代码中,我们使用了这个源Excel文件,它也显示在下面的图像中。

todo:image_alt_text

如果修改单元格B1的值为100,则黄色填充的数据表中的值将变为120。示例代码生成了输出PDF,其中显示了数据表中的值为120,如下图所示。

todo:image_alt_text

这是用于从源Excel文件生成输出PDF的示例代码。有关更多信息,请阅读注释。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getDataDir(CalculationOfArrayFormula.class);
// Create workbook from source excel file
Workbook workbook = new Workbook(dataDir + "DataTable.xlsx");
// Access first worksheet
Worksheet 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(dataDir + "output.pdf");