إضافة توقيع رقمي إلى ملف إكسل تم توقيعه بالفعل

سيناريوهات الاستخدام المحتملة

Aspose.Cells توفر أسلوب Workbook.AddDigitalSignature(DigitalSignatureCollection digitalSignatureCollection) الذي يمكنك استخدامه لإضافة توقيع رقمي إلى ملف إكسل موقع مسبقًا.

كيفية إضافة توقيع رقمي إلى ملف Excel تم توقيعه مسبقًا

يوضح مقتطفات الكود التالية كيفية استخدام أسلوب Workbook.AddDigitalSignature(DigitalSignatureCollection digitalSignatureCollection) لإضافة توقيع رقمي إلى ملف إكسل موقع مسبقًا. يرجى التحقق من ملف إكسل نموذجي المستخدم في هذا الكود. هذا الملف موقع مسبقًا بالفعل. يرجى التحقق من ملف إكسل الناتج الذي تم إنشاؤه بواسطة الكود. لقد استخدمنا شهادة العرض الديمو المُسماة AsposeDemo.pfx في هذا الكود ولديها كلمة مرور aspose. توضح اللقطة الشاشية تأثير الكود النموذجي على ملف إكسل النموذجي بعد التنفيذ.

todo:image_alt_text

الكود المثالي

// 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();