通过C++使用Node.js检测受密码保护的Office Open XML(OOXML)文件的文件格式
Contents
[
Hide
]
Office Open XML(也称为OOXML或微软开放XML(MOX))是一种由微软开发的基于XML的文件格式,用于表示办公文档,如电子表格、图表、演示文稿和文字处理文件。
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());