public Workbook loadExcel(String filePath) throws FileNotFoundException,IOException, EncryptedDocumentException, InvalidFormatException{
POIFSFileSystem ps=new POIFSFileSystem(new File(filePath));
book =WorkbookFactory.create(ps);
}else if(filePath.endsWith(".xlsx")){
//解决模板污染问题
InputStream input=new FileInputStream(new File(filePath));
book=new XSSFWorkbook(input);
}
return book;
Workbook book = null;
if(filePath==null)return null;
if(filePath.endsWith(".xls")){POIFSFileSystem ps=new POIFSFileSystem(new File(filePath));
book =WorkbookFactory.create(ps);
}else if(filePath.endsWith(".xlsx")){
//解决模板污染问题
InputStream input=new FileInputStream(new File(filePath));
book=new XSSFWorkbook(input);
}
return book;
}
//通过流的方式去创建则原文件不会被修改。