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. Also, review the output Excel file generated by the code. We used the demo certificate named AsposeDemo.pfx, which has the password aspose. The screenshot shows the effect of the sample code on the Excel file after execution.

todo:image_alt_text

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 that is already digitally signed to add a new digital signature
const workbook = new AsposeCells.Workbook(path.join(dataDir, "sampleDigitallySignedByCells.xlsx"));

// Create the digital signature collection
const dsCollection = new AsposeCells.DigitalSignatureCollection();


// Create a new digital signature and add it to the 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();