class XlsUtils {

    public static List<String> getActiveSheetsFromWorkbookSpec(InputStream inputStream) throws XMLStreamException {
        // If doesn't support mark, wrap up
        if (!inputStream.markSupported()) {
            inputStream = new PushbackInputStream(inputStream, 8);
        }
        XMLStreamReader streamReader = XML_INPUT_FACTORY.createXMLStreamReader(inputStream);
        try {
            /*
             *
             * <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <workbook
             * xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
             * xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <fileVersion appName="xl"
             * lastEdited="5" lowestEdited="5" rupBuild="9303" codeName="{8C4F1C90-05EB-6A55-5F09-09C24B55AC0B}"/>
             * <workbookPr codeName="ThisWorkbook" defaultThemeVersion="124226"/> <bookViews> <workbookView xWindow="0"
             * yWindow="732" windowWidth="22980" windowHeight="8868" firstSheet="1" activeTab="8"/> </bookViews>
             * <sheets> <sheet name="formdata" sheetId="4" state="hidden" r:id="rId1"/> <sheet name="MONDAY" sheetId="1"
             * r:id="rId2"/> <sheet name="TUESDAY" sheetId="8" r:id="rId3"/> <sheet name="WEDNESDAY" sheetId="10"
             * r:id="rId4"/> <sheet name="THURSDAY" sheetId="11" r:id="rId5"/> <sheet name="FRIDAY" sheetId="12"
             * r:id="rId6"/> <sheet name="SATURDAY" sheetId="13" r:id="rId7"/> <sheet name="SUNDAY" sheetId="14"
             * r:id="rId8"/> <sheet name="WEEK SUMMARY" sheetId="15" r:id="rId9"/> </sheets>
             *
             */
            // we only want sheets not with state=hidden

            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")) {
                        // shortcut to stop parsing
                        return names;
                    }
                    break;
                default:
                    // no op
                }
            }
            return names;
        } finally {
            if (streamReader != null) {
                streamReader.close();
            }
        }
    }

    private  XlsUtils();

}