Add Digital Signature to an already signed Excel file with Node.js via C++
Possible Usage Scenarios
Aspose.Cells for Node.js via C++ provides the Workbook.addDigitalSignature(digitalSignatureCollection) method that you can use to add a digital signature to an already signed Excel file.
How to Add Digital Signature to an Already Signed Excel File
The following sample code demonstrates how to make use of the Workbook.addDigitalSignature(digitalSignatureCollection) method to add a digital signature to an 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.
Sample Code
const AsposeCells = require("aspose.cells.node");
const path = require("path");
const dataDir = path.join(__dirname, "data");
// Certificate file path and password
const certFileName = path.join(dataDir, "AsposeDemo.pfx");
const password = "aspose";
// Load the workbook which is already digitally signed to add new digital signature
const workbook = new AsposeCells.Workbook(path.join(dataDir, "sampleDigitallySignedByCells.xlsx"));
// Create the digital signature collection
const dsCollection = new AsposeCells.DigitalSignatureCollection();
// Create new digital signature and add it in digital signature collection
const signature = new AsposeCells.DigitalSignature(certFileName, password, "Aspose.Cells added new digital signature in existing digitally signed workbook.", new Date());
dsCollection.add(signature);
// Add digital signature collection inside the workbook
workbook.addDigitalSignature(dsCollection);
// Save the workbook and dispose of it.
workbook.save(path.join(__dirname, "outputDigitallySignedByCells.xlsx"));
workbook.dispose();