Calcul de la formule de table de données en tableau avec Python.NET

Contents
[ ]

Dans l’exemple suivant, nous utilisons le fichier Excel source. Si vous changez la valeur de la cellule B1 en 100, les valeurs du tableau de données (surlignées en jaune) se mettront à jour à 120 comme le montrent les captures d’écran ci-dessous. Le code Python génère ce PDF de sortie.

todo:image_alt_text

todo:image_alt_text

Voici l’implémentation Python démontrant comment générer le PDF de sortie à partir du fichier Excel source :

import os
from aspose.cells import Workbook

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

# Create workbook from source excel file
workbook = Workbook(os.path.join(data_dir, "DataTable.xlsx"))

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

# When you will put 100 in B1, then all Data Table values formatted as Yellow will become 120
worksheet.cells.get("B1").put_value(100)

# Calculate formula, now it also calculates Data Table array formula
workbook.calculate_formula()

# Save the workbook in pdf format
workbook.save(os.path.join(data_dir, "output_out.pdf"))

Explication du code Python :

import aspose.cells as ac

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

# Calculate formulas using Python.NET API
workbook.calculate_formula()

# Save the workbook in PDF format
workbook.save("5115538.pdf", ac.SaveFormat.PDF)