Node.js経由のC++を使用して既に署名済みのExcelファイルにデジタル署名を追加する

可能な使用シナリオ

Aspose.Cells for Node.js via C++は、既に署名済みのExcelファイルにデジタル署名を追加できるWorkbook.addDigitalSignature(digitalSignatureCollection)メソッドを提供します。

すでに署名されたExcelファイルにデジタル署名を追加する方法

以下のサンプルコードは、Workbook.addDigitalSignature(digitalSignatureCollection)メソッドを使用して既に署名されたExcelファイルにデジタル署名を追加する方法を示しています。このコードで使用されているサンプルExcelファイルはすでにデジタル署名が施されています。 このコードによって生成される出力Excelファイルもご確認ください。デモ証明書としてname=AsposeDemo.pfxを使用し、パスワードはasposeです。スクリーンショットは、コード実行後のサンプルExcelファイルの効果を示しています。

todo:image_alt_text

サンプルコード

const AsposeCells = require("aspose.cells.node");
const path = require("path");

const dataDir = path.join(__dirname, "data");
// Certificate file path and password
const certFileName = path.join(dataDir, "AsposeDemo.pfx");
const password = "aspose";

// Load the workbook which is already digitally signed to add new digital signature
const workbook = new AsposeCells.Workbook(path.join(dataDir, "sampleDigitallySignedByCells.xlsx"));

// Create the digital signature collection
const dsCollection = new AsposeCells.DigitalSignatureCollection();


// Create new digital signature and add it in digital signature collection
const signature = new AsposeCells.DigitalSignature(certFileName, password, "Aspose.Cells added new digital signature in existing digitally signed workbook.", new Date());
dsCollection.add(signature);

// Add digital signature collection inside the workbook
workbook.addDigitalSignature(dsCollection);

// Save the workbook and dispose of it.
workbook.save(path.join(__dirname, "outputDigitallySignedByCells.xlsx"));
workbook.dispose();