Node.js経由のC++を使用したWorkbookMetadataの利用例

Contents
[ ]

以下のサンプルコードは、WorkbookMetadataクラスを使用してワークブックのカスタムドキュメントプロパティを編集する例です。Workbookクラスを使ってワークブックを開くと、ドキュメントのプロパティを読むことができます。こちらは、WorkbookMetadataクラスを使ったサンプルコードです。

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

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");

// Open Workbook metadata
const options = new AsposeCells.MetadataOptions(AsposeCells.MetadataType.Document_Properties);
const meta = new AsposeCells.WorkbookMetadata(path.join(dataDir, "Sample1.xlsx"), options);

// Set some properties
meta.getCustomDocumentProperties().add("test", "test");

// Save the metadata info
meta.save(path.join(dataDir, "Sample2.out.xlsx"));

// Open the workbook
const w = new AsposeCells.Workbook(path.join(dataDir, "Sample2.out.xlsx"));

// Read document property
console.log(w.getCustomDocumentProperties().get("test"));

console.log("Press any key to continue...");