Utilisation de la fonction FormulaText dans Aspose.Cells avec Python.NET

Contents
[ ]

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

from aspose.cells import Workbook

# Create a workbook object
workbook = Workbook()

# Access first worksheet
worksheet = workbook.worksheets[0]

# Put some formula in cell A1
cell_a1 = worksheet.cells.get("A1")
cell_a1.formula = "=Sum(B1:B10)"

# Get the text of the formula in cell A2 using FORMULATEXT function
cell_a2 = worksheet.cells.get("A2")
cell_a2.formula = "=FormulaText(A1)"

# Calculate the workbook
workbook.calculate_formula()

# Print the results of A2, It will now print the text of the formula inside cell A1
print(cell_a2.string_value)

Sortie console

Voici la sortie de la console pour le code ci-dessus :

=SUM(B1:B10)