قم بالتوقيع رقميًا على مشروع رمز VBA باستخدام الشهادة
Contents
[
Hide
]
يمكنك التوقيع رقميًا على مشروع كود VBA الخاص بك باستخدام Aspose.Cells بهWorkbook.VbaProject.Sign () طريقة. يرجى اتباع هذه الخطوات للتحقق مما إذا كان ملف Excel الخاص بك قد تم توقيعه رقميًا بشهادة.
- انقرالبصرية الأساسية منمطور علامة التبويب لفتحVisual Basic لتطبيقات IDE
- انقرأدوات > التوقيعات الرقمية… منVisual Basic لتطبيقات IDE
وسوف تظهر النموذج التوقيع الرقمي تبين ما إذا كان المستند موقعا رقميا بشهادة أم لا.
قم بالتوقيع رقميًا على مشروع رمز VBA باستخدام الشهادة في C#
يوضح نموذج التعليمات البرمجية التالي كيفية الاستفادة من[Workbook.VbaProject.Sign ()](https://reference.aspose.com/cells/java/com.aspose.cells/vbaproject#sign(com.aspose.cells.DigitalSignature)طريقة. فيما يلي ملفات الإدخال والإخراج لعينة التعليمات البرمجية. يمكنك استخدام أي ملف إكسل وأي شهادة لاختبار هذا الرمز.
- ملف Excel المصدر المستخدمة في نموذج التعليمات البرمجية.
- نموذج لملف pfx لإنشاء التوقيع الرقمي. يرجى تثبيته على جهاز الكمبيوتر الخاص بك لتشغيل هذا الرمز. كلمة المرور الخاصة به هي 1234.
- إخراج ملف Excel تم إنشاؤها بواسطة نموذج التعليمات البرمجية.
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"); |