/*** 读取转换异常
**/
public class DemoExceptionListener extends AnalysisEventListener{private static final Logger LOGGER = LoggerFactory.getLogger(DemoExceptionListener.class);/*** 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收*/
private static final int BATCH_COUNT = 5;
List list = new ArrayList();//定义接收异常
private StringBuffer errorMsg;/*** 在转换异常 获取其他异常下会调用本接口。抛出异常则停止读取。如果这里不抛出异常则 继续读取下一行。
*
*@paramexception
*@paramcontext
*@throwsException*/@Overridepublic voidonException(Exception exception, AnalysisContext context) {
LOGGER.error("解析失败,但是继续解析下一行:{}", exception.getMessage());//如果是某一个单元格的转换异常 能获取到具体行号//如果要获取头的信息 配合invokeHeadMap使用
if (exception instanceofExcelDataConvertException) {
ExcelDataConvertException excelDataConvertException=(ExcelDataConvertException)exception;