通过C++使用Node.js检测受密码保护的Office Open XML(OOXML)文件的文件格式

Contents
[ ]

Aspose.Cells提供了一种检测加密的微软开放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());