Calculation of Array Formula of Data Tables
Calculation of Array Formula of Data Tables
In the following sample code, we used this source excel file which is also shown in the following image.
If you change the value of cell B1 to 100, the values of Data Table which are filled with Yellow color will become 120. The sample code generates the output PDF which shows 120 as values in the Data Table as shown in this image.
Here is the sample code used to generate the output PDF from the source excel file. Please read the comments for more information.
// 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"); |