Aspose.CellsとPython.NETを使用したFormulaText関数の利用例

以下のサンプルコードは、Aspose.Cellsを使用したFORMULATEXTの例です。まずセルA1に数式を書き込み、次にセルA2でFORMULATEXTを使って数式のテキストを表示します。

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)

コンソール出力

上記サンプルコードのコンソール出力は次のとおりです:

=SUM(B1:B10)