jeecgboot / autopoi

AutoPOI 功能如同名字auto,追求的就是自动化,让一个没接触过poi的人员,可以傻瓜化的快速实现Excel导入导出、Word模板导出、可以仅仅5行代码就可以完成Excel的导入导出。
http://www.jeecg.com
Apache License 2.0
460 stars 199 forks source link

读取空行时越界 #116

Open skiloop opened 2 months ago

skiloop commented 2 months ago

版本:1.4.7

我遇到了一个案例,表格结尾几行没有单元格导致越界异常。 ExcelImportServer.java的133行importExcel函数

int firstCellNum = row.getFirstCellNum();
                    if (firstCellNum > minColumnIndex) {
                        firstCellNum = minColumnIndex;
                    }

                    int lastCellNum = row.getLastCellNum();
                    if (lastCellNum < maxColumnIndex + 1) {
                        lastCellNum = maxColumnIndex + 1;
                    }

                    int i = firstCellNum;

                    for(int le = lastCellNum; i < le; ++i) {
                        Cell cell = row.getCell(i);

因为没有单元格,getFirstCellNum返回-1, 导致Cell cell = row.getCell(i);发生越界异常。