EasyExcel import type conversion error custom exception

Before undefined exception

Inherit AnalysisEventListener to rewrite onException

@Override
    public void onException(Exception exception, AnalysisContext context) throws Exception {
        if (exception instanceof ExcelDataConvertException) {
            ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception;
            Integer row = excelDataConvertException.getRowIndex()+ 1;
            Integer column = excelDataConvertException.getColumnIndex()+1;
            throw new RuntimeException("第"+row+"行,第"+column+"列解析异常,请正确填写");
        }
    }

When an exception is thrown, stop reading the remaining data and return directly.

When no exception is thrown, ignore this line and continue reading insert

After

Guess you like

Origin blog.csdn.net/zjy660358/article/details/129020470