I guess answering the question, how to start an Iterator from a specific index, would help me in figuring out how to begin my cellIterator from a specific cell? I've dropped my code block below:
Iterator<Row> rowIterator = spreadSheet.iterator();
while(rowIterator.hasNext()) {
row = (XSSFRow) rowIterator.next();
Iterator<Cell> cellIterator = row.cellIterator();
//Cell cell = row.getCell(7);
cell = cellIterator.next();
How do I get my iterator to start at column (cell) 7?
Any help is greatly appreciated: Thanks :)
LinkedList has a method listIterator(int) which starts from a particular index. I doubt whether rowIterator or columnIteratr provides this. But you can use something like:
public Iterator<E> iterator(int index) {
Iterator<E> iterator = iterator();
for (int i = 0; i < index && iterator.hasNext(); i++) {
iterator.next();
}
return iterator;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.