Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

POI row 0, col 0 is null

807606Mar 23 2007 — edited Mar 26 2007
Hi,

I'm trying to load data from 1 excel workbook with several sheets.
The first row on every sheet contains titles which I fetch first:
	private void loadXlsColumns(int sheet) {
		xlsColumns.clear();
		for(int col=0;col<countCols(sheet, 0);col++) {
			String value = (String) evalCell(getCell(sheet, 0, Short.parseShort(col+"")));
			if ((value!=null) && (!value.equals("")) )
				xlsColumns.add(value);
		}	
	}
	public int countCols(int sheet, int row) {
		return workbook.getSheetAt(sheet).getRow(row).getLastCellNum();
	}
	public HSSFCell getCell(int sheet,int row,short column){
		return workbook.getSheetAt(sheet).getRow(row).getCell(column);
	}
Works fine for the first sheet. But whenever I want to do this with the next sheets, getCell() returns null. I've debuged the line and the parameters are correct. He gives null on sheet 1, row 0, cell 0, and there really is data on there. Is there anything I should do before I load the 2nd sheet ? Any ideas ?

Message was edited by:
ReggieBE
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2007
Added on Mar 23 2007
7 comments
190 views