Supporto per la firma XAdES
Contents
[
Hide
]
Introduzione
Aspose.Cells per Python via .NET supporta la firma di workbooks con la firma XAdES. Per questo, l’API fornisce le classi DigitalSignature e le enumerazioni XAdESType.
Come Aggiungere la Firma XAdES per Excel
Il seguente frammento di codice dimostra l’uso della classe DigitalSignature per firmare il workbook source.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import Workbook | |
from aspose.cells.digitalsignatures import DigitalSignature, DigitalSignatureCollection, XAdESType | |
from datetime import datetime | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
sourceDir = RunExamples.Get_SourceDirectory() | |
# Output directory | |
outputDir = RunExamples.Get_OutputDirectory() | |
workbook = Workbook(sourceDir + "sourceFile.xlsx") | |
password = "pfxPassword" | |
pfx = "pfxFile" | |
signature = DigitalSignature(open(pfx, "rb").read(), password, "testXAdES", datetime.now()) | |
signature.x_ad_es_type = XAdESType.X_AD_ES | |
dsCollection = DigitalSignatureCollection() | |
dsCollection.add(signature) | |
workbook.set_digital_signature(dsCollection) | |
workbook.save(outputDir + "XAdESSignatureSupport_out.xlsx") |