Hi,
I found out that Aspose.Cells.FileFormatUtil.DetectFileFormat returns incorrect value in following cases:
-
“Excel2007Xlsx” for password protected DOCM/DOCX/DOTM/DOTX;
-
“Excel2007Xlsx” for password protected POTM/POTX/PPTM/PPTX.
I think the reason is that new (open xml) formats are saved in OLE package when they are password protected (even MS Office 2010 does not show error message until you enter password to open).
So it seems to be more logical to return something general like “OpenXMLFile” (or whatever you want), because you cannot guaranty that it is actually Excel (Word or PowerPoint) file.
But in this case it is highly important to ensure that CellsException with Code set to ExceptionType.FileFormat is thrown when you try to open not Excel file. For example here http://www.aspose.com/community/forums/526240/aspose.cells-opens-ole-objects/showthread.aspx#526240 OLE packages are successfully opened be Aspose.Cells.Workbook, whereas Aspose.Cells.FileFormatUtil.DetectFileFormat returns “Unknown”.
Used version – Aspose.Cells 7.7.2.0
Thank you,
Alex Shloma