Add Digital Signature to an already signed Excel file

Possible Usage Scenarios

Aspose.Cells for Python via .NET provides the Workbook.add_digital_signature method that you can use to add digital signature to an already signed Excel file.

How to Add Digital Signature to an Already Signed Excel File

The following sample code demonstrated how to make use of Workbook.add_digital_signature method to add digital signature to already signed Excel file. Please check the sample Excel file used in this code. This file is already digitally signed. Please check the output Excel file generated by the code. We have used the demo certificate named AsposeDemo.pfx in this code which has a password aspose. The screenshot shows the effect of the sample code on the sample Excel file after execution.

todo:image_alt_text

Sample Code

from aspose.cells import Workbook
from aspose.cells.digitalsignatures import DigitalSignature, DigitalSignatureCollection
from datetime import datetime
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Load the workbook which is already digitally signed to add new digital signature
workbook = Workbook(sourceDir + "sampleDigitallySignedByCells.xlsx")
# Create the digital signature collection
dsCollection = DigitalSignatureCollection()
# Create new digital signature and add it in digital signature collection
# Cert must contain private key, it can be contructed from cert file or windows certificate collection. aa is password of cert
rawData = None
password = None
signature = DigitalSignature(rawData, password, "Aspose.Cells added new digital signature in existing digitally signed workbook.", datetime.now())
dsCollection.add(signature)
# Add digital signature collection inside the workbook
workbook.add_digital_signature(dsCollection)
# Save the workbook and dispose it.
workbook.save(outputDir + "outputDigitallySignedByCells.xlsx")