أضف التوقيع الرقمي إلى ملف Excel موقع بالفعل
Contents
[
Hide
]
سيناريوهات الاستخدام الممكنة
يوفر Aspose.Cells ملفWorkbook.AddDigitalSignature (DigitalSignatureCollection digitalSignatureCollection)الطريقة التي يمكنك استخدامها لإضافة توقيع رقمي إلى ملف Excel موقع بالفعل.
يرجى ملاحظة أثناء إضافة توقيع رقمي إلى مستند Excel موقع بالفعل ، إذا كان المستند الأصلي هو مستند تم إنشاؤه بواسطة Aspose.Cells ، فإنه يعمل بشكل جيد. ولكن إذا تم إنشاء المستند الأصلي بواسطة محركات أخرى (مثل Microsoft Excel وما إلى ذلك) ، فلن يتمكن Aspose.Cells من الاحتفاظ بالملف كما هو بعد تحميله وإعادة حفظه ، سيؤدي ذلك إلى جعل التوقيع الأصلي غير صالح.
أضف التوقيع الرقمي إلى ملف Excel موقع بالفعل
يوضح نموذج التعليمات البرمجية التالي كيفية الاستفادة منWorkbook.AddDigitalSignature (DigitalSignatureCollection digitalSignatureCollection) طريقة لإضافة توقيع رقمي إلى ملف Excel موقع بالفعل. رجاء تاكد مننموذج لملف Excel المستخدمة في هذا الرمز. هذا الملف موقّع رقميًا بالفعل. رجاء تاكد منإخراج ملف Excel التي تم إنشاؤها بواسطة الكود. لقد استخدمنا الشهادة التجريبية المسماةAsposeDemo.pfx في هذا الرمز الذي يحتوي على كلمة مرورأوقفتُظهر لقطة الشاشة تأثير نموذج التعليمات البرمجية على نموذج ملف 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-.NET | |
//Certificate file and its password | |
string certFileName = sourceDir + "AsposeDemo.pfx"; | |
string password = "aspose"; | |
//Load the workbook which is already digitally signed to add new digital signature | |
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(sourceDir + "sampleDigitallySignedByCells.xlsx"); | |
//Create the digital signature collection | |
Aspose.Cells.DigitalSignatures.DigitalSignatureCollection dsCollection = new Aspose.Cells.DigitalSignatures.DigitalSignatureCollection(); | |
//Create new certificate | |
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certFileName, password); | |
//Create new digital signature and add it in digital signature collection | |
Aspose.Cells.DigitalSignatures.DigitalSignature signature = new Aspose.Cells.DigitalSignatures.DigitalSignature(certificate, "Aspose.Cells added new digital signature in existing digitally signed workbook.", DateTime.Now); | |
dsCollection.Add(signature); | |
//Add digital signature collection inside the workbook | |
workbook.AddDigitalSignature(dsCollection); | |
//Save the workbook and dispose it. | |
workbook.Save(outputDir + "outputDigitallySignedByCells.xlsx"); | |
workbook.Dispose(); | |