Zaten imzalanmış Excel dosyasına dijital imza ekleme (C++)
Contents
[
Hide
]
Olası Kullanım Senaryoları
Aspose.Cells, zaten imzalanmış Excel dosyalarına dijital imza eklemek için Workbook::AddDigitalSignature(DigitalSignatureCollectionPtr digitalSignatureCollection) yöntemini sağlar.
Lütfen, zaten imzalanmış bir Excel belgesine dijital imza eklerken: orijinal belge Aspose.Cells ile oluşturulduysa düzgün çalışır. Ancak, belge başka motorlar (örneğin Microsoft Excel) tarafından oluşturulduysa, Aspose.Cells for C++ yükleme ve yeniden kaydetme işleminden sonra tam dosya yapısını koruyamaz, bu da mevcut imzaları geçersiz kılabilir.
Zaten İmzalanmış Bir Excel Dosyasına Dijital İmza Eklemek
Aşağıdaki kod örneği, imzalanmış Excel dosyalarına dijital imza eklemek için Workbook::AddDigitalSignature‘ın kullanımını gösterir. Örnek Excel dosyası önceden imzalanmıştır. Çıktı dosyası sonucu gösterir. Demo sertifikası AsposeDemo.pfx şifresi ile aspose kullanıyoruz.

Örnek Kod
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::DigitalSignatures;
int main()
{
Aspose::Cells::Startup();
// Source and output directories
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Certificate and workbook paths
U16String certFilePath = srcDir + u"AsposeDemo.pfx";
U16String inputFilePath = srcDir + u"sampleDigitallySignedByCells.xlsx";
U16String outputFilePath = outDir + u"outputDigitallySignedByCells.xlsx";
// Load digitally signed workbook
Workbook workbook(inputFilePath);
// Create digital signature collection
DigitalSignatureCollection dsCollection;
// Create digital signature using PFX certificate
U16String password = u"aspose";
U16String comments = u"Aspose.Cells added new digital signature in existing digitally signed workbook.";
DigitalSignature signature(certFilePath, password, comments, Date());
// Add signature to collection
dsCollection.Add(signature);
// Apply digital signatures to workbook
workbook.AddDigitalSignature(dsCollection);
// Save modified workbook
workbook.Save(outputFilePath);
std::cout << "Digital signature added successfully." << std::endl;
Aspose::Cells::Cleanup();
return 0;
}