Zaten imzalanmış Excel dosyasına dijital imza ekleme (C++)

Olası Kullanım Senaryoları

Aspose.Cells, zaten imzalanmış Excel dosyalarına dijital imza eklemek için Workbook::AddDigitalSignature(DigitalSignatureCollectionPtr digitalSignatureCollection) yöntemini sağlar.

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.

todo:image_alt_text

Ö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;
}