Digitale Signatur zu einer bereits signierten Excel Datei mit C++ hinzufügen
Mögliche Verwendungsszenarien
Aspose.Cells bietet die Workbook::AddDigitalSignature(DigitalSignatureCollectionPtr digitalSignatureCollection)-Methode zum Hinzufügen digitaler Signaturen zu bereits signierten Excel-Dateien.
Wie fügt man eine digitale Signatur zu einer bereits signierten Excel-Datei hinzu
Das folgende Code-Beispiel zeigt, wie man Workbook::AddDigitalSignature verwendet, um digitale Signaturen zu signierten Excel-Dateien hinzuzufügen. Die Beispieldatei Excel ist vorverschlüsselt. Die Ausgabedatei zeigt das Ergebnis. Wir verwenden ein Dem-Zertifikat AsposeDemo.pfx mit Passwort aspose.
Beispielcode
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::DigitalSignatures;
int main()
{
Aspose::Cells::Startup();
// Source and output directories
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Certificate and workbook paths
U16String certFilePath = srcDir + u"AsposeDemo.pfx";
U16String inputFilePath = srcDir + u"sampleDigitallySignedByCells.xlsx";
U16String outputFilePath = outDir + u"outputDigitallySignedByCells.xlsx";
// Load digitally signed workbook
Workbook workbook(inputFilePath);
// Create digital signature collection
DigitalSignatureCollection dsCollection;
// Create digital signature using PFX certificate
U16String password = u"aspose";
U16String comments = u"Aspose.Cells added new digital signature in existing digitally signed workbook.";
DigitalSignature signature(certFilePath, password, comments, Date());
// Add signature to collection
dsCollection.Add(signature);
// Apply digital signatures to workbook
workbook.AddDigitalSignature(dsCollection);
// Save modified workbook
workbook.Save(outputFilePath);
std::cout << "Digital signature added successfully." << std::endl;
Aspose::Cells::Cleanup();
return 0;
}