Free Support Forum -

Cell iterator throws NoSuchElementException


i’ve got this piece of code:

Iterator rowIter = cellsBlabla.getCell(“A10”).getCells().getRowIterator();

Set listOfStrings = someObject.getListOfStrings();

Row actualRow =;

for(String str : listOfStrings) {

Cell actualCell;
Iterator cellIter = actualRow.getCellIterator();

actualCell =

actualCell =

actualCell.setValue(str + “bla”);

// next line…
actualRow =;

1) first call of doesn’t star at “A10” cell but on the first cell, which is weird because then
next call of is on the right row (10th row)

what is wrong with my code? how can I easily get row iterator starting at some row number which I explicitly set?

2) consider second “for each” loop… second call of (where callIter is iterator for cells) throw an NoSuchElementException … why? I couldn’t be on the last cell in the row. What NoSuchElementException indicates in this case?


We will check and get back to you soon.

Thank you.


1.Cells.getRowIterator() is for getting all defined rows in a worksheet. To get row iterator starting at some row number, you can use the method Cells.getRowIterator(int startRowIndex). For more detail, please refer to the java-doc.

2.For the NoSuchElementException, commonly it is caused by having no enough items for the next() method call. If you are sure there are enough data, for you case in loop, at least 2 defined cells per row, please give us your template file and code, we will check and figure the issue out, thank you.