Halihazırda imzalanmış bir Excel dosyasına Dijital İmza ekleme
Olası Kullanım Senaryoları
Aspose.Cells şunları sağlar:Workbook.AddDigitalSignature(DigitalSignatureCollection digitalSignatureCollection)Halihazırda imzalanmış bir Excel dosyasına dijital imza eklemek için kullanabileceğiniz bir yöntem.
Halihazırda imzalanmış bir Excel dosyasına Dijital İmza ekleme
Aşağıdaki örnek kod, nasıl kullanılacağını gösterdiWorkbook.AddDigitalSignature(DigitalSignatureCollection digitalSignatureCollection) Halihazırda imzalanmış Excel dosyasına dijital imza ekleme yöntemi. lütfen kontrol edinizörnek excel dosyası bu kodda kullanılır. Bu dosya zaten dijital olarak imzalanmış. lütfen kontrol edinizçıktı excel dosyası kod tarafından oluşturulur. adlı demo sertifikasını kullandık.AsposeDemo.pfx şifresi olan bu koddavarsaymakEkran görüntüsü, yürütmeden sonra örnek kodun örnek Excel dosyası üzerindeki etkisini gösterir.
Basit kod
// 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(); | |