Nov 25

In previous posts we have covered opening Excel files, and accessing sheets. Now we need to move onto reading the rows and cells in that sheet.

FileInputStream in = new FileInputStream(file);
Workbook workbook = WorkbookFactory.create(in);

int nsheets = workbook.getNumberOfSheets();
for (int i=0; i<nsheets; i++) {
	Sheet sheet = workbook.getSheetAt(i);
	for (Row row : sheet) {
		for (Cell cell : row) {
			
			// Do what you want with the cell value
		}
	}
}

written by objects \\ tags: , , , , ,


One Response to “Reading Excel rows using POI”

  1. Prashant Says:

    Sir as per JAVA project ..
    I need to read an particolar cell valur
    (say cell no. D5)
    how can i read that.

    secondly,
    how can i read all the cells in a given row.

    Please help sir.
    I need it.
    I will be grateful to you Sir.

Leave a Reply

You must be logged in to post a comment.