Wiki

Clone wiki

Aspose for Apache POI / Iterate-Rows-and-Columns

Apache POI SS

Workbook wb = WorkbookFactory.create(inStream);
Sheet sheet = wb.getSheetAt(0);
for (Row row : sheet) 
{
  for (Cell cell : row) 
  {
    System.out.println("Iteration.");
  }
}

Aspose.Cells

//Access the Maximum Display Range
Range range = worksheet.getCells().getMaxDisplayRange();
int tcols = range.getColumnCount();
int trows = range.getRowCount();

System.out.println("Total Rows:" + trows);
System.out.println("Total Cols:" + tcols);

RowCollection rows = cells.getRows();

for (int i = 0 ; i < rows.getCount() ; i++)
{
    for (int j = 0 ; j < tcols ; j++)
    {
        System.out.print(cells.get(i,j).getName() + " - " + cells.get(i,j).getValue() + "\t");
    }
    System.out.println("");
}

Download Source Code

Updated