|
xelem.3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nl.fountain.xelem.excel.AbstractXLElement nl.fountain.xelem.excel.ss.SSCell
public class SSCell
An implementation of the XLElement Cell.
The setData(Object)
-method reflects
upon the class of the given object and will delegate to a corresponding
setData-method if such a method is available. If no corresponding
method is found this method sets the data of this cell to the
toString
-value of the given object and the datatype to
"String".
This class may be extended to accommodate setData-methods for java-objects
that might otherwise
be displayed as the toString
-value of that object.
Null values
If the passed parameter has a value of null
the resulting
xml will have a datatype set to "Error",
the formula of the cell will be set to "=#N/A
" and the cell will
display "#N/A
" when the spreadsheet is opened.
Infinite values
If the passed parameter is of type Double, Float or the primitive representation
of these objects and the method isInfinite
results to true
the resulting xml will have a datatype set to
"String" and the cell will display "Infinite" when the spreadsheet is opened.
NaN values
If the passed parameter is of type Double, Float or the primitive representation
of these objects and the method isNaN
results to true
the resulting xml will have a datatype set to
"String" and the cell will display "NaN" when the spreadsheet is opened.
Worksheet.addCell()
,
Row.addCell()
Field Summary |
---|
Fields inherited from interface nl.fountain.xelem.excel.Cell |
---|
DATATYPE_BOOLEAN, DATATYPE_DATE_TIME, DATATYPE_ERROR, DATATYPE_NUMBER, DATATYPE_STRING, ERRORVALUE_DIV_BY_0, ERRORVALUE_NA, ERRORVALUE_NAME, ERRORVALUE_NULL, ERRORVALUE_NUM, ERRORVALUE_REF, ERRORVALUE_VALUE |
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 |
Constructor Summary | |
---|---|
SSCell()
Creates a new SSCell with an initial datatype of "String" and an empty ("") value. |
Method Summary | |
---|---|
Comment |
addComment()
Adds a comment to this cell. |
Comment |
addComment(Comment comment)
Adds the given comment to this cell. |
Comment |
addComment(String text)
Adds a comment to this cell and sets the data-attribute of the comment to the given text. |
Element |
assemble(Element parent,
GIO gio)
Assembles the state of this XLElement and all of it's children into an Element . |
boolean |
booleanValue()
Convenience method for reading the value of the data element of this cell as a boolean . |
double |
doubleValue()
Convenience method for reading the value of the data element of this cell as a double . |
Comment |
getComment()
Gets the comment of this cell. |
Object |
getData()
Gets the value of the data element of this cell as an object. |
String |
getData$()
Gets the NodeValue of the Data-tag as a String. |
Element |
getDataElement(Document doc)
Gets the Data-element of this cell as an org.w3c.dom.Element . |
String |
getFormula()
Gets the formula that was set on this cell. |
String |
getHRef()
Gets the ss:HRef-attribute value that was set on this cell. |
int |
getIndex()
Gets the value of the ss:Index-attribute of this Cell-element. |
int |
getMergeAcross()
Gets the number of cells over which this cell has been merged horizontally. |
int |
getMergeDown()
Gets the number of cells over which this cell has been merged vertically. |
String |
getNameSpace()
Gets the namespace of this XLElement. |
String |
getPrefix()
Gets the prefix of this XLElement. |
String |
getStyleID()
Gets the ss:StyleID which was set on this cell. |
String |
getTagName()
Gets the tagname (localName) of this XLElement. |
String |
getXLDataType()
Gets the value of the ss:Type-attribute of the Data-element. |
boolean |
hasComment()
Specifies whether this cell has a comment. |
boolean |
hasData()
Specifies whether this cell has data. |
boolean |
hasError()
Specifies whether this cell has an error. |
int |
intValue()
Convenience method for reading the value of the data element of this cell as an int . |
void |
setAttributes(Attributes attrs)
Does effectively nothing. |
void |
setChildElement(String localName,
String content)
Does effectively nothing. |
void |
setData(boolean data)
Sets the given boolean as the data of this cell. |
void |
setData(Boolean data)
Sets the given Boolean as the data of this cell. |
void |
setData(byte data)
Sets the given byte as the data of this cell. |
void |
setData(char data)
Sets the data of this cell to the value String.valueOf(char) . |
void |
setData(Date data)
Sets the given Date as the data of this cell. |
void |
setData(double data)
Sets the given double as the data of this cell. |
void |
setData(Double data)
Sets the given Double as the data of this cell. |
void |
setData(float data)
Sets the given float as the data of this cell. |
void |
setData(Float data)
Sets the given Float as the data of this cell. |
void |
setData(int data)
Sets the given int as the data of this cell. |
void |
setData(Integer data)
Sets the given Integer as the data of this cell. |
void |
setData(long data)
Sets the given long as the data of this cell. |
void |
setData(Long data)
Sets the given Long as the data of this cell. |
void |
setData(Number data)
Sets the given Number as the data of this cell. |
void |
setData(Object data)
Sets the given object as the data of this cell. |
void |
setData(short data)
Sets the given short as the data of this cell. |
void |
setData(String data)
Sets the given String as the data of this cell. |
void |
setError(String error_value)
Sets the given error value as the data of this cell. |
void |
setFormula(String formula)
Sets the ss:Formula-attribute on this cell. |
void |
setHRef(String href)
Sets the ss:HRef-attribute on this cell. |
void |
setIndex(int index)
Sets the value of the ss:Index-attribute of this Cell-element. |
void |
setMergeAcross(int m)
Merges this cell with adjacent cells on the same row. |
void |
setMergeDown(int m)
Merges this cell with adjacent cells on the same column. |
void |
setStyleID(String id)
Sets the ss:StyleID on this cell. |
protected void |
setType(String type)
Sets the value of the ss:Type-attribute of the Data-element. |
protected void |
setXLDataType(String type)
Deprecated. as of xelem.2.0 use setType(String) |
Methods inherited from class nl.fountain.xelem.excel.AbstractXLElement |
---|
addElementComment, assemble, createAttributeNS, createAttributeNS, createElementNS, createElementNS, createElementNS, createElementNS, getElementComments |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface nl.fountain.xelem.excel.XLElement |
---|
addElementComment, getElementComments |
Constructor Detail |
---|
public SSCell()
Worksheet.addCell()
Method Detail |
---|
public void setStyleID(String id)
The refered style-definition must be available from the
XFactory
.
If the definition was not found,
the XLWorkbook
-implementation will create an empty ss:Style-definition
and adds a UnsupportedStyleException-warning.
setStyleID
in interface Cell
id
- the id of the style to employ on this cell.XLWorkbook.getWarnings()
public String getStyleID()
Cell
getStyleID
in interface Cell
null
if no styleID was previously set.public void setFormula(String formula)
Cell
cell.setData(3); cell.setFormula("=1+1");will display
2
in the opened spreadsheet.
setFormula
in interface Cell
formula
- The formula for this cell.public String getFormula()
Cell
getFormula
in interface Cell
null
if the cell has no formula.public void setHRef(String href)
Cell
setHRef
in interface Cell
href
- the ss:HRef-attribute on this cell.public String getHRef()
Cell
getHRef
in interface Cell
null
if this cell has no HRef.public Comment addComment()
Cell
addComment
in interface Cell
public Comment addComment(Comment comment)
Cell
addComment
in interface Cell
comment
- the comment to be added to this cell
public Comment addComment(String text)
Cell
addComment
in interface Cell
text
- the string to be displayed in the newly added comment
public boolean hasComment()
Cell
hasComment
in interface Cell
true
if this cell has a comment, false otherwise.public Comment getComment()
Cell
getComment
in interface Cell
null
.public void setMergeAcross(int m)
Cell
The value of
m
must be greater than 0 in order to have effect on
the resulting xml. No logic is included to prevent the merging of
cells that goes beyond the width of the spreadsheet. If such is the case,
the resulting xml spreadsheet will not open.
No other cells must be added within the scope of the merged cell:
Cell c1 = sheet.addCellAt(1, 3); // adds a cell at row 1, column 3 c1.setMergeAcross(5); // merges c1 across columns 3 - 8 // illegal: first free index = 3 + 5 + 1 = 9 // Cell c2 = sheet.addCellAt(1, 7);
setMergeAcross
in interface Cell
m
- The number of cells to include in the merge.public int getMergeAcross()
Cell
0
indicates no horizontal merge
was applied on this cell.
getMergeAcross
in interface Cell
public void setMergeDown(int m)
Cell
The value of
m
must be greater than 0 in order to have effect on
the resulting xml.
No other rows or cells must be added within the scope of the merged cell:
Cell c1 = sheet.addCellAt(1, 3); // adds a cell at row 1, column 3 c1.setMergeDown(5); // merges c1 across rows 1 - 6 // illegal: first free index = 1 + 5 + 1 = 7 // Cell c2 = sheet.addCellAt(5, 3);
setMergeDown
in interface Cell
m
- The number of cells to include in the merge.public int getMergeDown()
Cell
0
indicates no vertical merge
was applied on this cell.
getMergeDown
in interface Cell
public String getXLDataType()
Cell
getXLDataType
in interface Cell
public void setData(Number data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(Integer data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(Double data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(Long data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(Float data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(Date data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(Boolean data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(String data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(Object data)
Cell
toString
-value of the given object and the datatype to
"String".
setData
in interface Cell
data
- The data to be displayed in this cell.public void setError(String error_value)
Cell
setError
in interface Cell
error_value
- Must be one of Cell's ERRORVALUE_XXX values.public void setData(byte data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(short data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(int data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(long data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(float data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(double data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(char data)
Cell
String.valueOf(char)
. The attribute
ss:Type of the Data-element will be set to "String".
setData
in interface Cell
data
- The data to be displayed in this cell.public void setData(boolean data)
Cell
setData
in interface Cell
data
- The data to be displayed in this cell.public boolean hasData()
Cell
hasData
in interface Cell
true
if this cell has a data element,
false
otherwisepublic boolean hasError()
Cell
hasError
in interface Cell
true
if the 'Type' attribute of this cells
data element equals DATATYPE_ERROR, false
otherwisepublic String getData$()
Cell
getData$
in interface Cell
public Object getData()
Cell
xlDataType | returned type |
---|---|
Number | Double |
DateTime | Date |
Boolean | Boolean |
String | String |
Error | String |
(not specified) | String |
getData
in interface Cell
public int intValue()
Cell
int
. Returns 0
if the value could not be converted.
intValue
in interface Cell
public double doubleValue()
Cell
double
. Returns 0.0
if the value could not be converted.
doubleValue
in interface Cell
public boolean booleanValue()
Cell
boolean
. Returns false
if the value is not equal to "1".
booleanValue
in interface Cell
public String getTagName()
XLElement
getTagName
in interface XLElement
public String getNameSpace()
XLElement
getNameSpace
in interface XLElement
public String getPrefix()
XLElement
getPrefix
in interface XLElement
public Element assemble(Element parent, GIO gio)
XLElement
Element
. Attaches the new element to it's
parent-element if needed.
assemble
in interface XLElement
parent
- the parent-element to which the new formed element
will be appendedgio
- a global information object
public void setAttributes(Attributes attrs)
AbstractXLElement
setAttributes
in interface XLElement
setAttributes
in class AbstractXLElement
attrs
- the attributes found on the elementpublic void setChildElement(String localName, String content)
AbstractXLElement
setChildElement
in interface XLElement
setChildElement
in class AbstractXLElement
localName
- the local name of the childcontent
- the content of the childpublic Element getDataElement(Document doc)
Cell
org.w3c.dom.Element
.
getDataElement
in interface Cell
doc
- the document to which the returned element may be appended
protected void setXLDataType(String type)
setType(String)
type
- one of Cell's DATATYPE_XXX valuesprotected void setType(String type)
type
- Must be one of Cell's DATATYPE_XXX values.public void setIndex(int index)
Cell
Row.cellIterator()
, which sets the
index of cells during assembly.
If you want to place a cell in any particular place, use the addCellAt-methods of Row, Table or Worksheet, or use Worksheets CellPointer.
setIndex
in interface Cell
index
- the index of this cellpublic int getIndex()
Cell
getIndex
in interface Cell
|
xelem.3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |