检测加密的Office Open XML OOXML文件的文件格式
Contents
[
Hide
]
Office Open XML(也称为OOXML或Microsoft Open XML(MOX))是由Microsoft开发的用于表示办公文档的基于XML的文件格式,如电子表格、图表、演示文稿和文字处理文档。
Aspose.Cells 提供检测加密的 Microsoft Open XML 文件格式的方法。要识别文件类型,请使用 FileFormatUtil.detectFileFormat 方法,具体示例如下。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); | |
} |