xelem.3.0

nl.fountain.xelem.excel
Interface Row

All Superinterfaces:
XLElement
All Known Implementing Classes:
SSRow

public interface Row
extends XLElement

Represents the Row element. The XLElement Row is not aware of it's parent, nor of it's index-position in a table or worksheet. This makes it possible to use the same instances of Rows on different worksheets, or different places in the worksheet. Only at the time of assembly the row-index and the attribute ss:Index are automatically set, if necessary. See also: Table.rowIterator(). (Also a Row that is read by the nl.fountain.xelem.lex-API has it's index set.)

See Also:
Worksheet.addRow(), Table.addRow()

Field Summary
 
Fields inherited from interface nl.fountain.xelem.excel.XLElement
PREFIX_HTML, PREFIX_O, PREFIX_SS, PREFIX_X, XMLNS, XMLNS_HTML, XMLNS_O, XMLNS_SS, XMLNS_X
 
Method Summary
 Cell addCell()
          Adds a new Cell to this row.
 Cell addCell(Cell cell)
          Adds the given Cell to this row.
 Cell addCell(double data)
          Adds a new Cell to this row.
 Cell addCell(double data, String styleID)
          Adds a new Cell to this row.
 Cell addCell(int data)
          Adds a new Cell to this row.
 Cell addCell(int data, String styleID)
          Adds a new Cell to this row.
 Cell addCell(Object data)
          Adds a new Cell to this row.
 Cell addCell(Object data, String styleID)
          Adds a new Cell to this row.
 Cell addCellAt(int index)
          Adds a new Cell at the given index.
 Cell addCellAt(int index, Cell cell)
          Adds the given Cell at the given index.
 Iterator<Cell> cellIterator()
          Returns an iterator for the cells in this row.
 Element createElement(Document doc)
          Creates an Element with the specified doc as owner-document.
 Cell getCellAt(int index)
          Gets the cell at the given index.
 TreeMap<Integer,Cell> getCellMap()
          Gets all the cells of this row.
 Collection<Cell> getCells()
          Gets all the cells of this row in the order of their index.
 double getHeight()
          Gets the height of this row.
 int getIndex()
          Gets the value of the ss:Index-attribute of this Row-element.
 int getSpan()
          Gets the number of extra rows this row spans.
 String getStyleID()
          Gets the ss:StyleID which was set on this row.
 boolean hasCellAt(int index)
          Specifies whether this row has a cell at the given index
 boolean isHidden()
          Specifies whether this row is hidden.
 int maxCellIndex()
          Gets the highest index number of the cells in this row.
 Cell removeCellAt(int index)
          Removes the cell at the given index.
 void setHeight(double h)
          Sets the height of this row.
 void setHidden(boolean hide)
          Sets whether this row will be hidden.
 void setIndex(int index)
          Sets the value of the ss:Index-attribute of this Row-element.
 void setSpan(int s)
          Sets the span of this row.
 void setStyleID(String id)
          Sets the ss:StyleID on this row.
 int size()
          Gets the number of cells in this row.
 
Methods inherited from interface nl.fountain.xelem.excel.XLElement
addElementComment, assemble, getElementComments, getNameSpace, getPrefix, getTagName, setAttributes, setChildElement
 

Method Detail

setStyleID

void setStyleID(String id)
Sets the ss:StyleID on this row. If no styleID is set on a row, the ss:StyleID-attribute is not deployed in the resulting xml and Excel employes the Default-style on the row.

Parameters:
id - the id of the style to employ on this row.

getStyleID

String getStyleID()
Gets the ss:StyleID which was set on this row.

Returns:
The id of the style to employ on this row or null if no styleID was previously set.

setSpan

void setSpan(int s)
Sets the span of this row. The value of s must be greater than 0 in order to have effect on the resulting xml.

No other rows must be added within the span of this row:

         Row row = table.addRow(5); // adds a row with index 5
         row.setHeight(25.2);       // do some formatting on the row
         row.setSpan(3);            // span a total of 4 rows
         // illegal: first free index = 5 + 3 + 1 = 9
         // Row row2 = table.addRow(8);
 

Parameters:
s - The number of additional rows to include in the span.

getSpan

int getSpan()
Gets the number of extra rows this row spans.

Returns:
the number of extra rows this row spans

setHeight

void setHeight(double h)
Sets the height of this row.

Parameters:
h - The height of the row (in points).

getHeight

double getHeight()
Gets the height of this row. A return value of 0.0 may indicate this row has a default height.

Returns:
the height of the row (in points).

setHidden

void setHidden(boolean hide)
Sets whether this row will be hidden.

Parameters:
hide - true if this row must not be displayed.

isHidden

boolean isHidden()
Specifies whether this row is hidden.


addCell

Cell addCell()
Adds a new Cell to this row. If no cells were previously added the cell will be added at index 1. Otherwise the cell will be added at maxCellIndex() + 1.

Returns:
A new cell with an initial datatype of "String" and an empty ("") value.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn

addCell

Cell addCell(Object data)
Adds a new Cell to this row. If no cells were previously added the cell will be added at index 1. Otherwise the cell will be added at maxCellIndex() + 1.

Datatype and value of the new cell depend on the passed object.

Parameters:
data - The data to be displayed in this cell.
Returns:
A new cell.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn
See Also:
Cell.setData(Object)

addCell

Cell addCell(Object data,
             String styleID)
Adds a new Cell to this row. If no cells were previously added the cell will be added at index 1. Otherwise the cell will be added at maxCellIndex() + 1.

Datatype and value of the new cell depend on the passed object. The new cell will have it's styleID set to the given id.

Parameters:
data - The data to be displayed in this cell.
styleID - The id of the style to employ on this cell.
Returns:
A new cell.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn
See Also:
Cell.setData(Object), Cell.setStyleID(String)

addCell

Cell addCell(double data)
Adds a new Cell to this row. If no cells were previously added the cell will be added at index 1. Otherwise the cell will be added at maxCellIndex() + 1.

Parameters:
data - The data to be displayed in this cell.
Returns:
A new cell with a datatype "Number" and the given double as value.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn
See Also:
Cell.setData(double)

addCell

Cell addCell(double data,
             String styleID)
Adds a new Cell to this row. If no cells were previously added the cell will be added at index 1. Otherwise the cell will be added at maxCellIndex() + 1. The new cell will have it's styleID set to the given id.

Parameters:
data - The data to be displayed in this cell.
styleID - The id of the style to employ on this cell.
Returns:
A new cell with a datatype "Number" and the given double as value.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn
See Also:
Cell.setData(double), Cell.setStyleID(String)

addCell

Cell addCell(int data)
Adds a new Cell to this row. If no cells were previously added the cell will be added at index 1. Otherwise the cell will be added at maxCellIndex() + 1.

Parameters:
data - The data to be displayed in this cell.
Returns:
A new cell with a datatype "Number" and the given int as value.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn

addCell

Cell addCell(int data,
             String styleID)
Adds a new Cell to this row. If no cells were previously added the cell will be added at index 1. Otherwise the cell will be added at maxCellIndex() + 1. The new cell will have it's styleID set to the given id.

Parameters:
data - The data to be displayed in this cell.
styleID - The id of the style to employ on this cell.
Returns:
A new cell with a datatype "Number" and the given int as value.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn
See Also:
Cell.setStyleID(String)

addCell

Cell addCell(Cell cell)
Adds the given Cell to this row. If no cells were previously added the cell will be added at index 1. Otherwise the cell will be added at maxCellIndex() + 1.

Parameters:
cell - The cell that is to be appended to this row.
Returns:
The passed cell.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn

addCellAt

Cell addCellAt(int index)
Adds a new Cell at the given index. If the index was allready occupied by another cell, replaces this cell.

Parameters:
index - The index (column number) of the cell.
Returns:
A new cell with an initial datatype of "String" and an empty ("") value.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn

addCellAt

Cell addCellAt(int index,
               Cell cell)
Adds the given Cell at the given index. If the index was allready occupied by another cell, replaces this cell.

Parameters:
index - The index (column number) of the cell.
cell - The cell that is to be appended to this row.
Returns:
The passed cell.
Throws:
IndexOutOfBoundsException - If the index is less then Worksheet.firstColumn or greater then Worksheet.lastColumn

removeCellAt

Cell removeCellAt(int index)
Removes the cell at the given index.

Parameters:
index - The index (column number) of the cell.
Returns:
The removed cell or null if the index was not occupied by a cell.

getCellAt

Cell getCellAt(int index)
Gets the cell at the given index.

Parameters:
index - The index (column number) of the cell.
Returns:
The cell at the given index. Never null

hasCellAt

boolean hasCellAt(int index)
Specifies whether this row has a cell at the given index


getCells

Collection<Cell> getCells()
Gets all the cells of this row in the order of their index.

Returns:
A collection of cells.

getCellMap

TreeMap<Integer,Cell> getCellMap()
Gets all the cells of this row. The key of the Map.Entrys is of type Integer and stands for the index number of the cell.

Returns:
A TreeMap of cells.

size

int size()
Gets the number of cells in this row.

Returns:
The number of cells in this row.

maxCellIndex

int maxCellIndex()
Gets the highest index number of the cells in this row.

Returns:
The highest index number of the cells in this row.

cellIterator

Iterator<Cell> cellIterator()
Returns an iterator for the cells in this row. Cells are aware of their index number when passed by this iterator.

Returns:
An iterator for the cells in this row.

createElement

Element createElement(Document doc)
Creates an Element with the specified doc as owner-document. The attribute span will not be reflected in this Element.

Parameters:
doc - the Document to which this row will be appended.
Returns:
this row as an Element.

setIndex

void setIndex(int index)
Sets the value of the ss:Index-attribute of this Row-element. Any value set may be overruled by Table.rowIterator(), which sets the index of rows during assembly.

If you want to place a row in any particular place, use the addRowAt-methods of Table or Worksheet.

Parameters:
index - the index of this row

getIndex

int getIndex()
Gets the value of the ss:Index-attribute of this Row-element. The returned value only makes sence if this row was read with the reader-API in the nl.fountain.xelem.lex-package and before any manipulation of this row or the workbook took place.

Returns:
the value of the ss:Index-attribute of this Row-element
Since:
xelem.2.0

xelem.3.0