All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jxls.reader.XLSRowCursorImpl Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package org.jxls.reader;

import java.util.NoSuchElementException;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;

/**
 * @author Leonid Vysochyn
 */
public class XLSRowCursorImpl implements XLSRowCursor {
    int currentRowNum;
    Sheet sheet;
    String sheetName;


    public XLSRowCursorImpl(Sheet sheet) {
        this.sheet = sheet;
    }


    public XLSRowCursorImpl(String sheetName, Sheet sheet) {
        this.sheetName = sheetName;
        this.sheet = sheet;
    }

    public int getCurrentRowNum() {
        return currentRowNum;
    }

    public Row getCurrentRow() {
        return sheet.getRow( currentRowNum );
    }


    public Sheet getSheet() {
        return sheet;
    }

    public void setSheet(Sheet sheet) {
        this.sheet = sheet;
    }

    public String getSheetName() {
        return sheetName;
    }

    public void setSheetName(String sheetName) {
        this.sheetName = sheetName;
    }

    public Row next() {
        if( hasNext() ){
            return sheet.getRow( currentRowNum++ );
        }
        throw new NoSuchElementException();
    }

    public boolean hasNext() {
        return (currentRowNum <= sheet.getLastRowNum());
    }

    public void reset() {
        currentRowNum = 0;
    }

    public void setCurrentRowNum(int rowNum) {
        currentRowNum = rowNum;
    }

    public void moveForward() {
        currentRowNum++;
    }

    public void moveBackward() {
        currentRowNum--;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy