Nedd Api to get all the cell's value

Hi,


I want to get the all the data’s in the cells of a worksheet.

Tried with the following code. But if a cell in a row is empty, i can’t get that cell or it’s value as empty.

Worksheet worksheet = workbook.getWorksheets().get(0);

RowCollection rows = worksheet.getCells().getRows();

Iterator rowIterator = rows .iterator();

while (rowIterator.hasNext())

{

Row r = rowIterator.next();

Iterator cellIterator = r .iterator();

while (cellIterator.hasNext())

{

Cell cell = cellIterator.next();

System.out.print(cell.getStringValue() + “\t”);

}

}

Hi,



I think you may try to use the code segment if it works for your needs:
e.g
Sample code:

int maxRow = worksheet.getCells().getMaxRow();
int maxCol = worksheet.getCells().getMaxColumn();
for (int i = 0; i < maxRow; i++ ) {
for ( int j = 0; j < maxCol; j++ ) {
Cell cell = worksheet.getCells().get(i, j);
System.out.print(cell.getStringValue() + “\t”);
}
}

Thank you.



Yeah. Thank you. It works fine.

Hi,


Good to know that it figures out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.