An XLSX file is actually just a special ZIP file. As such, its first two bytes are always PK (0x50 and 0x4B). You can even check the source of java.util.zip.ZipInputStream how it reads the first few bytes. Check the "src.zip" file inside your JDK installation.
Also be aware that the org.apache.poi.ss package contains classes that can hide the differences between both formats. For example, WorkbookFactory.create(InputStream) returns a Workbook you can use regardless of actual file format. Much better than having to code that yourself :-)
Ping & DNS - updated with new look and Ping home screen widget
Joined: Jun 21, 2010
Thank you friends. Using org.apache.poi.ss package solved my problem as now I do not need to bother about the file type.