Support for XAdES Signature
Contents
[
Hide
]
Introduction
Aspose.Cells for Python via .NET provides supports signing workbooks with XAdES Signature. For this, the API provides DigitalSignature class and XAdESType enumeration.
How to Add XAdES Signature for Excel
The following code snippet demonstrates the use of the DigitalSignature class to sign the source workbook.
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") |