com.f1j.ss
Class XMLWriter

java.lang.Object
  |
  +--com.actuate.util.Debug
        |
        +--com.f1j.util.Debug
              |
              +--com.f1j.util.ObjConst
                    |
                    +--com.f1j.util.Obj
                          |
                          +--com.f1j.ss.XMLWriter

public class XMLWriter
extends com.f1j.util.Obj

This class writes data from workbook ranges to XML. The resulting XML data can be formatted using an XSLT document.

XMLWriter outputs the following XML tags:

XMLWriter Output Tags and Attributes
Tag Attribute Description
<book>
<sheet> name string (e.g. "Sheet1")
<range> name string (e.g. "A1:G30" or "MergedRange" if ranges have been merged)
<row> index number (the row number)
skip number (of rows skipped prior to the last <row> element. Rows with formatting are not skipped)
height-twips number (row height in twips, e.g. 240 = 12pt)
<cell> width-twips number (cell height in twips, e.g. 240 = 12pt)
hidden boolean (true = cell is hidden)
locked boolean (true = cell is locked)
keys string (a list of all defined names referring to this cell)
alignment-horizontal string ("left," "center," "right")
alignment-vertical string ("top," "center," "bottom")
font-bold boolean (true = bold)
font-italic boolean (true = italic)
font-color RGB value (e.g. 0XFF0000 = red)
font-size-twips number (e.g. 240 = 12pt)
merge-horizontal number (of cells merged to the right)
merge-vertical number (of cells merged down)
pattern-fg RGB value (e.g. 0XFF0000 = red)
skip number (of cells skipped. Rows with formatting are not skipped)
wrap boolean (true = wrap cell text)

See Also:
HTMLWriter

Field Summary
static short eMergeRangeNone
          Ranges treated as separate ranges.
static short eMergeRangeRows
          Ranges merged into one range.
 
Constructor Summary
XMLWriter(Book book)
          Constructs an XML file based on data from the designated Book.
 
Method Summary
 short getMergeRangeType()
          Returns how ranges will be merged (if applicable) when calling the write method.
 boolean isSkipEmptyCells()
          Returns whether empty cells are skipped.
 boolean isWriteFormatAttributes()
          Returns whether cell formatting information is written out in the cell tag.
 boolean isWriteKeyAttributes()
          Returns whether the keys parameter is included in the cell tag.
 void setMergeRangeType(short type)
          Specifies how ranges are output.
 void setSkipEmptyCells(boolean b)
          Sets whether empty cells are skipped.
 void setWriteFormatAttributes(boolean b)
          Sets whether cell formatting information is included within the cell tag in the XML ouput.
 void setWriteKeyAttributes(boolean b)
          Sets whether the keys parameter is included in the cell tag.
 void write(java.lang.String[] formulas, java.io.InputStream styleSheet, java.io.OutputStream output)
          Writes the given ranges from a worksheet to an output stream and processes the XML output with a user-supplied XSLT document.
 void write(java.lang.String[] formulas, java.io.OutputStream output)
          Writes the given ranges from a worksheet to an output stream as XML data.
 void write(java.lang.String formula, java.io.InputStream styleSheet, java.io.OutputStream output)
          Writes the given range from a worksheet to an output stream and processes the XML output with a user-supplied XSLT document.
 void write(java.lang.String formula, java.io.OutputStream output)
          Writes the given range from a worksheet to an output stream as XML data.
 

Field Detail

eMergeRangeNone

public static final short eMergeRangeNone
Ranges treated as separate ranges. Each individual range specified by the formula array in the write method wil be placed within a <range></range> tag.

eMergeRangeRows

public static final short eMergeRangeRows
Ranges merged into one range. All ranges specified in all of the formula[] array will be merged within one <range> </range> tag by outputting <cell> delimited values for each range before starting a new row. For example, if you specified the following ranges:

A1:B5, D5:F10, I1:I4

the cell would be output as follows:

     A1  B1  D5  E5  F5  I1
     A2  B2  D6  E6  F6  I2
     A3  B3  D7  E7  F7  I3
     A4  B4  D8  E8  F8  I4
     A5  B5  D9  E9  F9  -
     -   -   D10 F10 F10 -
 
Constructor Detail

XMLWriter

public XMLWriter(Book book)
Constructs an XML file based on data from the designated Book.
Parameters:
book - a Book object.
Method Detail

getMergeRangeType

public short getMergeRangeType()
Returns how ranges will be merged (if applicable) when calling the write method.
Returns:
a short indicating how multiple ranges are treated: eMergeRangeNone = ranges treated separately; eMergeRangeRows = ranges merged into one.
See Also:
eMergeRangeNone, eMergeRangeRows, setMergeRangeType(short)

isSkipEmptyCells

