Calculation of Array Formula of Data Tables with C++
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.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Path of input excel file
U16String inputFilePath = srcDir + u"DataTable.xlsx";
// Create workbook from source excel file
Workbook workbook(inputFilePath);
// 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(u"B1").PutValue(100);
// Calculate formula, now it also calculates Data Table array formula
workbook.CalculateFormula();
// Save the workbook in pdf format
workbook.Save(outDir + u"output_out.pdf");
std::cout << "Workbook saved successfully!" << std::endl;
Aspose::Cells::Cleanup();
}