XlsUtils { public static List<String> getActiveSheetsFromWorkbookSpec(InputStream inputStream) throws XMLStreamException { if (!inputStream.markSupported()) { inputStream = new PushbackInputStream(inputStream, 8); } XMLStreamReader streamReader = XML_INPUT_FACTORY.createXMLStreamReader(inputStream); try { List<String> names = new ArrayList<>(); while (streamReader.hasNext()) { switch (streamReader.next()) { case START_ELEMENT: if (StringUtils.equals(streamReader.getLocalName(), "sheet")) { Map<String, String> attributesValues = getAttributesNameValue(streamReader); if (!attributesValues.isEmpty()) { String sheetState = attributesValues.get("state"); if (!StringUtils.equals(sheetState, "hidden")) { String sheetName = attributesValues.get("name"); names.add(sheetName); } } } break; case XMLStreamConstants.END_ELEMENT: if (StringUtils.equals(streamReader.getLocalName(), "sheets")) { return names; } break; default: } } return names; } finally { if (streamReader != null) { streamReader.close(); } } } 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 get_active_sheets() throws Exception { OPCPackage container = OPCPackage.open(getClass().getResourceAsStream("000_DTA_DailyTimeLog.xlsm")); XSSFReader xssfReader = new XSSFReader(container); List<String> names = XlsUtils.getActiveSheetsFromWorkbookSpec(xssfReader.getWorkbookData()); Assertions .assertThat(names) .isNotEmpty() .containsExactly("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY", "WEEK SUMMARY"); }
@Test public void get_active_sheets_simple() throws Exception { List<String> names = XlsUtils.getActiveSheetsFromWorkbookSpec(getClass().getResourceAsStream("simple_workbook.xml")); Assertions .assertThat(names) .isNotEmpty() .containsExactly("Feuille1", "Feuille2", "Feuille3"); }