public boolean isSkipEmptyCells()
Returns whether empty cells are skipped. If true is returned, the skip attribute is included in <row> and <cell> tags. The skip attribute indicates how many empty cells occurred in the original range before the cell with the skip attribute. This optimizes the output stream if the range contains many empty cells.
Returns:
boolean. true/false.
See Also:
setSkipEmptyCells(boolean)

isWriteFormatAttributes

public boolean isWriteFormatAttributes()
Returns whether cell formatting information is written out in the cell tag. By default, cell format information is not ouput. See the class description for a table describing output tags and attributes.
Returns:
boolean. true/false.
See Also:
setWriteFormatAttributes(boolean), write(String[] formulas, java.io.InputStream styleSheet, java.io.OutputStream output)

isWriteKeyAttributes

public boolean isWriteKeyAttributes()
Returns whether the keys parameter is included in the cell tag. The keys parameter contains a list of all of the defined names in the workbook that refer to this cell.
Returns:
boolean. true/false.
See Also:
setWriteKeyAttributes(boolean)

setMergeRangeType

public void setMergeRangeType(short type)
                       throws F1Exception
Specifies how ranges are output.
Parameters:
type - a short indicating how to treat multiple ranges: eMergeRangeNone = ranges treated separately; eMergeRangeRows = ranges merged into one.
Throws:
F1Exception - if parameter is invalid
See Also:
eMergeRangeNone, eMergeRangeRows, getMergeRangeType()

setSkipEmptyCells

public void setSkipEmptyCells(boolean b)
Sets whether empty cells are skipped. If called with true, the skip attribute is included in <row> and <cell> tags. The skip attribute indicates how many empty cells occurred in the original range before the cell with the skip attribute. This optimizes the output stream if the range contains many empty cells.
Parameters:
b - boolean. true/false.
See Also:
isSkipEmptyCells()

setWriteFormatAttributes

public void setWriteFormatAttributes(boolean b)
Sets whether cell formatting information is included within the cell tag in the XML ouput. See the class description for a table describing output tags and attributes.
Parameters:
b - boolean. true/false.
See Also:
isWriteFormatAttributes(), write(String[] formulas, java.io.InputStream styleSheet, java.io.OutputStream output)

setWriteKeyAttributes

public void setWriteKeyAttributes(boolean b)
Sets whether the keys parameter is included in the cell tag. The keys parameter contains a list of all of the defined names in the workbook that refer to this cell.
Returns:
boolean. true/false.
See Also:
isWriteKeyAttributes()

write

public void write(java.lang.String formula,
                  java.io.OutputStream output)
           throws F1Exception
Writes the given range from a worksheet to an output stream as XML data. This method creates XML with no XSLT formatting.
Parameters:
formula - the formula describing the range (e.g. A1:F12) or a defined name.
output - the target output stream to which to write the formatted file.
Throws:
F1Exception - if an invalid argument (or no argument) is entered in the formula parameter or if any parameter is invalid.
See Also:
write(String formula, java.io.InputStream styleSheet, java.io.OutputStream output)

write

public void write(java.lang.String[] formulas,
                  java.io.OutputStream output)
           throws F1Exception
Writes the given ranges from a worksheet to an output stream as XML data. This method creates XML with no XSLT formatting.
Parameters:
formulas - a formula describing any number of source ranges (e.g. A1:F12;H1:M12;A14:M25).
output - the target output stream to which to write the formatted file.
Throws:
F1Exception - if an invalid argument (or no argument) is entered in the formula parameter or if any parameter is invalid.
See Also:
write(String[] formulas, java.io.InputStream styleSheet, java.io.OutputStream output)

write

public void write(java.lang.String formula,
                  java.io.InputStream styleSheet,
                  java.io.OutputStream output)
           throws F1Exception
Writes the given range from a worksheet to an output stream and processes the XML output with a user-supplied XSLT document.
Parameters:
formula - the formula describing the range (e.g. A1:F12).
styleSheet - the XSLT stylesheet used to format the XML data.
output - the target output stream to which to write the formatted file.
Throws:
F1Exception - if an invalid argument (or no argument) is entered in the formula parameter or if any parameter is invalid.
See Also:
write(String[] formulas, java.io.InputStream styleSheet, java.io.OutputStream output)

write

public void write(java.lang.String[] formulas,
                  java.io.InputStream styleSheet,
                  java.io.OutputStream output)
           throws F1Exception
Writes the given ranges from a worksheet to an output stream and processes the XML output with a user-supplied XSLT document.
Parameters:
formulas - a formula describing any number of source ranges (e.g. A1:F12;H1:M12;A14:M25).
styleSheet - the XSLT stylesheet used to format the XML data.
output - the target output stream to which to write the formatted file.
Throws:
F1Exception - if no argument or an invalid argument is entered in the formula parameter or another parameter is invalid.
See Also:
write(String formula, java.io.InputStream styleSheet, java.io.OutputStream output)