public class RowCollection
extends java.lang.Object
implements java.lang.Iterable
Row objects that represent the individual rows in a worksheet.
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
//Get first row
Row row = worksheet.getCells().getRows().get(0);
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear all rows and cells.
|
Row |
get(int rowIndex)
Gets a
Row object by given row index. |
int |
getCount()
Gets the number of rows in this collection.
|
Row |
getRowByIndex(int index)
Gets the row object by the position in the list.
|
java.util.Iterator |
iterator()
Gets an enumerator that iterates rows through this collection
|
java.util.Iterator |
iterator(boolean reversed,
boolean sync)
Gets an enumerator that iterates rows through this collection
|
void |
removeAt(int index)
Remove the row item at the specified index(position) in this collection.
|
public int getCount()
public java.util.Iterator iterator()
Example
Workbook workbook = new Workbook("template.xlsx");
Cells cells = workbook.getWorksheets().get(0).getCells();
Iterator en = cells.getRows().iterator();
while (en.hasNext())
{
Row row = (Row)en.next();
System.out.println(row.getIndex() + ": " + row.getHeight());
}
iterator in interface java.lang.Iterablepublic java.util.Iterator iterator(boolean reversed,
boolean sync)
Remarks
If the row collection will be modified(by operations that may cause new Row be instantiated or existing Row be removed) during the traversal with the enumerator, synchronized enumerator should be used instead of normal enumerator so that the traversal can continue from the position just after the one has been traversed by the last MoveNext(). However, together with the advantage that no element be skipped or traversed repeatedly, the disadvantage for synchronized enumerator is that the performance will be degraded a bit when comparing with normal enumerator.reversed - whether enumerate rows in reversed ordersync - whether the returned enumerator should check the modification of row collection
and keep synchronized with it.public Row getRowByIndex(int index)
index - The position.public Row get(int rowIndex)
Row object by given row index. The Row object of given row index will be instantiated if it does not exist before.public void clear()
public void removeAt(int index)
index - zero-based index(position, not Row.getIndex()) of the existing row item in this collection.See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.