ワークシートに署名行を追加(C++)
Contents
[
Hide
]
紹介
Aspose.Cellsは、ワークシートの署名行を追加するためのPicture.SignatureLineプロパティを提供します。
ワークシートに署名行を追加する方法
以下のサンプルコードは、Picture.SignatureLineプロパティを使用してワークシートの署名行を追加する方法を示します。実行後のサンプルExcelファイルの効果をスクリーンショットで示します。
サンプルコード
#include <iostream>
#include <ctime>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::DigitalSignatures;
int main() {
Aspose::Cells::Startup();
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
Workbook wb;
SignatureLine signatureLine;
signatureLine.SetSigner(u"Aspose.Cells");
signatureLine.SetTitle(u"signed by Aspose.Cells");
wb.GetWorksheets().Get(0).GetShapes().AddSignatureLine(1, 1, signatureLine);
U16String certificatePath = srcDir + u"rsa2048.pfx";
U16String password = u"123456";
std::time_t now = std::time(nullptr);
struct tm now_tm;
localtime_s(&now_tm, &now);
Date currentDate{
now_tm.tm_year + 1900,
now_tm.tm_mon + 1,
now_tm.tm_mday,
now_tm.tm_hour,
now_tm.tm_min,
now_tm.tm_sec,
0
};
DigitalSignature signature(certificatePath, password, u"test Microsoft Office signature line", currentDate);
DigitalSignatureCollection dsCollection;
dsCollection.Add(signature);
wb.SetDigitalSignature(dsCollection);
U16String outputPath = srcDir + u"signatureLine.xlsx";
wb.Save(outputPath);
std::cout << "Workbook with signature line saved successfully!" << std::endl;
Aspose::Cells::Cleanup();
}