List of usage examples for org.apache.poi.ss.usermodel WorkbookFactory create
public static Workbook create(File file, String password, boolean readOnly) throws IOException, EncryptedDocumentException
Note that in order to properly release resources the Workbook should be closed after use.
From source file:org.gephi.io.importer.plugin.file.spreadsheet.ImporterSpreadsheetExcel.java
License:Open Source License
private SheetParser createParser(boolean withFirstRecordAsHeader) throws IOException { try {/*from www .jav a 2 s .c o m*/ boolean readOnly = true; Workbook workbook = WorkbookFactory.create(file, null, readOnly); Sheet sheet = workbook.getSheetAt(sheetIndex); return new ExcelSheetParser(sheet, withFirstRecordAsHeader); } catch (Exception ex) { //Control and report old excel files are unsupported: //Control and report excel file blocked by another process (normally excel itself): if (report != null) { SpreadsheetUtils.logError(report, ex.getMessage(), null); return EmptySheet.INSTANCE; } else { return new ErrorSheet(ex.getMessage()); } } }