Signieren Sie ein VBA-Code-Projekt digital mit Zertifikat
Contents
[
Hide
]
Sie können Ihr VBA-Code-Projekt mit Aspose.Cells digital signierenWorkbook.VbaProject.Sign() Methode. Bitte befolgen Sie diese Schritte, um zu überprüfen, ob Ihre Excel-Datei mit einem Zertifikat digital signiert ist.
- KlickenVisualBasic von demEntwickler Registerkarte zu öffnenVisual Basic für Applikationen-IDE
- KlickenWerkzeug > Digitale Signaturen… vonVisual Basic für Applikationen-IDE
und es wird die zeigenFormular für digitale Signatur zeigt an, ob das Dokument mit einem Zertifikat digital signiert ist oder nicht.
Signieren Sie ein VBA-Code-Projekt digital mit Zertifikat unter C#
Der folgende Beispielcode veranschaulicht die Verwendung von[Workbook.VbaProject.Sign()](https://reference.aspose.com/cells/java/com.aspose.cells/vbaproject#sign(com.aspose.cells.DigitalSignature)Methode. Hier sind die Eingabe- und Ausgabedateien des Beispielcodes. Sie können jede Excel-Datei und jedes Zertifikat verwenden, um diesen Code zu testen.
- Excel-Quelldatei im Beispielcode verwendet.
- Beispiel-pfx-Datei um eine digitale Signatur zu erstellen. Bitte installieren Sie es auf Ihrem Computer, um diesen Code auszuführen. Sein Passwort ist 1234.
- Excel-Datei ausgeben generiert durch den Beispielcode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
String password = "1234"; | |
String pfxPath = sourceDir + "sampleDigitallySignVbaProjectWithCertificate.pfx";; | |
String comment = "Signing Digital Signature using Aspose.Cells"; | |
// Load the certificate into an instance of InputStream | |
InputStream inStream = new FileInputStream(pfxPath); | |
// Create an instance of KeyStore with PKCS12 cryptography | |
KeyStore inputKeyStore = KeyStore.getInstance("PKCS12"); | |
// Use the KeyStore.load method to load the certificate stream and its password | |
inputKeyStore.load(inStream, password.toCharArray()); | |
inStream.close(); | |
// Create an instance of DigitalSignature and pass the instance of KeyStore, password, comments and time | |
DigitalSignature signature = new DigitalSignature(inputKeyStore, password, comment, | |
DateTime.getNow()); | |
Workbook wb = new Workbook(sourceDir + "sampleDigitallySignVbaProjectWithCertificate.xlsm"); | |
wb.getVbaProject().sign(signature); | |
wb.save(outputDir + "outputDigitallySignVbaProjectWithCertificate.xlsm"); |