标签:
/** * 验证导入模板的正确性 InputStream inputStream = file.getInputStream();
*/ @SuppressWarnings("deprecation") public Boolean falg(InputStream inputStream,String fileName) throws IOException{ Boolean falg = true; if(fileName.equals("xlsx")){ XSSFWorkbook workbook = new XSSFWorkbook(inputStream); XSSFSheet sheet = workbook.getSheetAt(0); if(sheet!=null){ XSSFRow row1 = sheet.getRow(0); if(row1!=null){ XSSFCell cell = row1.getCell((short) 0); XSSFCell cell1 = row1.getCell((short) 2); XSSFCell cell2 = row1.getCell((short) 3); if(cell==null||!cell.toString().equals("信息来源")){//字段 falg=false; return falg; } if(cell1==null||!cell1.toString().equals("权利证明编号")){ falg=false; return falg; } if(cell2==null||!cell2.toString().equals("省")){ falg=false; return falg; } } } }else{ HSSFWorkbook workbook = new HSSFWorkbook(inputStream); HSSFSheet sheet = workbook.getSheetAt(0); if(sheet!=null){ HSSFRow row1 = sheet.getRow(0); if(row1!=null){ HSSFCell cell = row1.getCell((short) 0); HSSFCell cell1 = row1.getCell((short) 2); HSSFCell cell2 = row1.getCell((short) 3); if(cell==null||!cell.toString().equals("信息来源")){ falg=false; return falg; } if(cell1==null||!cell1.toString().equals("权利证明编号")){ falg=false; return falg; } if(cell2==null||!cell2.toString().equals("省")){ falg=false; return falg; } } } } return falg; }
标签:
原文地址:http://www.cnblogs.com/yy123/p/4761219.html