https://bz.apache.org/bugzilla/show_bug.cgi?id=65916
--- Comment #9 from moimoi.chk <moimoi....@gmail.com> --- Hey Tom! This problem seems to occur when there is an empty line in the iterator. ================= Examples of okay case1 remove empty row ================= fun clearAll(sheet: Sheet) { val itr = sheet.rowIterator() while (itr.hasNext()) { val row = itr.next() if (row.rowNum >= 4) { clearRow(row) itr.remove()// remove empty row } } } fun clearRow(row: Row) { val itr = row.cellIterator() while (itr.hasNext()) { itr.next() itr.remove() } } ================= Examples of okay case2 Leave at least one cell in the row ================= fun clearAll(sheet: Sheet) { val itr = sheet.rowIterator() while (itr.hasNext()) { val row = itr.next() if (row.rowNum >= 4) { clearRow(row) } } } fun clearRow(row: Row) { // count cell var itr = row.cellIterator() var cellCount = 0 while (itr.hasNext()) { itr.next() cellCount++ } if (cellCount == 0) { return } // leave one cell and delete the rest val keepTarget = Random().nextInt(cellCount) itr = row.cellIterator() var i = 0 while (itr.hasNext()) { itr.next() if (i++ != keepTarget) { itr.remove() cellCount-- } } assert(cellCount == 1) } -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org