Utilisation de la fonction FormulaText dans Aspose.Cells

Contents
[ ]

Le code d’exemple suivant montre l’utilisation de FormulaText avec Aspose.Cells. Le code écrit d’abord une formule dans la cellule A1, puis imprime le texte de la formule en utilisant FormulaText dans la cellule A2.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create a workbook object
Workbook workbook = new Workbook();
// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Put some formula in cell A1
Cell cellA1 = worksheet.Cells["A1"];
cellA1.Formula = "=Sum(B1:B10)";
// Get the text of the formula in cell A2 using FORMULATEXT function
Cell cellA2 = worksheet.Cells["A2"];
cellA2.Formula = "=FormulaText(A1)";
// Calculate the workbook
workbook.CalculateFormula();
// Print the results of A2, It will now print the text of the formula inside cell A1
Console.WriteLine(cellA2.StringValue);

Sortie console

Voici la sortie de la console du code d’exemple ci-dessus.

 =SUM(B1:B10)