暗号化されたOffice Open XML OOXMLファイルのファイルフォーマットをNode.jsとC++経由で検出
Contents
[
Hide
]
Office Open XML(またはOOXML、Microsoft Open XML(MOX)とも呼ばれる)は、Microsoftが開発したXMLベースのファイル形式であり、スプレッドシート、チャート、プレゼンテーション、ワードプロセッシングドキュメントの表現に使用されます。
Aspose.Cellsは、暗号化されたMicrosoft Open XMLファイルのファイル形式を検出する方法を提供しています。ファイルタイプを識別するには、FileFormatUtil.detectFileFormat(Uint8Array)メソッドを以下のコード例のように使用します。
const fs = require("fs");
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// Source directory
const sourceDir = path.join(__dirname, "data");
const filePath = path.join(sourceDir, "encryptedBook1.out.tmp");
fs.writeFileSync(filePath, Buffer.from([0x50, 0x4B, 0x03, 0x04]));
const stream = fs.readFileSync(filePath);
AsposeCells.FileFormatUtil.verifyPassword(stream, "1234");
const fileFormatInfo = AsposeCells.FileFormatUtil.detectFileFormat(stream);
console.log("File Format: " + fileFormatInfo.getFileFormatType());