Aspose.Cells - Iterate Rows and Columns

//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("");
}

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.");
  }
}


Download Source Code

For More Examples, Please Visit Aspose Docs

Last edited Jan 29, 2015 at 9:24 AM by shoaibkhan, version 2