Einstellung des Formelfeldberechnungsmodus des Arbeitsbuchs mit Python.NET

Einstellung des Formelfeldberechnungsmodus in der Arbeitsmappe

Einstellung des Berechnungsmodus mit Aspose.Cells

Aspose.Cells für Python via .NET bietet die Konfiguration formula_settings über die Eigenschaft Workbook.settings. Verwenden Sie das Attribut calculation_mode, um das Berechnungsverhalten zu steuern.

Verfügbare Modi über das CalcModeType-Enum:

  • AUTOMATIC
  • AUTOMATIC_EXCEPT_TABLE
  • MANUAL

Implementierungsschritte:

  1. Laden Sie das vorhandene Arbeitsbuch oder erstellen Sie eine neue Instanz
  2. Zugriff auf die Arbeitseinstellungen
  3. Stellen Sie den Berechnungsmodus ein mit formula_settings.calculation_mode
  4. Speichern Sie das geänderte Arbeitsbuch
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)