List of usage examples for org.apache.poi.xssf.usermodel XSSFWorkbook XSSFWorkbook
public XSSFWorkbook(PackagePart part) throws IOException
From source file:com.movielabs.availslib.AvailSS.java
License:Open Source License
/** * Add a sheet from an Excel spreadsheet to a spreadsheet object * @param sheetName name of the sheet to add * @return created sheet object/*from w ww . ja v a 2 s . c o m*/ * @throws IllegalArgumentException if the sheet does not exist in the Excel spreadsheet * @throws Exception other error conditions may also throw exceptions */ public AvailsSheet addSheet(String sheetName) throws Exception { Workbook wb = new XSSFWorkbook(new FileInputStream(file)); Sheet sheet = wb.getSheet(sheetName); if (sheet == null) { wb.close(); throw new IllegalArgumentException(file + ":" + sheetName + " not found"); } AvailsSheet as = addSheetHelper(wb, sheet); wb.close(); return as; }
From source file:com.movielabs.availslib.AvailSS.java
License:Open Source License
/** * Add a sheet from an Excel spreadsheet to a spreadsheet object * @param sheetNumber zero-based index of sheet to add * @return created sheet object//ww w . j a v a 2s. c o m * @throws IllegalArgumentException if the sheet does not exist in the Excel spreadsheet * @throws Exception other error conditions may also throw exceptions */ public AvailsSheet addSheet(int sheetNumber) throws Exception { Workbook wb = new XSSFWorkbook(new FileInputStream(file)); Sheet sheet; try { sheet = wb.getSheetAt(sheetNumber); } catch (IllegalArgumentException e) { wb.close(); throw new IllegalArgumentException(file + ": sheet number " + sheetNumber + " not found"); } AvailsSheet as = addSheetHelper(wb, sheet); wb.close(); return as; }
From source file:com.movielabs.availslib.AvailSS.java
License:Open Source License
/** * Dump the contents (sheet-by-sheet) of an Excel spreadsheet * @param file name of the Excel .xlsx spreadsheet * @throws Exception if any error is encountered (e.g. non-existant or corrupt file) *//*from w w w .ja va 2 s. c om*/ public static void dumpFile(String file) throws Exception { Workbook wb = new XSSFWorkbook(new FileInputStream(file)); for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); System.out.println("Sheet <" + wb.getSheetName(i) + ">"); for (Row row : sheet) { System.out.println("rownum: " + row.getRowNum()); for (Cell cell : row) { System.out.println(" | " + cell.toString()); } } } wb.close(); }