RowCollection

Inheritance: java.lang.Object

All Implemented Interfaces: java.lang.Iterable

public class RowCollection implements Iterable

Collects the 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);

Methods

MethodDescription
clear()Clear all rows and cells.
equals(Object arg0)
get(int rowIndex)Gets a Row object by given row index.
getClass()
getCount()Gets the number of rows in this collection.
getRowByIndex(int index)Gets the row object by the position in the list.
hashCode()
iterator()Gets an enumerator that iterates rows through this collection
iterator(boolean reversed, boolean sync)Gets an enumerator that iterates rows through this collection
notify()
notifyAll()
removeAt(int index)Remove the row item at the specified index(position) in this collection.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

clear()

public void clear()

Clear all rows and cells.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

get(int rowIndex)

public Row get(int rowIndex)

Gets a Row object by given row index. The Row object of given row index will be instantiated if it does not exist before.

Parameters:

ParameterTypeDescription
rowIndexint

Returns: Row

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getCount()

public int getCount()

Gets the number of rows in this collection.

Returns: int

getRowByIndex(int index)

public Row getRowByIndex(int index)

Gets the row object by the position in the list.

Parameters:

ParameterTypeDescription
indexintThe position.

Returns: Row - The Row object at given position.

hashCode()

public native int hashCode()

Returns: int

iterator()

public Iterator iterator()

Gets an enumerator that iterates rows through this collection

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

Returns: java.util.Iterator - enumerator

iterator(boolean reversed, boolean sync)

public Iterator iterator(boolean reversed, boolean sync)

Gets an enumerator that iterates rows through this collection

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.

Parameters:

ParameterTypeDescription
reversedbooleanwhether enumerate rows in reversed order
syncbooleanwhether the returned enumerator should check the modification of row collection and keep synchronized with it.

Returns: java.util.Iterator - The row enumerator

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

removeAt(int index)

public void removeAt(int index)

Remove the row item at the specified index(position) in this collection.

Parameters:

ParameterTypeDescription
indexintzero-based index(position, not Row.getIndex()) of the existing row item in this collection.

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int