数据表的数组公式计算
Contents
[
Hide
]
您可以使用数据 > 此后数据 > 数据表…在Microsoft Excel中创建数据表。Aspose.Cells现在允许您计算数据表的数组公式。请使用Workbook.calculateFormula()正常计算任何类型的公式。
计算数据表的数组公式
在下面的示例代码中,我们使用了这个源Excel文件,它也显示在下面的图像中。
如果修改单元格B1的值为100,则黄色填充的数据表中的值将变为120。示例代码生成了输出PDF,其中显示了数据表中的值为120,如下图所示。
这是用于从源Excel文件生成输出PDF的示例代码。有关更多信息,请阅读注释。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |