Calculation of Array Formula of Data Tables
Contents
[
Hide
]
You can create Data Table in Microsoft Excel using Data > What-If Analysis > Data Table…. Aspose.Cells now allows you to calculate the array formula of a data table. Please use Workbook.CalculateFormula() as normal for calculating any type of formulas.
In the following sample code, we used the source excel file. If you change the value of cell B1 to 100, the values of the Data Table which are filled with Yellow color will become 120 as shown in the following images. The sample code generates the output PDF.
Here is the sample code used to generate the output PDF from the source excel file. Please read the comments for more information.
This file contains hidden or 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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook from source excel file | |
Workbook workbook = new Workbook(dataDir + "DataTable.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// When you will put 100 in B1, then all Data Table values formatted as Yellow will become 120 | |
worksheet.Cells["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_out.pdf"); |