P
prashantmantri
I am trying to read excel file using POI with code which looks as
follows
HSSFWorkbook wb = new HSSFWorkbook(stream, false);
HSSFSheet sheet = wb.getSheetAt(sheetNo);
int noOfRows = sheet.getPhysicalNumberOfRows();
for (int r = 0; r < noOfRows; r++) {
HSSFRow row = sheet.getRow(r);
if(row == null) break;
//read data
}
What happens is if say I have an excel with 10 rows then i select the
data in last 5 row and delete it and save the excel. Now if I read the
excle again I assume that
int noOfRows = sheet.getPhysicalNumberOfRows(); should give me 5. But
still give me 10 and hence my program fails.
Anyone knows how to handle it?
follows
HSSFWorkbook wb = new HSSFWorkbook(stream, false);
HSSFSheet sheet = wb.getSheetAt(sheetNo);
int noOfRows = sheet.getPhysicalNumberOfRows();
for (int r = 0; r < noOfRows; r++) {
HSSFRow row = sheet.getRow(r);
if(row == null) break;
//read data
}
What happens is if say I have an excel with 10 rows then i select the
data in last 5 row and delete it and save the excel. Now if I read the
excle again I assume that
int noOfRows = sheet.getPhysicalNumberOfRows(); should give me 5. But
still give me 10 and hence my program fails.
Anyone knows how to handle it?