Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
The following sample code shows the usage of FormulaText with Aspose.Cells. The code first writes a formula in cell A1 and then prints the text of the formula using FormulaText in cell A2.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Create a workbook object
Workbook workbook;
// Access the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Put a formula in cell A1
Cell cellA1 = worksheet.GetCells().Get(u"A1");
cellA1.SetFormula(u"=Sum(B1:B10)");
// Get the text of the formula in cell A2 using FORMULATEXT function
Cell cellA2 = worksheet.GetCells().Get(u"A2");
cellA2.SetFormula(u"=FormulaText(A1)");
// Calculate the workbook
workbook.CalculateFormula();
// Print the result of A2. It will now print the text of the formula inside cell A1
std::cout << cellA2.GetStringValue().ToUtf8() << std::endl;
Aspose::Cells::Cleanup();
return 0;
}
Here is the console output of the above sample code.
=SUM(B1:B10)
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.