title: How to know the excel file version in java?
body: <p>I want to read excel files in java. I have some excel files with old format (excel 95) and others in new format (excel 2007). I am currently using poi but it is not able to read the excel files with older format. So what I need is a function that passes the filename which will return a boolean with value true if the format is old format (BIFF5) and false if the format is new (BIFF8). The need of this function is to allow me to use jxl in for older format and poi for newer format.</p>
  
  <p>Here is the code I have:</p>
  
  <pre><code>    try
      {
        // create a new org.apache.poi.poifs.filesystem.Filesystem
        POIFSFileSystem poifs = new POIFSFileSystem(fin);
        w = new HSSFWorkbook(poifs);
      }
      catch (IOException e)
      {
        w = null;
        throw e;
      }
      catch (OutOfMemoryError e) // java.lang.OutOfMemoryError:
      {
        w = null;
        throw e;
      }
      catch (OldExcelFormatException e) // OldExcelFormatException
      {
        w = null;
        System.out.println("OldExcelFormatException");
        translateBIFF5();
      }
  
   private void translateBIFF5() throws IOException, CmpException
    {
      ArrayList&lt;String&gt; row = null;
      try
      {
        jxl_w = Workbook.getWorkbook(excelFile);
      }
      catch (BiffException e)
      {
        jxl_w = null;
        e.printStackTrace();
      }
      catch (IOException e)
      {
        jxl_w = null;
        throw e;
      }
      catch (OutOfMemoryError e) // java.lang.OutOfMemoryError:
      {
        jxl_w = null;
        throw e;
      }
  
      if (jxl_w != null)
      {
        try
        {
          for (currentSheet = 0; currentSheet &lt; jxl_w.getNumberOfSheets(); currentSheet++)
          {
            jxl_sheet = jxl_w.getSheet(currentSheet);
        . . . . .
  </code></pre>