XlsUtils { public static boolean isNewExcelFormat(InputStream inputStream) throws IOException { return FileMagic.valueOf(inputStream) == FileMagic.OOXML; } private  XlsUtils(); static String getCellValueAsString(Cell cell, FormulaEvaluator formulaEvaluator); static boolean isNewExcelFormat(InputStream inputStream); static List<String> getActiveSheetsFromWorkbookSpec(InputStream inputStream); static int getColumnsNumber(InputStream inputStream); static int getColumnsNumberFromDimension(String dimension); static int getColumnNumberFromCellRef(String lastCell);  }
@Test public void detect_old_excel_version() throws Exception { InputStream inputStream = getClass().getResourceAsStream("Workbook-xls.xls"); Assertions.assertThat(XlsUtils.isNewExcelFormat(inputStream)).isFalse(); }
@Test public void detect_new_excel_version() throws Exception { InputStream inputStream = getClass().getResourceAsStream("Workbook-xlsx.xlsx"); Assertions.assertThat(XlsUtils.isNewExcelFormat(inputStream)).isTrue(); inputStream = getClass().getResourceAsStream("Workbook-xls.xls"); Assertions.assertThat(XlsUtils.isNewExcelFormat(inputStream)).isFalse(); }
@Test public void no_detect_excel() throws Exception { InputStream inputStream = getClass().getResourceAsStream("fake.xls"); Assertions.assertThat(XlsUtils.isNewExcelFormat(inputStream)).isFalse(); inputStream = getClass().getResourceAsStream("fake.xls"); Assertions.assertThat(XlsUtils.isNewExcelFormat(inputStream)).isFalse(); }