Lägg till digital signatur i en redan signerad Excel fil med Node.js via C++
Möjliga användningsscenario
Aspose.Cells for Node.js via C++ tillhandahåller Workbook.addDigitalSignature(digitalSignatureCollection)-metoden som kan användas för att lägga till en digital signatur i en redan signerad Excel-fil.
Hur man lägger till en digital signatur till en redan signerad Excel-fil
Följande exempel visar hur man använder Workbook.addDigitalSignature(digitalSignatureCollection)-metoden för att lägga till en digital signatur i en redan signerad Excel-fil. Kontrollera exempel-Excel-filen som används i denna kod. Denna fil är redan digitalt signerad. Kontrollera utdata Excel-filen som genereras av koden. Vi har använt demosertifikatet AsposeDemo.pfx i denna kod, som har ett lösenord aspose. Skärmbilden visar effekten av kodexemplet på exemplexcel-filen efter körning.
Exempelkod
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();