Example usage for org.apache.poi.ss.usermodel Workbook getFirstVisibleTab

List of usage examples for org.apache.poi.ss.usermodel Workbook getFirstVisibleTab

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Workbook getFirstVisibleTab.

Prototype

int getFirstVisibleTab();

Source Link

Document

Gets the first tab that is displayed in the list of tabs in excel.

Usage

From source file:com.faizod.aem.component.core.servlets.datasources.impl.ExcelDatasourceParser.java

License:Apache License

@Override
public boolean validate(InputStream inputStream) {
    if (inputStream == null) {
        return false;
    }/*from w  ww  .  j a va  2s . c om*/

    boolean valid = true;
    try {
        Workbook workbook = WorkbookFactory.create(inputStream);
        int firstVisibleTab = workbook.getFirstVisibleTab();
        valid = firstVisibleTab >= 0;
    } catch (IOException e) {
        valid = false;
    } catch (InvalidFormatException e) {
        valid = false;
    } catch (EncryptedDocumentException e) {
        valid = false;
    }
    return valid;
}