List of usage examples for org.apache.poi.openxml4j.exceptions NotOfficeXmlFileException NotOfficeXmlFileException
public NotOfficeXmlFileException(String message)
From source file:com.abixen.platform.service.businessintelligence.multivisualisation.application.service.file.reader.ExcelReaderService.java
License:Open Source License
private Workbook openFileAsWorkBook(final MultipartFile file, final FileParserMessage msg) throws IOException { try {/*from w w w .j a v a2 s . c om*/ final String fileName = file.getOriginalFilename(); if (XLSX_FILE_EXTENSION.equals(fileName.substring(fileName.lastIndexOf(".")))) { return new XSSFWorkbook(file.getInputStream()); } if (XLS_FILE_EXTENSION.equals(fileName.substring(fileName.lastIndexOf(".")))) { return new HSSFWorkbook(file.getInputStream()); } throw new NotOfficeXmlFileException("Not recognized type"); } catch (NotOfficeXmlFileException e) { msg.addFileParseError(new FileParseError(0, "Invalid file type")); throw new IOException(); } }
From source file:com.abixen.platform.service.businessintelligence.multivisualisation.service.impl.parser.ExcelParserServiceImpl.java
License:Open Source License
private Workbook openFileAsWorkBook(MultipartFile file, FileParserMessage<DataFileColumn> msg) throws IOException { try {//w w w . ja va2 s . co m String fileName = file.getOriginalFilename(); if (".xlsx".equals(fileName.substring(fileName.lastIndexOf(".")))) { return new XSSFWorkbook(file.getInputStream()); } if (".xls".equals(fileName.substring(fileName.lastIndexOf(".")))) { return new HSSFWorkbook(file.getInputStream()); } throw new NotOfficeXmlFileException("Not recognized type"); } catch (NotOfficeXmlFileException e) { msg.addFileParseError(new FileParseError(0, "Invalid file type")); throw new IOException(); } }