检测加密的Office Open XML OOXML文件的文件格式

Contents
[ ]

Aspose.Cells提供了一种检测加密的 Microsoft Open XML 文件文件格式的方法。要识别文件类型,使用下面代码示例中显示的FileFormatUtil.detectFileFormat方法。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Source directory
String dataDir = AsposeCellsExamples.Utils.getSharedDataDir(DetectFileFormatOfEncryptedFiles.class) + "TechnicalArticles/";
String filename = dataDir + "encryptedBook1.out.tmp";
FileFormatInfo fileFormatInfo = FileFormatUtil.detectFileFormat(filename,"1234"); // The password is 1234
if(fileFormatInfo.getFileFormatType() == FileFormatType.EXCEL_97_TO_2003) {
System.out.println("File Format: EXCEL_97_TO_2003");
} else if(fileFormatInfo.getFileFormatType() == FileFormatType.PPTX) {
System.out.println("File Format: PPTX");
} else if(fileFormatInfo.getFileFormatType() == FileFormatType.DOCX) {
System.out.println("File Format: DOCX");
}