求助,导出excel2007,CEVUtil.fileExist(),CEVUtil是哪个jar里的?
2条回答 默认 最新
- 战在春秋 2017-06-05 02:37关注
不属于jar包里的类,是别人写的一个工具类。
就是一个类文件,名为CEVUtil.java,其代码如下:import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.poi.POIXMLDocument; import org.apache.poi.poifs.filesystem.POIFSFileSystem; public class CEVUtil { /** * 依据后缀名判断读取的是否为Excel文件 * @param filePath * @return */ public static boolean isExcel(String filePath){ if(filePath.matches("^.+\\.(?i)(xls)$")||filePath.matches("^.+\\.(?i)(xlsx)$")){ return true; } return false; } /** * 检查文件是否存在 */ public static boolean fileExist(String filePath){ if(filePath == null || filePath.trim().equals("")) return false; File file = new File(filePath); if (file == null || !file.exists()){ return false; } return true; } /** * 依据内容判断是否为excel2003及以下 */ public static boolean isExcel2003(String filePath){ try { BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filePath)); if(POIFSFileSystem.hasPOIFSHeader(bis)) { System.out.println("Excel版本为excel2003及以下"); return true; } } catch (IOException e) { e.printStackTrace(); return false; } return false; } /** * 依据内容判断是否为excel2007及以上 */ public static boolean isExcel2007(String filePath){ try { BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filePath)); if(POIXMLDocument.hasOOXMLHeader(bis)) { System.out.println("Excel版本为excel2007及以上"); return true; } } catch (IOException e) { e.printStackTrace(); return false; } return false; } }
如果您需要使用此类定义的一些功能函数,可以将此java文件包含在工程中。
用心回答每个问题,如果有帮助,请采纳答案好吗,谢谢~~~
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 python的qt5界面
- ¥15 无线电能传输系统MATLAB仿真问题
- ¥50 如何用脚本实现输入法的热键设置
- ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
- ¥30 深度学习,前后端连接
- ¥15 孟德尔随机化结果不一致
- ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
- ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
- ¥15 谁有desed数据集呀
- ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100