zoukankan      html  css  js  c++  java
  • java校验导入的模板

    /**
         * 验证导入模板的正确性 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;
        }
  • 相关阅读:
    Django框架之数据库ORM框架
    Django模块之jinja2模版
    Django框架之中间件MiddleWare
    Django框架之类视图
    Django框架之session
    Django框架之cookies
    Django框架之给客户端返回数据
    Django框架之获取客户端发送的数据
    题解 UVA11475 【Extend to Palindrome】
    题解 P3964 【[TJOI2013]松鼠聚会】
  • 原文地址:https://www.cnblogs.com/yy123/p/4761219.html
Copyright © 2011-2022 走看看