美文网首页
java 验证 excel是否2003和2007

java 验证 excel是否2003和2007

作者: 换她笑面如花 | 来源:发表于2018-11-06 22:52 被阅读0次

    public class ExcelImportUtils {

        // @描述:是否是2003的excel,返回true是2003

        public static boolean isExcel2003(String filePath)  { 

            return filePath.matches("^.+\\.(?i)(xls)$"); 

        } 

        //@描述:是否是2007的excel,返回true是2007

        public static boolean isExcel2007(String filePath)  { 

            return filePath.matches("^.+\\.(?i)(xlsx)$"); 

        } 

      /**

      * 验证EXCEL文件

      * @param filePath

      * @return

      */

      public static boolean validateExcel(String filePath){

            if (filePath == null || !(isExcel2003(filePath) || isExcel2007(filePath))){ 

                return false; 

            } 

            return true;

      }

    }

    相关文章

      网友评论

          本文标题:java 验证 excel是否2003和2007

          本文链接:https://www.haomeiwen.com/subject/bgwpxqtx.html