cn.hutool.poi.PoiChecker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hutool-all Show documentation
Show all versions of hutool-all Show documentation
Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。
package cn.hutool.poi;
import cn.hutool.core.exceptions.DependencyException;
import cn.hutool.core.util.ClassLoaderUtil;
/**
* POI引入检查器
*
* @author looly
* @since 4.0.10
*/
public class PoiChecker {
/** 没有引入POI的错误消息 */
public static final String NO_POI_ERROR_MSG = "You need to add dependency of 'poi-ooxml' to your project, and version >= 4.1.2";
/**
* 检查POI包的引入情况
*/
public static void checkPoiImport() {
try {
Class.forName("org.apache.poi.ss.usermodel.Workbook", false, ClassLoaderUtil.getClassLoader());
} catch (ClassNotFoundException | NoClassDefFoundError | NoSuchMethodError e) {
throw new DependencyException(e, NO_POI_ERROR_MSG);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy