Setting Formula Calculation Mode of Workbook with Python.NET

Setting Formula Calculation Mode in Workbook

Setting Calculation Mode with Aspose.Cells

Aspose.Cells for Python via .NET provides the formula_settings configuration through the Workbook.settings property. Use the calculation_mode attribute to control calculation behavior.

Available modes via CalcModeType enum:

  • AUTOMATIC
  • AUTOMATIC_EXCEPT_TABLE
  • MANUAL

Implementation Steps:

  1. Load existing workbook or create new instance
  2. Access workbook settings
  3. Set calculation mode using formula_settings.calculation_mode
  4. Save modified workbook
from aspose.cells import Workbook, CalcModeType

# Load source workbook
workbook = Workbook("source.xlsx")

# Configure manual calculation mode
workbook.settings.formula_settings.calculation_mode = CalcModeType.MANUAL

# Save modified workbook
workbook.save("output.xlsx")
import os
from aspose.cells import Workbook, CalcModeType, SaveFormat

# For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
current_dir = os.path.dirname(os.path.abspath(__file__))
data_dir = os.path.join(current_dir, "data")

# Create a workbook
workbook = Workbook()

# Set the Formula Calculation Mode to Manual
workbook.settings.formula_settings.calculation_mode = CalcModeType.MANUAL

# Save the workbook
output_path = os.path.join(data_dir, "output_out.xlsx")
workbook.save(output_path, SaveFormat.XLSX)