迭代行和列
Contents
[
Hide
]
如何使用Aspose.Cells for Java迭代行和列
可以使用行和列集合迭代行和列。
Java
//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 - HSSF XSSF - 迭代行和列
在 Sheet 上可以迭代行和单元格。下面提供了示例代码。
Java
Workbook wb = WorkbookFactory.create(inStream);
Sheet sheet = wb.getSheetAt(0);
for (Row row : sheet)
{
for (Cell cell : row)
{
System.out.println("Iteration.");
}
}