|
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.XLWorkbook
public class XLWorkbook
An implementation of the XLElement Workbook, the root of a SpreadsheetML document.
Typically, the XLWorkbook is at the start of creating an Excel workbook in SpreadsheetML. Mostly all of the other objects in xelem can be obtained from it or through it by one of the addXxx- methods.
After setting up the workbook, you can obtain the
org.w3c.dom.Document
from it (see
createDocument()
) or serialize the workbook by means of one of the
serialize-methods of the
XSerializer.class
,
which was included in xelem for convenience.
Worksheets are displayed in Excel in the order that they were added to the
workbook. The methods removeSheet(String)
and
addSheet(Worksheet)
may savely be applied to change this order.
A more convenient way is to obtain the
list of sheet names with getSheetNames()
and manupulating this list.
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 |
Constructor Summary | |
---|---|
XLWorkbook()
Creates a new XLWorkbook. |
|
XLWorkbook(String name)
Creates a new XLWorkbook with the given name. |
Method Summary | |
---|---|
NamedRange |
addNamedRange(NamedRange nr)
Adds a new NamedRange to this workbook. |
NamedRange |
addNamedRange(String name,
String refersTo)
Adds a new NamedRange to this workbook. |
Worksheet |
addSheet()
Adds a new Worksheet to this workbook. |
Worksheet |
addSheet(String name)
Adds a new Worksheet to this workbook with the given name as name. |
Worksheet |
addSheet(Worksheet sheet)
Adds the given Worksheet to this workbook. |
void |
appendInfoSheet()
Appends a Worksheet with general information to this Workbook. |
Element |
assemble(Element root,
GIO gio)
Assembles the state of this XLElement and all of it's children into an Element . |
Document |
createDocument()
Creates a Document , the structure that holds this Workbook
and all of it's children. |
DocumentProperties |
getDocumentProperties()
Gets the DocumentProperties of this workbook. |
ExcelWorkbook |
getExcelWorkbook()
Gets the ExcelWorkbook of this workbook. |
String |
getFileName()
Gets the filename of this Workbook. |
String |
getName()
Gets the name of this Workbook. |
Map<String,NamedRange> |
getNamedRanges()
Gets all the NamedRanges that were added to this workbook. |
String |
getNameSpace()
Gets the namespace of this XLElement. |
String |
getPrefix()
Gets the prefix of this XLElement. |
List<String> |
getSheetNames()
Gets a list of all the names of worksheets in this workbook in display order. |
String |
getTagName()
Gets the tagname (localName) of this XLElement. |
List<String> |
getWarnings()
Gets a list of warnings (Strings) that were registered during assembly of this workbook after a call to Workbook.createDocument() . |
Worksheet |
getWorksheet(String name)
Gets the worksheet with the given name. |
Worksheet |
getWorksheetAt(int index)
Gets the worksheet at the given index. |
List<Worksheet> |
getWorksheets()
Gets a list of all the worksheets in this workbook in display order. |
boolean |
hasDocumentProperties()
Specifies whether this workbook has DocumentProperties. |
boolean |
hasExcelWorkbook()
Specifies whether this workbook has an ExcelWorkbook. |
boolean |
isPrintingDocComments()
Specifies whether this Workbook's Workbook.createDocument() -method
will include docComments. |
boolean |
isPrintingElementComments()
Specifies whether this Workbook's Workbook.createDocument() -method
will include comments. |
void |
mergeStyles(String newID,
String id1,
String id2)
Merges two SpreadsheetML Style elements. |
Worksheet |
removeSheet(String name)
Removes the sheet with the given name. |
void |
setDocumentProperties(DocumentProperties docProps)
Set the DocumentProperties of this workbook or, if this workbook allready had DocumentProperties, replace it. |
void |
setExcelWorkbook(ExcelWorkbook excelWb)
Set the ExcelWorkbook of this workbook or, if this workbook allready had an ExcelWorkbook, replace it. |
void |
setFileName(String filename)
Sets the filename of this Workbook. |
void |
setName(String name)
Sets the name of this Workbook. |
void |
setPrintDocComments(boolean print)
Sets whether this Workbook's Workbook.createDocument() -method
will include docComments. |
void |
setPrintElementComments(boolean print)
Sets whether this Workbook's Workbook.createDocument() -method
will print comments which were set with
XLElement.addElementComment(String) . |
Methods inherited from class nl.fountain.xelem.excel.AbstractXLElement |
---|
addElementComment, assemble, createAttributeNS, createAttributeNS, createElementNS, createElementNS, createElementNS, createElementNS, getElementComments, setAttributes, setChildElement |
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, setAttributes, setChildElement |
Constructor Detail |
---|
public XLWorkbook()
public XLWorkbook(String name)
Method Detail |
---|
public void setName(String name)
Workbook
setName
in interface Workbook
public String getName()
Workbook
getName
in interface Workbook
public void setFileName(String filename)
Workbook
setFileName
in interface Workbook
public String getFileName()
Workbook
Workbook.setFileName(String)
the name of the workbook is returned
with the extension '.xls'.
getFileName
in interface Workbook
public void mergeStyles(String newID, String id1, String id2) throws UnsupportedStyleException
Workbook
mergeStyles
in interface Workbook
newID
- the ss:ID of the new merged styleid1
- the ss:ID of the copied styleid2
- the ss:ID of the appended style
UnsupportedStyleException
- if either of the styles mentioned with
id1 or id2 are unknown to the factory.XFactory.mergeStyles(String, String, String)
public void appendInfoSheet()
Workbook
appendInfoSheet
in interface Workbook
public void setDocumentProperties(DocumentProperties docProps)
Workbook
setDocumentProperties
in interface Workbook
docProps
- the DocumentProperties for this workbookpublic DocumentProperties getDocumentProperties()
Workbook
getDocumentProperties
in interface Workbook
null
.public boolean hasDocumentProperties()
Workbook
hasDocumentProperties
in interface Workbook
public void setExcelWorkbook(ExcelWorkbook excelWb)
Workbook
setExcelWorkbook
in interface Workbook
excelWb
- The ExcelWorkbook for this workbookpublic ExcelWorkbook getExcelWorkbook()
Workbook
getExcelWorkbook
in interface Workbook
null
.public boolean hasExcelWorkbook()
Workbook
hasExcelWorkbook
in interface Workbook
public NamedRange addNamedRange(NamedRange nr)
Workbook
addNamedRange
in interface Workbook
nr
- the NamedRange to be added to this workbook
public NamedRange addNamedRange(String name, String refersTo)
Workbook
The string refersTo
should be of format
[worksheet name]!R1C1:R1C1
.
If this workbook allready contained a NamedRange with the given name,
replaces it.
addNamedRange
in interface Workbook
name
- The name to apply to the range.refersTo
- A String of R1C1 reference style, including worksheet name.
public Map<String,NamedRange> getNamedRanges()
Workbook
getNamedRanges
in interface Workbook
public Worksheet addSheet()
Workbook
addSheet
in interface Workbook
public Worksheet addSheet(String name)
Workbook
addSheet
in interface Workbook
name
- The name that is to be given to the new worksheet.
public Worksheet addSheet(Worksheet sheet)
Workbook
addSheet
in interface Workbook
sheet
- The worksheet to be added.
public List<Worksheet> getWorksheets()
Workbook
getWorksheets
in interface Workbook
public List<String> getSheetNames()
Workbook
Collections.swap(workbook.getSheetNames(), 0, 2);will display the first worksheet added to this workbook at position 3.
No objects should be added to this list.
getSheetNames
in interface Workbook
public Worksheet getWorksheet(String name)
Workbook
getWorksheet
in interface Workbook
name
- The name of the worksheet.
null
if
no worksheet with that name was in this workbook.public Worksheet getWorksheetAt(int index)
Workbook
getWorksheetAt
in interface Workbook
index
- the worksheet index number
null
if
no worksheet was at that indexpublic Worksheet removeSheet(String name)
Workbook
removeSheet
in interface Workbook
name
- The name of the worksheet to remove.
null
if a worksheet with
the given name was not in this workbook.public void setPrintElementComments(boolean print)
Workbook
Workbook.createDocument()
-method
will print comments which were set with
XLElement.addElementComment(String)
.
The default is true.
setPrintElementComments
in interface Workbook
XLElement.addElementComment(String)
public void setPrintDocComments(boolean print)
Workbook
Workbook.createDocument()
-method
will include docComments. DocComments are the comments that will
be passed in at the start of the Workbook document,
just after the processing instruction.
DocComments can be configured in the configuration file, standard at config/xelem.xml.
The default is true.
setPrintDocComments
in interface Workbook
XFactory.getDocComments()
public boolean isPrintingElementComments()
Workbook
Workbook.createDocument()
-method
will include comments.
isPrintingElementComments
in interface Workbook
public boolean isPrintingDocComments()
Workbook
Workbook.createDocument()
-method
will include docComments.
isPrintingDocComments
in interface Workbook
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 Document createDocument() throws ParserConfigurationException
Workbook
Document
, the structure that holds this Workbook
and all of it's children.
During assembly
non fatal-errors will be registered as warnings. See Workbook.getWarnings()
.
A new call to createDocument erases all previous warnings.
Non fatal-errors could be:
XFactory
could not be configured.
<Style ss:ID="foo"/>
).
Workbook.appendInfoSheet()
was called, but an infoSheet-Node
could not be created.
createDocument
in interface Workbook
Document
, representing this workbook.
ParserConfigurationException
- if the document could not be created.public Element assemble(Element root, GIO gio)
XLElement
Element
. Attaches the new element to it's
parent-element if needed.
assemble
in interface XLElement
root
- the parent-element to which the new formed element
will be appendedgio
- a global information object
public List<String> getWarnings()
Workbook
Workbook.createDocument()
.
getWarnings
in interface Workbook
|
xelem.3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |