[seam-commits] Seam SVN: r8930 - in trunk: examples/excel/src/org/jboss/seam/excel and 11 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Sep 10 16:41:18 EDT 2008


Author: nickarls
Date: 2008-09-10 16:41:17 -0400 (Wed, 10 Sep 2008)
New Revision: 8930

Added:
   trunk/src/excel/org/jboss/seam/excel/css/
   trunk/src/excel/org/jboss/seam/excel/css/CSSNames.java
   trunk/src/excel/org/jboss/seam/excel/css/CellStyle.java
   trunk/src/excel/org/jboss/seam/excel/css/ColumnStyle.java
   trunk/src/excel/org/jboss/seam/excel/css/Parser.java
   trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilder.java
   trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilders.java
   trunk/src/excel/org/jboss/seam/excel/css/StyleMap.java
   trunk/src/excel/org/jboss/seam/excel/jxl/CellInfo.java
   trunk/src/excel/org/jboss/seam/excel/jxl/CellInfoCache.java
   trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java
   trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java
   trunk/src/excel/org/jboss/seam/excel/ui/UICellBase.java
   trunk/src/excel/org/jboss/seam/excel/ui/UILink.java
   trunk/src/excel/org/jboss/seam/excel/ui/command/
   trunk/src/excel/org/jboss/seam/excel/ui/command/Command.java
   trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupColumns.java
   trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupRows.java
   trunk/src/excel/org/jboss/seam/excel/ui/command/UIMergeCells.java
   trunk/src/excel/org/jboss/seam/excel/ui/command/UIRowPageBreak.java
   trunk/src/excel/org/jboss/seam/excel/ui/validation/
   trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidation.java
   trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidationItem.java
   trunk/src/excel/org/jboss/seam/excel/ui/validation/UINumericValidation.java
   trunk/src/excel/org/jboss/seam/excel/ui/validation/UIRangeValidation.java
   trunk/src/excel/org/jboss/seam/excel/ui/validation/Validation.java
Removed:
   trunk/src/excel/org/jboss/seam/excel/Command.java
   trunk/src/excel/org/jboss/seam/excel/Template.java
   trunk/src/excel/org/jboss/seam/excel/Validation.java
   trunk/src/excel/org/jboss/seam/excel/exporter/StyleParser.java
   trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelFactory.java
   trunk/src/excel/org/jboss/seam/excel/jxl/JXLTemplates.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIBackground.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIBorder.java
   trunk/src/excel/org/jboss/seam/excel/ui/UICellFormat.java
   trunk/src/excel/org/jboss/seam/excel/ui/UICellTemplate.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIExcelExport.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIFont.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIGroupColumns.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIGroupRows.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIListValidation.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIListValidationItem.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIMergeCells.java
   trunk/src/excel/org/jboss/seam/excel/ui/UINumericValidation.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIRangeValidation.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIRowPageBreak.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetSettings.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetTemplate.java
   trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelCellFactoryTest.java
   trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelWorkbookTest.java
Modified:
   trunk/doc/Seam_Reference_Guide/en-US/Excel.xml
   trunk/examples/excel/src/org/jboss/seam/excel/ExcelTest.java
   trunk/examples/excel/view/home.xhtml
   trunk/src/excel/META-INF/faces-config.xml
   trunk/src/excel/META-INF/seam-excel.taglib.xml
   trunk/src/excel/org/jboss/seam/excel/ExcelWorkbook.java
   trunk/src/excel/org/jboss/seam/excel/csv/CsvExcelWorkbook.java
   trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
   trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelWorkbook.java
   trunk/src/excel/org/jboss/seam/excel/ui/ExcelComponent.java
   trunk/src/excel/org/jboss/seam/excel/ui/UICell.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIColumn.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIHyperlink.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheet.java
   trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/testng.xml
Log:
JBSEAM-3231. Major rewrite of the templating system for Excel

* Dropped worksheet templates (merged into worksheet)
* Dropped Cell templates, UIFont, UIBorder, UIBackground in favor of CSS
* Added CSS with shorthand to xhtml and datatable exporter
* Added e:link for xhtml stylesheet reference
* UI tag subpackages for commands and validations
* Updated docs
* Dropped concept UIExport tag (not used)
* Dropped unit tests. Will be rewritten.
* Minor code cleanups/refactoring

NOTE! Examples still broken. Daaaanieeeelll....

Modified: trunk/doc/Seam_Reference_Guide/en-US/Excel.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Excel.xml	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/doc/Seam_Reference_Guide/en-US/Excel.xml	2008-09-10 20:41:17 UTC (rev 8930)
@@ -126,8 +126,7 @@
    <section id="excel.workbook">
       <title>Workbooks</title>
       <para>
-         Workbooks are the top-level parents of worksheets, cell templates and
-         worksheet templates.
+         Workbooks are the top-level parents of worksheets and stylesheet links.
       </para>
       <informaltable>
          <tgroup cols="2">
@@ -340,22 +339,14 @@
                      <itemizedlist>
                         <listitem>
                            <para>
-                              <literal>&lt;e:cellTemplate/&gt;</literal>
-                              &#8212;Zero or more cell templates (see
-                              <xref linkend="excel.templates.cell" />
+                              <literal>&lt;e:link/&gt;</literal>
+                              &#8212;Zero or more stylesheet links (see
+                              <xref linkend="excel.fontsandlayout.link" />
                               ).
                            </para>
                         </listitem>
                         <listitem>
                            <para>
-                              <literal>&lt;e:worksheetTemplate/&gt;</literal>
-                              &#8212;Zero or more worksheet templates (see
-                              <xref linkend="excel.templates.worksheetsettings" />
-                              ).
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
                               <literal>&lt;e:worksheet/&gt;</literal>
                               &#8212;Zero or more worksheets (see
                               <xref linkend="excel.worksheet" />
@@ -465,16 +456,6 @@
                         </listitem>
                         <listitem>
                            <para>
-                              <literal>templates</literal>
-                              &#8212;The comma-separated list of
-                              <literal>worksheetTemplates</literal>
-                              to cascade on. The value is a string (see
-                              <xref linkend="excel.templates.cell" />
-                              ).
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
                               <literal>automaticFormulaCalculation</literal>
                               &#8212;Should formulas be automatically
                               calculated? The value is a boolean.
@@ -825,7 +806,8 @@
       <para>
          Columns are the children of worksheets and the parents of cells,
          images, formulas and hyperlinks. They are the structure that control
-         the iteration of the worksheet data.
+         the iteration of the worksheet data. See <xref linkend="excel.fontsandlayout.columnsettings"/>
+         for formatting.
       </para>
       <informaltable>
          <tgroup cols="2">
@@ -845,25 +827,9 @@
                      <itemizedlist>
                         <listitem>
                            <para>
-                              <literal>autoSize</literal>
-                              &#8212;Should the column be autosized? The value
-                              is a boolean.
+                              <literal>none</literal>
                            </para>
                         </listitem>
-                        <listitem>
-                           <para>
-                              <literal>hidden</literal>
-                              &#8212;Should the column be hidden? The value is a
-                              boolean.
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
-                              <literal>width</literal>
-                              &#8212;The width of the column. The valus ia
-                              number (characters multiplied by 256)
-                           </para>
-                        </listitem>
                      </itemizedlist>
                      <para>
                         <emphasis>Child elemenents</emphasis>
@@ -964,8 +930,8 @@
          (for direct placement using the <literal>column</literal> and
          <literal>row</literal> attributes) and are responsible for outputting 
          the value (usually though en EL-expression involving the
-         <literal>var</literal>-attribute of the datatable. They can contain 
-         fonts and other formattings and can also use pre-defined templates.
+         <literal>var</literal>-attribute of the datatable. See 
+         <xref linkend="excel.fontsandlayout.cells"/>
       </para>
       <informaltable>
          <tgroup cols="2">
@@ -1009,16 +975,6 @@
                         </listitem>
                         <listitem>
                            <para>
-                              <literal>templates</literal>
-                              &#8212;A comma-separated list of cascading,
-                              predefined templates to apply before the own
-                              formattings (see
-                              <xref linkend="excel.templates.cell" />
-                              ).
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
                               <literal>forceType</literal>
                               &#8212;The forced type of the cell data. The value
                               is a string that can be one of "general",
@@ -1029,14 +985,6 @@
                         </listitem>
                         <listitem>
                            <para>
-                              <literal>alignment</literal>
-                              &#8212;The alignment of the cell data. The value
-                              is a string that can be one of "centre", "fill",
-                              "general", "justify", "left" or "right".
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
                               <literal>comment</literal>
                               &#8212;A comment to add to the cell. The value is
                               a string.
@@ -1056,62 +1004,6 @@
                               number (in pixels).
                            </para>
                         </listitem>
-                        <listitem>
-                           <para>
-                              <literal>indentation</literal>
-                              &#8212;The indentation of the cell. The value is a
-                              number (in pixels)
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
-                              <literal>locked</literal>
-                              &#8212;Should the cell be locked? For this to have
-                              any effect, the sheet containing cells with this
-                              format must also be locked. The value is a
-                              boolean.
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
-                              <literal>mask</literal>
-                              &#8212;A format mask (see
-                              <xref linkend="excel.cells.formatmasks" />
-                              ).
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
-                              <literal>orientation</literal>
-                              &#8212;The orientation of the cell data. The value
-                              is a string that can be one of "horizontal",
-                              "minus_45", "minus_90", "plus_45", "plus_90",
-                              "stacked" or "vertical".
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
-                              <literal>shrinkToFit</literal>
-                              &#8212;Should the cell data be shrunk to fit? The
-                              value is a boolean.
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
-                              <literal>verticalAlignment</literal>
-                              &#8212;The vertical aligment of the cell data. The
-                              value is a string that can be one of "bottom",
-                              "centre", "justify" or "top").
-                           </para>
-                        </listitem>
-                        <listitem>
-                           <para>
-                              <literal>wrap</literal>
-                              &#8212;Should the data be wrapped so that it fits
-                              within the cell boundaries? The value is a
-                              boolean.
-                           </para>
-                        </listitem>
                      </itemizedlist>
 
                      <para>
@@ -1181,323 +1073,6 @@
          ]]>
       </programlisting>
       <para>defines a column with a header and an iterated output</para>
-      <section id="excel.cells.fonts">
-         <title>Fonts</title>
-         <para>
-            Fonts are nested inside cells, formulas, hyperlinks or cell
-            templates. They determine the typeface of the cell data
-         </para>
-         <informaltable>
-            <tgroup cols="2">
-               <colspec colnum="1" colwidth="1*" />
-               <colspec colnum="2" colwidth="3*" />
-               <tbody>
-                  <row>
-                     <entry valign="top">
-                        <para>
-                           <literal>&lt;e:font&gt;</literal>
-                        </para>
-                     </entry>
-                     <entry valign="top">
-                        <para>
-                           <emphasis>Attributes</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>fontName</literal>
-                                 &#8212;The font name. The value is a string.
-                                 Should be used with care, since the used font
-                                 must be recognized by the
-                                 <trademark class="registered">
-                                    Microsoft
-                                 </trademark>
-                                 <trademark class="registered">Excel</trademark>
-                                 spreadsheet application
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>color</literal>
-                                 &#8212;The color of the background. The value
-                                 is a string that can be one of "blue", "red"
-                                 etc (see
-                                 <ulink
-                                    url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                                    jxl.format.Colour
-                                 </ulink>
-                                 ).
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>pointSize</literal>
-                                 &#8212;The point size of the font. The value is
-                                 a number.
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>bold</literal>
-                                 &#8212;Should the font be bold? The value is a
-                                 boolean.
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>italic</literal>
-                                 &#8212;Should the font be italic? The value is
-                                 a boolean.
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>struckOut</literal>
-                                 &#8212;Should the font be struck out? The value
-                                 is a boolean.
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>scriptStyle</literal>
-                                 &#8212;The script style of the font. The value
-                                 is a string that can be one of "normal_script",
-                                 "subscript" or "superscript".
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>underlineStyle</literal>
-                                 &#8212;The underline style of the font. The
-                                 value is a string that can be one of "double",
-                                 "double_accounting", "no_underline", "single"
-                                 or "single_accounting".
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                        <para>
-                           <emphasis>Child elemenents</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>none</literal>
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                        <para>
-                           <emphasis>Facets</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>none</literal>
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                     </entry>
-                  </row>
-               </tbody>
-            </tgroup>
-         </informaltable>
-         <programlisting role="XML">
-            <![CDATA[
-            <e:workbook>
-               <e:worksheet>
-                  <e:column value="#{personList}" var="person">               
-	                 <e:cell value="#{person.age">
-                        <e:font fontName="Times New Roman" color="red" bold="true"/>
-                     </e:cell>
-                  </e:column>
-               </e:worksheet>
-            </e:workbook>         
-         ]]>
-         </programlisting>
-         <para>defines a cell with a red, bold, Times New Roman font.</para>
-      </section>
-      <section id="excel.cells.backgrounds">
-         <title>Backgrounds</title>
-         <para>
-            Backgrounds are nested inside cells, formulas, hyperlinks or cell
-            templates. They determine the color and pattern of the cell.
-         </para>
-         <informaltable>
-            <tgroup cols="2">
-               <colspec colnum="1" colwidth="1*" />
-               <colspec colnum="2" colwidth="3*" />
-               <tbody>
-                  <row>
-                     <entry valign="top">
-                        <para>
-                           <literal>&lt;e:background&gt;</literal>
-                        </para>
-                     </entry>
-                     <entry valign="top">
-                        <para>
-                           <emphasis>Attributes</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>pattern</literal>
-                                 &#8212;The pattern of the background. The value
-                                 is a string that can be one of "solid",
-                                 "gray_25" etc (see
-                                 <ulink
-                                    url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Pattern.html">
-                                    jxl.format.Pattern
-                                 </ulink>
-                                 ). The default is "solid".
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>color</literal>
-                                 &#8212;The color of the background. The value
-                                 is a string that can be one of "blue", "red"
-                                 etc
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                        <para>
-                           <emphasis>Child elemenents</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>none</literal>
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                        <para>
-                           <emphasis>Facets</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>none</literal>
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                     </entry>
-                  </row>
-               </tbody>
-            </tgroup>
-         </informaltable>
-         <programlisting role="XML">
-            <![CDATA[
-               <e:workbook>
-                  <e:worksheet>
-                     <e:column value="#{personList}" var="person">            
-                        <e:cell value="#{person.age">
-                           <e:background color="green" pattern="gray_25"/>
-                        </e:cell>
-                     </e:column>
-                  </e:worksheet>
-               </e:workbook>   
-         ]]>
-         </programlisting>
-         <para>defined a green cell background with a 25% gray mask.</para>
-      </section>
-      <section id="excel.cells.borders">
-         <title>Borders</title>
-         <para>
-            Borders are nested inside cells, formulas, hyperlinks and cell
-            templates. They determine the color and line style of the cell
-            borders.
-         </para>
-         <informaltable>
-            <tgroup cols="2">
-               <colspec colnum="1" colwidth="1*" />
-               <colspec colnum="2" colwidth="3*" />
-               <tbody>
-                  <row>
-                     <entry valign="top">
-                        <para>
-                           <literal>&lt;e:border&gt;</literal>
-                        </para>
-                     </entry>
-                     <entry valign="top">
-                        <para>
-                           <emphasis>Attributes</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>border</literal>
-                                 &#8212;The border to apply the settings to. The
-                                 value is a string that can be one of "all",
-                                 "bottom", "left", "none", "right" or "top". The
-                                 default is "all".
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>lineStyle</literal>
-                                 &#8212;The border line style. The value is a
-                                 string that can be one of "medium", "thin" etc
-                                 (see
-                                 <ulink
-                                    url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/BorderLineStyler.html">
-                                    jxl.format.BorderLineStyle
-                                 </ulink>
-                                 ).
-                              </para>
-                           </listitem>
-                           <listitem>
-                              <para>
-                                 <literal>color</literal>
-                                 &#8212;The color of the border. The value is a
-                                 string that can be one of "blue", "red" etc
-                                 (see
-                                 <ulink
-                                    url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                                    jxl.format.Colour
-                                 </ulink>
-                                 ).
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                        <para>
-                           <emphasis>Child elemenents</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>none</literal>
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                        <para>
-                           <emphasis>Facets</emphasis>
-                        </para>
-                        <itemizedlist>
-                           <listitem>
-                              <para>
-                                 <literal>none</literal>
-                              </para>
-                           </listitem>
-                        </itemizedlist>
-                     </entry>
-                  </row>
-               </tbody>
-            </tgroup>
-         </informaltable>
-         <programlisting role="XML">
-            <![CDATA[
-               <e:workbook>
-                  <e:worksheet>
-                     <e:column value="#{personList}" var="person">                   
-                        <e:cell value="#{person.age">
-                           <e:border border="left" color="green" lineStyle="thin"/>
-                        </e:cell>
-                     </e:column>
-                  </e:worksheet>
-               </e:workbook>
-            ]]>
-         </programlisting>
-         <para>defined a thin green border on the left edge of the cell.</para>
-      </section>
       <section id="excel.cells.validation">
          <title>Validation</title>
          <para>
@@ -2816,113 +2391,6 @@
          <para>merges the cells in the range A1:J10</para>
       </section>
    </section>
-   <section id="excel.templates">
-      <title>Templates</title>
-      <para>
-         Templates are a way of grouping common formatting under a name to be
-         used later. They come in two flavors, cell level and worksheet settings
-         level and they can be cascaded so that the end result is a union of the
-         applied templates (overriden where applicable)
-      </para>
-      <section id="excel.templates.cell">
-         <title>Cell templates</title>
-         <para>
-            Cell templates are defined on workbook level using the following
-            notation
-         </para>
-         <programlisting role="XML">
-            <![CDATA[
-               <e:workbook>
-                  <e:cellTemplate name="foo">
-                     <font color="red"/>
-                  </e:cellTemplate>
-               </e:workbook>         
-             ]]>
-         </programlisting>
-         <para>
-            and are later used by referencing them in the templates attribute of
-            a cell
-         </para>
-         <programlisting role="XML">
-            <![CDATA[
-               <e:workbook>
-                  <e:worksheet>            
-                     <e:cell templates="foo" column="0" row="0" value="ping"/>
-                  </e:worksheet>
-               </e:workbook>         
-             ]]>
-         </programlisting>
-         <para>
-            Cell templates have the same attributes as cells (see
-            <xref linkend="excel.cells" />
-            ). Note that the cellTemplate can also contain tags for font, border
-            and background definitions and they are merged with the definitions
-            of the cell using the templates so a more complex definition could
-            look like
-         </para>
-         <programlisting role="XML">
-            <![CDATA[
-               <e:workbook>
-                  <e:cellTemplate name="foo" alignment="right">
-                     <e:font name="Times New Roman"/>
-                     <e:background color="blue"/>
-                  </e:cellTemplate>         
-
-                  <e:cellTemplate name="bar" wrap="true">
-                     <e:font color="red"/>
-                     <e:border color="yellow" lineStyle="thick"/>
-                  </e:cellTemplate>
-               </e:workbook>            
-         ]]>
-         </programlisting>
-         <para>so that a cell that later on applies the templates</para>
-         <programlisting role="XML">
-            <![CDATA[
-               <e:workbook>
-                  <e:worksheet>             
-                     <e:cell templates="foo,bar" column="0" row="0" value="ping">
-                        <e:border border="left" color="green" lineStyle="thin"/>
-                     </e:cell>
-                  </e:worksheet>
-               </e:workbook>      
-         ]]>
-         </programlisting>
-         <para>
-            end up with a red Times New Roman font in a right-aligned, wrapping
-            cell that has a solid blue background and thick yellow borders, with
-            exception of the left border, which is thin and green.
-         </para>
-      </section>
-      <section id="excel.templates.worksheetsettings">
-         <title>Worksheet setting templates</title>
-         <para>
-            Worksheet settings are defined and used in the same way as cell
-            templates. On workbook level, you can place a
-         </para>
-         <programlisting role="XML">
-            <![CDATA[
-               <e:workbook>
-                  <e:worksheetTemplate name="foo" horizontalFreeze="5"/>
-               </e:workbook>      
-            ]]>
-         </programlisting>
-         <para>and when you later use it like</para>
-         <programlisting role="XML">
-            <![CDATA[
-               <e:workbook>            
-                  <e:worksheet templates="foo" verticalFreeze="5"/>
-               </e:workbook>      
-            ]]>
-         </programlisting>
-         <para>
-            you end up with a worksheet that is frozen at column 5 and row 5.
-            Note that a worksheetTemplate is essentially a named worksheet (see
-            <xref linkend="excel.worksheet" />
-            ).
-         </para>
-
-      </section>
-   </section>
    <section id="excel.datatableexporter">
       <title>Datatable exporter</title>
       <para>
@@ -2962,32 +2430,93 @@
          for a dedicated export tag that can be placed inside the datatable tag
          so you won't have to refer to the datatable by ID.
       </para>
-      <section id="excel.datatableexporter.css">
-         <title>CSS</title>
+      <para>
+         See <xref linkend="excel.fontsandlayout"/> for formatting.
+      </para>
+   </section>
+   <section id="excel.fontsandlayout">
+      <title>Fonts and layout</title>
+      <para>
+         Controlling how the output look is done with a combination of CSSish
+         style attributes and tag attributes. The most common ones (fonts, borders,
+         backgrounds etc) are CSS and some more general settings are in tag attributes. 
+      </para>
+      <para>
+         The CSS attributes cascade down from parent to children and within one tag
+         cascades over the CSS classes referenced in the <literal>styleClass</literal>
+         attributes and finally over the CSS attributes defined in the 
+         <literal>style</literal>attribute. You can place them pretty much anywhere but
+         e.g. placing a column width setting in a cell nested within that column makes
+         little sense.
+      </para>
+      <section id="excel.fontsandlayout.link">
+         <title>Stylesheet links</title>
          <para>
-            In order to provide formatting for the spreadsheet, you can utilize
-            a number of xls-prefixed CSS:ish attributes that are placed in the
-            style-attribute of the datatable to be exported:
+            External stylesheets are references with the e:link tag. They are placed as
+            children of the workbook.
          </para>
+         <informaltable>
+            <tgroup cols="2">
+               <colspec colnum="1" colwidth="1*" />
+               <colspec colnum="2" colwidth="3*" />
+               <tbody>
+                  <row>
+                     <entry valign="top">
+                        <para>
+                           <literal>&lt;e:link&gt;</literal>
+                        </para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           <emphasis>Attributes</emphasis>
+                        </para>
+                        <itemizedlist>
+                           <listitem>
+                              <para>
+                                 <literal>URL</literal>
+                                 &#8212;The URL to the stylesheet
+                              </para>
+                           </listitem>
+                        </itemizedlist>
+                        <para>
+                           <emphasis>Child elemenents</emphasis>
+                        </para>
+                        <itemizedlist>
+                           <listitem>
+                              <para>
+                                 <literal>none</literal>
+                              </para>
+                           </listitem>
+                        </itemizedlist>
+                        <para>
+                           <emphasis>Facets</emphasis>
+                        </para>
+                        <itemizedlist>
+                           <listitem>
+                              <para>
+                                 <literal>none</literal>
+                              </para>
+                           </listitem>
+                        </itemizedlist>
+                     </entry>
+                  </row>
+               </tbody>
+            </tgroup>
+         </informaltable>
          <programlisting role="XML">
             <![CDATA[
-               <h:form id="theForm">
-                  <h:dataTable
-                     id="theDataTable"    
-                     value="#{personList.personList}" 
-                     var="person"
-                     style="xlsFontName : Times New Roman; xlsBackgroundColor : red">
-                     ...
-                  </h:dataTable>
-               </h:form>
+               <e:workbook>
+                  <e:link URL="/css/excel.css"/>
+               </e:workbook>           
             ]]>
          </programlisting>
+         <para>References a stylesheet that can be found at /css/excel.css</para>
+      </section>
+      
+      <section id="excel.fontsandlayout.fonts">
+         <title>Fonts</title>
          <para>
-            which sets Times New Roman as the font and red as the cell
-            background. Just as in CSS, separate name and value with a
-            <literal>:</literal> and multiple attributes with a
-            <literal>;</literal>. Below is a list of the supported 
-            style-attributes:
+            This group of XLS-CSS attributes define a font and its attributes
          </para>
          <informaltable>
             <tgroup cols="2">
@@ -2996,23 +2525,26 @@
                <tbody>
                   <row>
                      <entry valign="top">
-                        <para>xlsFontName</para>
+                        <para>xls-font-family</para>
                      </entry>
                      <entry valign="top">
-                        <para>The name of the font</para>
+                        <para>
+                           The name of the font. Make sure that it's one that is
+                           supported by your system. 
+                        </para>
                      </entry>
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsFontSize</para>
+                        <para>xls-font-size</para>
                      </entry>
                      <entry valign="top">
-                        <para>The font size</para>
+                        <para>The font size. Use a plain number</para>
                      </entry>
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsFontColor</para>
+                        <para>xls-font-color</para>
                      </entry>
                      <entry valign="top">
                         <para>
@@ -3027,7 +2559,7 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsFontBold</para>
+                        <para>xls-font-bold</para>
                      </entry>
                      <entry valign="top">
                         <para>
@@ -3038,7 +2570,7 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsFontItalic</para>
+                        <para>xls-font-italic</para>
                      </entry>
                      <entry valign="top">
                         <para>
@@ -3049,7 +2581,7 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsFontScriptStyle</para>
+                        <para>xls-font-script-style</para>
                      </entry>
                      <entry valign="top">
                         <para>
@@ -3064,10 +2596,25 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsFontStruckOut</para>
+                        <para>xls-font-underline-style</para>
                      </entry>
                      <entry valign="top">
                         <para>
+                           The underline style of the font (see
+                           <ulink
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/UnderlineStyle.html">
+                              jxl.format.UnderlineStyle
+                           </ulink>
+                           ).
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-font-struck-out</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
                            Should the font be struck out? Valid values are
                            "true" and "false"
                         </para>
@@ -3075,26 +2622,42 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsFontUnderlineStyle</para>
+                        <para>xls-font</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The underline style of the font (see
-                           <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/UnderlineStyle.html">
-                              jxl.format.UnderlineStyle
-                           </ulink>
-                           ).
+                          A shorthand notation for setting all the values. Place
+                          the font name last and use tick marks for fonts with
+                          spaces in them, e.g. 'Times New Roman'. Use "italic", "bold" 
+                          and "struckout". 
                         </para>
+                        <para>
+                          Example style="xls-font: red bold italic 22 Verdana"
+                        </para>
                      </entry>
                   </row>
+               </tbody>
+            </tgroup>
+         </informaltable>
+      </section>
+      <section id="excel.fontsandlayout.borders">
+         <title>Borders</title>
+         <para>
+            This group of XLS-CSS attributes define the borders of the cell
+         </para>
+         <informaltable>
+            <tgroup cols="2">
+               <colspec colnum="1" colwidth="1*" />
+               <colspec colnum="2" colwidth="3*" />
+               <tbody>
                   <row>
                      <entry valign="top">
-                        <para>xlsBackgroundColor</para>
+                        <para>xls-border-left-color</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The background color of the cell (see
+                           The border color of the left edge of the cell
+                           (see
                            <ulink
                               url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
                               jxl.format.Colour
@@ -3105,14 +2668,14 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBackgroundPattern</para>
+                        <para>xls-border-left-line-style</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The background pattern of the cell (see
+                           The border line style of the left edge of the cell (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Pattern.html">
-                              jxl.format.Pattern
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+                              jxl.format.LineStyle
                            </ulink>
                            ).
                         </para>
@@ -3120,14 +2683,26 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsAlignment</para>
+                        <para>xls-border-left</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The alignment of the cell value (see
+                           A shorthand for setting color and line style of the left edge
+                           of the cell, e.g style="xls-border-left: red thick"
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-border-top-color</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           The border color of the top edge of the cell
+                           (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Alignment.html">
-                              jxl.format.Alignment
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
+                              jxl.format.Colour
                            </ulink>
                            ).
                         </para>
@@ -3135,36 +2710,38 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsColumnWidths</para>
+                        <para>xls-border-top-line-style</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The column widths. Note that the unit is internal to
-                           &excel;, be prepared to use largeish numbers. 
-                           Separate columns with a <literal>,</literal>
-                           and use <literal>*</literal> for not setting a value.
+                           The border line style of the top edge of the cell (see
+                           <ulink
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+                              jxl.format.LineStyle
+                           </ulink>
+                           ).
                         </para>
-                        <programlisting role="XML">
-                           <![CDATA[
-                              <h:dataTable style="xlsColumnWidths : *,800">
-                                 ...
-                              </h:dataTable>
-                           ]]>
-                        </programlisting>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-border-top</para>
+                     </entry>
+                     <entry valign="top">
                         <para>
-                           leaves the width on column 1 as default, sets the
-                           width of column 2 to 800 and leaves the rest of the
-                           columns (if any) as default.
+                           A shorthand for setting color and line style of the top edge
+                           of the cell, e.g style="xls-border-left: red thick"
                         </para>
                      </entry>
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderColor</para>
+                        <para>xls-border-right-color</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border color of the entire cell (see
+                           The border color of the right edge of the cell
+                           (see
                            <ulink
                               url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
                               jxl.format.Colour
@@ -3175,15 +2752,14 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderColorLeft</para>
+                        <para>xls-border-right-line-style</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border color of the left edge of the cell
-                           (see
+                           The border line style of the right edge of the cell (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                              jxl.format.Colour
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+                              jxl.format.LineStyle
                            </ulink>
                            ).
                         </para>
@@ -3191,26 +2767,22 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderColorTop</para>
+                        <para>xls-border-right</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border color of the top edge of the cell (see
-                           <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                              jxl.format.Colour
-                           </ulink>
-                           ).
+                           A shorthand for setting color and line style of the right edge
+                           of the cell, e.g style="xls-border-right: red thick"
                         </para>
                      </entry>
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderColorRight</para>
+                        <para>xls-border-bottom-color</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border color of the right edge of the cell
+                           The border color of the bottom edge of the cell
                            (see
                            <ulink
                               url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
@@ -3222,15 +2794,14 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderColorBottom</para>
+                        <para>xls-border-bottom-line-style</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border color of the bottom edge of the cell
-                           (see
+                           The border line style of the bottom edge of the cell (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                              jxl.format.Colour
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+                              jxl.format.LineStyle
                            </ulink>
                            ).
                         </para>
@@ -3238,14 +2809,50 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderLineStyle</para>
+                        <para>xls-border-bottom</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border line style of the entire cell (see
+                           A shorthand for setting color and line style of the bottom edge
+                           of the cell, e.g style="xls-border-bottom: red thick"
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-border</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           A shorthand for setting color and line style all edges
+                           of the cell, e.g style="xls-border: red thick"
+                        </para>
+                     </entry>
+                  </row>
+               </tbody>
+            </tgroup>
+         </informaltable>         
+      </section>
+      <section id="excel.fontsandlayout.background">
+         <title>Background</title>
+         <para>
+            This group of XLS-CSS attributes define the background of the cell
+         </para>
+         <informaltable>
+            <tgroup cols="2">
+               <colspec colnum="1" colwidth="1*" />
+               <colspec colnum="2" colwidth="3*" />
+               <tbody>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-background-color</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           The color of the background (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                              jxl.format.Colour
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+                              jxl.format.LineStyle
                            </ulink>
                            ).
                         </para>
@@ -3253,15 +2860,14 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderLineStyleLeft</para>
+                        <para>xls-background-pattern</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border line style of the left edge of the
-                           cell (see
+                           The pattern of the background (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                              jxl.format.Colour
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Pattern.html">
+                              jxl.format.Pattern
                            </ulink>
                            ).
                         </para>
@@ -3269,15 +2875,99 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderLineStyleTop</para>
+                        <para>xls-background</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border line style of the top edge of the cell
-                           (see
+                           A shorthand for setting the background color and pattern. See above for rules.
+                        </para>
+                     </entry>
+                  </row>
+               </tbody>
+            </tgroup>
+         </informaltable>
+      </section>
+      <section id="excel.fontsandlayout.columnsettings">
+         <title>Column settings</title>
+         <para>
+            This group of XLS-CSS attributes define the column widths etc.
+         </para>
+         <informaltable>
+            <tgroup cols="2">
+               <colspec colnum="1" colwidth="1*" />
+               <colspec colnum="2" colwidth="3*" />
+               <tbody>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-column-width</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           The width of the column. Use largeish values (~5000) to start with.
+                           Used by the e:column in xhtml mode.
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-column-widths</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           The width of the column. Use largeish values (~5000) to start with.
+                           Used by the excel exporter, placed in the datatable style attribute.
+                           Use numerical values or * to bypass a column.
+                        </para>
+                        <para>
+                           Example style="xls-column-widths: 5000, 5000, *, 10000"
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-column-autosize</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           Should an attempt be made to autosize the column? Valid values
+                           are "true" and "false".
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-column-hidden</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           Should the column be hidden? Valid values are "true" and "false".
+                        </para>
+                     </entry>
+                  </row>
+               </tbody>
+            </tgroup>
+         </informaltable>
+      </section>
+      <section id="excel.fontsandlayout.cellsettings">
+         <title>Cell settings</title>
+         <para>
+            This group of XLS-CSS attributes define the cell properties
+         </para>
+         <informaltable>
+            <tgroup cols="2">
+               <colspec colnum="1" colwidth="1*" />
+               <colspec colnum="2" colwidth="3*" />
+               <tbody>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-alignment</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           The alignment of the cell value (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                              jxl.format.Colour
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Alignment.html">
+                              jxl.format.Alignment
                            </ulink>
                            ).
                         </para>
@@ -3285,73 +2975,136 @@
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderLineStyleRight</para>
+                        <para>xls-format-mask</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border line style of the right edge of the
-                           cell (see
+                           The format mask of the cell, see <xref linkend="excel.cells.formatmasks" />
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-indentation</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           The indentation of the cell value. The value is numeric.
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-locked</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           Should the cell be locked. Use with workbook level locked. 
+                           Valid values are "true" and "false".
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-orientation</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           The orientation of the cell value (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                              jxl.format.Colour
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Orientation.html">
+                              jxl.format.Orientation
                            </ulink>
-                           ). styles
+                           ).
                         </para>
                      </entry>
                   </row>
                   <row>
                      <entry valign="top">
-                        <para>xlsBorderLineStyleBottom</para>
+                        <para>xls-vertical-alignment</para>
                      </entry>
                      <entry valign="top">
                         <para>
-                           The the border line style of the bottom edge of the
-                           cell (see
+                           The vertical alignment of the cell value (see
                            <ulink
-                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
-                              jxl.format.Colour
+                              url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/VerticalAlignment.html">
+                              jxl.format.VerticalAlignment
                            </ulink>
-                           ). styles
+                           ).
                         </para>
                      </entry>
                   </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-shrink-to-fit</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           Should the cell values shrink to fit?
+                           Valid values are "true" and "false".
+                        </para>
+                     </entry>
+                  </row>
+                  <row>
+                     <entry valign="top">
+                        <para>xls-wrap</para>
+                     </entry>
+                     <entry valign="top">
+                        <para>
+                           Should the cell wrap with newlines?
+                           Valid values are "true" and "false".
+                        </para>
+                     </entry>
+                  </row>
                </tbody>
             </tgroup>
          </informaltable>
       </section>
-      <section id="excel.datatableexporter.templates">
-         <title>Templates</title>
+      <section id="excel.fontsandlayout.datatableexporter">
+         <title>The datatable exporter</title>
          <para>
-            In order to provide different formatting for different kind of cells
-            you can use templates. Templates are defined in the datatable style
-            attribute as seen in the examples in the previous section by using a
-            dot-notation on the xls-attribute names. Attributes without template
-            names are considered global and are applied to all cells.
+            The datatable exporter uses the same xls-css attributes as the xhtml
+            document with the exception that column widths are defined with the 
+            <literal>xls-column-widths</literal> attribute on the datatable (since
+            the UIColumn doesn't support the style or styleClass attributes).
          </para>
+      </section>
+      <section id="excel.fontsandlayout.examples">
+         <title>Layout examples</title>
          <para>
-            Templates are used by referring to them in the style attribute of
-            the UIOutput using the xlsTemplates attribute. If you wish to
-            cascade several templates, separate them with a
-            <literal>,</literal>
-            .
+            TODO
          </para>
-         <programlisting role="XML">
-            <![CDATA[
-               <h:dataTable style="xlsFontName : Times New Roman; xlsFontColor.foo : blue; 
-                  xlsFontColor.bar : red; xlsFontBold.tar : true">
-                  <h:column>
-                     <h:outputText style="xlsTemplates : foo"/>
-                  </h:column>
-                  <h:column>
-                     <h:outputText style="xlsTemplates : bar,tar"/>
-                  </h:column>
-               </h:dataTable>
-            ]]>
-         </programlisting>
+      </section>
+      <section id="excel.fontsandlayout.limitations">
+         <title>Limitations</title>
          <para>
-            results in the first column being Times New Roman, blue and the
-            second column being Times New Roman red bold.
+            In the current version there are some known limitations regarding 
+            CSS support
          </para>
+         <itemizedlist>
+            <listitem>
+               <para>
+                  When using .xhtml documents, stylesheets must be referenced
+                  through the <literal>&lt;e:link&gt; tag</literal>
+               </para>
+            </listitem>
+            <listitem>
+               <para>
+                  When using external stylesheets they must be formatted in
+                  one line per entry like
+               </para>
+               <programlisting role="XML">
+                  .header { xls-font: bold 14 Verdana }
+                  .data { xls-font: 12 'Times New Roman' }
+               </programlisting>
+            </listitem>
+            <listitem>
+               <para>
+                  When using the datatable exporter, CSS must be entered through
+                  style-attributes, external stylesheets are not supported 
+               </para>
+            </listitem>
+         </itemizedlist>
       </section>
    </section>
    <section id="excel.links">

Modified: trunk/examples/excel/src/org/jboss/seam/excel/ExcelTest.java
===================================================================
--- trunk/examples/excel/src/org/jboss/seam/excel/ExcelTest.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/examples/excel/src/org/jboss/seam/excel/ExcelTest.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -24,8 +24,8 @@
    @Create
    public void create()
    {
-      people.add(new Person("Gavin King", "Red Hat Inc.", "Project Lead"));
-      people.add(new Person("Pete Muir", "Red Hat Inc.", "Seam Core"));
+      people.add(new Person("Pete Muir", "Red Hat Inc.", "Project Lead"));
+      people.add(new Person("Gavin King", "Red Hat Inc.", "Project Founder"));
       people.add(new Person("Norman Richards", "Red Hat Inc.", "Seam Core"));
       people.add(new Person("Shane Bryzak", "Red Hat Inc.", "Seam Security, Seam Remoting"));
       people.add(new Person("Michael Yuan", "Individual", ""));
@@ -42,7 +42,6 @@
       people.add(new Person("Max Rydahl Andersen", "Red Hat Inc.", "Lead developer JBoss Tools, Hibernate Tools, Seam Tools"));
       people.add(new Person("Emmanuel Bernard", "Red Hat Inc.", "Lead developer Hibernate Annotations, EntityManager, Validator, Search"));
       repeat.add(people.subList(0, 5));
-      
    }
 
    public List<List<Person>> getRepeat()

Modified: trunk/examples/excel/view/home.xhtml
===================================================================
--- trunk/examples/excel/view/home.xhtml	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/examples/excel/view/home.xhtml	2008-09-10 20:41:17 UTC (rev 8930)
@@ -34,10 +34,11 @@
 		<a4j:outputPanel id="searchResults">
 			<rich:dataTable value="#{excelTest.result}" var="person"
 				rendered="#{!empty excelTest.result}" id="excelTable"
+				style="xls-font: red bold 22 Verdana; xls-column-widths: 8000 9000 10000"
 				columnClasses="left, right" width="500px">
 				<rich:column>
 					<f:facet name="header">
-						<h:outputText value="Name" />
+						<h:outputText value="Name" style="xls-font: italic"/>
 					</f:facet>
 					<h:outputText value="#{person.name}" />
 				</rich:column>

Modified: trunk/src/excel/META-INF/faces-config.xml
===================================================================
--- trunk/src/excel/META-INF/faces-config.xml	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/META-INF/faces-config.xml	2008-09-10 20:41:17 UTC (rev 8930)
@@ -9,18 +9,6 @@
         <component-class>org.jboss.seam.excel.ui.UIWorkbook</component-class>
     </component>
     <component>
-        <component-type>org.jboss.seam.excel.ui.UIWorksheetSettings</component-type>
-        <component-class>org.jboss.seam.excel.ui.UIWorksheetSettings</component-class>
-    </component>
-    <component>
-        <component-type>org.jboss.seam.excel.ui.UIBackground</component-type>
-        <component-class>org.jboss.seam.excel.ui.UIBackground</component-class>
-    </component>
-    <component>
-        <component-type>org.jboss.seam.excel.ui.UIBorder</component-type>
-        <component-class>org.jboss.seam.excel.ui.UIBorder</component-class>
-    </component>
-    <component>
         <component-type>org.jboss.seam.excel.ui.UICell</component-type>
         <component-class>org.jboss.seam.excel.ui.UICell</component-class>
     </component>
@@ -29,10 +17,6 @@
         <component-class>org.jboss.seam.excel.ui.UIColumn</component-class>
     </component>
     <component>
-        <component-type>org.jboss.seam.excel.ui.UIFont</component-type>
-        <component-class>org.jboss.seam.excel.ui.UIFont</component-class>
-    </component>
-    <component>
         <component-type>org.jboss.seam.excel.ui.UIWorksheet</component-type>
         <component-class>org.jboss.seam.excel.ui.UIWorksheet</component-class>
     </component>    
@@ -73,14 +57,6 @@
 		<component-class>org.jboss.seam.excel.ui.UIFormula</component-class>
 	</component>
 	<component>
-		<component-type>org.jboss.seam.excel.ui.UICellTemplate</component-type>
-		<component-class>org.jboss.seam.excel.ui.UICellTemplate</component-class>
-	</component>
-	<component>
-		<component-type>org.jboss.seam.excel.ui.UIWorksheetTemplate</component-type>
-		<component-class>org.jboss.seam.excel.ui.UIWorksheetTemplate</component-class>
-	</component>
-	<component>
 		<component-type>org.jboss.seam.excel.ui.UIGroupColumns</component-type>
 		<component-class>org.jboss.seam.excel.ui.UIGroupColumns</component-class>
 	</component>
@@ -89,24 +65,24 @@
 		<component-class>org.jboss.seam.excel.ui.UIGroupRows</component-class>
 	</component>
 	<component>
-		<component-type>org.jboss.seam.excel.ui.UIListValidation</component-type>
-		<component-class>org.jboss.seam.excel.ui.UIListValidation</component-class>
+		<component-type>org.jboss.seam.excel.ui.validation.UIListValidation</component-type>
+		<component-class>org.jboss.seam.excel.ui.validation.UIListValidation</component-class>
 	</component>
 	<component>
-		<component-type>org.jboss.seam.excel.ui.UIListValidationItem</component-type>
-		<component-class>org.jboss.seam.excel.ui.UIListValidationItem</component-class>
+		<component-type>org.jboss.seam.excel.ui.validation.UIListValidationItem</component-type>
+		<component-class>org.jboss.seam.excel.ui.validation.UIListValidationItem</component-class>
 	</component>
 	<component>
 		<component-type>org.jboss.seam.excel.ui.UIMergeCells</component-type>
 		<component-class>org.jboss.seam.excel.ui.UIMergeCells</component-class>
 	</component>
 	<component>
-		<component-type>org.jboss.seam.excel.ui.UINumericValidation</component-type>
-		<component-class>org.jboss.seam.excel.ui.UINumericValidation</component-class>
+		<component-type>org.jboss.seam.excel.ui.validation.UINumericValidation</component-type>
+		<component-class>org.jboss.seam.excel.ui.validation.UINumericValidation</component-class>
 	</component>
 	<component>
-		<component-type>org.jboss.seam.excel.ui.UIRangeValidation</component-type>
-		<component-class>org.jboss.seam.excel.ui.UIRangeValidation</component-class>
+		<component-type>org.jboss.seam.excel.ui.validation.UIRangeValidation</component-type>
+		<component-class>org.jboss.seam.excel.ui.validation.UIRangeValidation</component-class>
 	</component>
 	<component>
 		<component-type>org.jboss.seam.excel.ui.UIRowPageBreak</component-type>
@@ -116,4 +92,8 @@
 		<component-type>org.jboss.seam.excel.ui.UIExcelExport</component-type>
 		<component-class>org.jboss.seam.excel.ui.UIExcelExport</component-class>
 	</component>
+   <component>
+      <component-type>org.jboss.seam.excel.ui.UILink</component-type>
+      <component-class>org.jboss.seam.excel.ui.UILink</component-class>
+   </component>
 </faces-config>

Modified: trunk/src/excel/META-INF/seam-excel.taglib.xml
===================================================================
--- trunk/src/excel/META-INF/seam-excel.taglib.xml	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/META-INF/seam-excel.taglib.xml	2008-09-10 20:41:17 UTC (rev 8930)
@@ -21,27 +21,6 @@
     </tag> 
 
     <tag>
-        <tag-name>worksheetSettings</tag-name>
-        <component>
-            <component-type>org.jboss.seam.excel.ui.UIWorksheetSettings</component-type>
-        </component>
-    </tag>
-
-    <tag>
-        <tag-name>background</tag-name>
-        <component>
-            <component-type>org.jboss.seam.excel.ui.UIBackground</component-type>
-        </component>
-    </tag>
-
-    <tag>
-        <tag-name>border</tag-name>
-        <component>
-            <component-type>org.jboss.seam.excel.ui.UIBorder</component-type>
-        </component>
-    </tag>
-
-    <tag>
         <tag-name>cell</tag-name>
         <component>
             <component-type>org.jboss.seam.excel.ui.UICell</component-type>
@@ -56,13 +35,6 @@
     </tag>
 
     <tag>
-        <tag-name>font</tag-name>
-        <component>
-            <component-type>org.jboss.seam.excel.ui.UIFont</component-type>
-        </component>
-    </tag>
-
-    <tag>
         <tag-name>headerFooter</tag-name>
         <component>
             <component-type>org.jboss.seam.excel.ui.UIHeaderFooter</component-type>
@@ -112,79 +84,72 @@
     </tag>
 
     <tag>
-        <tag-name>formula</tag-name>
+        <tag-name>link</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UIFormula</component-type>
+            <component-type>org.jboss.seam.excel.ui.UILink</component-type>
         </component>
     </tag>
 
     <tag>
-        <tag-name>cellTemplate</tag-name>
+        <tag-name>formula</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UICellTemplate</component-type>
+            <component-type>org.jboss.seam.excel.ui.UIFormula</component-type>
         </component>
     </tag>
 
     <tag>
-        <tag-name>worksheetTemplate</tag-name>
-        <component>
-            <component-type>org.jboss.seam.excel.ui.UIWorksheetTemplate</component-type>
-        </component>
-    </tag>
-
-    <tag>
         <tag-name>groupColumns</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UIGroupColumns</component-type>
+            <component-type>org.jboss.seam.excel.ui.command.UIGroupColumns</component-type>
         </component>
     </tag>
 
     <tag>
         <tag-name>groupRows</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UIGroupRows</component-type>
+            <component-type>org.jboss.seam.excel.ui.command.UIGroupRows</component-type>
         </component>
     </tag>
 
     <tag>
         <tag-name>listValidation</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UIListValidation</component-type>
+            <component-type>org.jboss.seam.excel.ui.validation.UIListValidation</component-type>
         </component>
     </tag>
 
     <tag>
         <tag-name>listValidationItem</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UIListValidationItem</component-type>
+            <component-type>org.jboss.seam.excel.ui.validation.UIListValidationItem</component-type>
         </component>
     </tag>
     
     <tag>
         <tag-name>mergeCells</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UIMergeCells</component-type>
+            <component-type>org.jboss.seam.excel.ui.command.UIMergeCells</component-type>
         </component>
     </tag>
     
     <tag>
         <tag-name>numericValidation</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UINumericValidation</component-type>
+            <component-type>org.jboss.seam.excel.ui.validation.UINumericValidation</component-type>
         </component>
     </tag>
     
     <tag>
         <tag-name>rangeValidation</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UIRangeValidation</component-type>
+            <component-type>org.jboss.seam.excel.ui.validation.UIRangeValidation</component-type>
         </component>
     </tag>
 
     <tag>
         <tag-name>rowPageBreak</tag-name>
         <component>
-            <component-type>org.jboss.seam.excel.ui.UIRowPageBreak</component-type>
+            <component-type>org.jboss.seam.excel.ui.command.UIRowPageBreak</component-type>
         </component>
     </tag>
 

Deleted: trunk/src/excel/org/jboss/seam/excel/Command.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/Command.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/Command.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,11 +0,0 @@
-package org.jboss.seam.excel;
-
-public interface Command
-{
-   public enum CommandType
-   {
-      merge_cells, add_row_pagebreak, group_rows, group_columns
-   }
-
-   public abstract CommandType getCommandType();
-}

Modified: trunk/src/excel/org/jboss/seam/excel/ExcelWorkbook.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ExcelWorkbook.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ExcelWorkbook.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,9 +1,13 @@
 package org.jboss.seam.excel;
 
+import java.util.List;
+
 import org.jboss.seam.document.DocumentData.DocumentType;
 import org.jboss.seam.excel.ui.UIColumn;
+import org.jboss.seam.excel.ui.UILink;
 import org.jboss.seam.excel.ui.UIWorkbook;
 import org.jboss.seam.excel.ui.UIWorksheet;
+import org.jboss.seam.excel.ui.command.Command;
 
 /**
  * General interface interacting with an Excel Workbook abstraction 
@@ -67,13 +71,6 @@
    public abstract void addItem(WorksheetItem item);
 
    /**
-    * Adds a template to the template stack
-    * 
-    * @param template The template to add
-    */
-   public abstract void addTemplate(Template template);
-
-   /**
     * Executes a command for a worksheet
     * 
     * @param command The command to execute
@@ -95,4 +92,6 @@
     * @param colspan The number of columns to span
     */
    public abstract void addWorksheetFooter(WorksheetItem item, int colspan);
+
+   public abstract void setStylesheets(List<UILink> stylesheets);
 }
\ No newline at end of file

Deleted: trunk/src/excel/org/jboss/seam/excel/Template.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/Template.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/Template.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,14 +0,0 @@
-package org.jboss.seam.excel;
-
-public interface Template
-{
-   public enum TemplateType
-   {
-      cell, worksheet
-   }
-
-   public abstract TemplateType getType();
-
-   public abstract String getName();
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/Validation.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/Validation.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/Validation.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,11 +0,0 @@
-package org.jboss.seam.excel;
-
-public interface Validation
-{
-   public enum ValidationType
-   {
-      numeric, range, list
-   }
-
-   public abstract ValidationType getType();
-}

Added: trunk/src/excel/org/jboss/seam/excel/css/CSSNames.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/CSSNames.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/CSSNames.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,51 @@
+package org.jboss.seam.excel.css;
+
+public class CSSNames
+{
+   public static final String FONT_FAMILY = "xls-font-family";
+   public static final String FONT_SIZE = "xls-font-size";
+   public static final String FONT_COLOR = "xls-font-color";
+   public static final String FONT_ITALIC = "xls-font-italic";
+   public static final String FONT_SCRIPT_STYLE = "xls-font-script-style";
+   public static final String FONT_STRUCK_OUT = "xls-font-struck-out";
+   public static final String FONT_UNDERLINE_STYLE = "xls-font-underline-style";
+   public static final String FONT_BOLD = "xls-font-bold";
+   public static final String FONT = "xls-font";
+
+   public static final String BACKGROUND_PATTERN = "xls-background-pattern";
+   public static final String BACKGROUND_COLOR = "xls-background-color";
+   public static final String BACKGROUND = "xls-background";
+
+   public static final String BORDER_LEFT_COLOR = "xls-border-left-color";
+   public static final String BORDER_LEFT_LINE_STYLE = "xls-border-left-line-style";
+   public static final String BORDER_LEFT = "xls-border-left";
+
+   public static final String BORDER_TOP_COLOR = "xls-border-top-color";
+   public static final String BORDER_TOP_LINE_STYLE = "xls-border-top-line-style";
+   public static final String BORDER_TOP = "xls-border-top";
+
+   public static final String BORDER_RIGHT_COLOR = "xls-border-right-color";
+   public static final String BORDER_RIGHT_LINE_STYLE = "xls-border-right-line-style";
+   public static final String BORDER_RIGHT = "xls-border-right";
+
+   public static final String BORDER_BOTTOM_COLOR = "xls-border-bottom-color";
+   public static final String BORDER_BOTTOM_LINE_STYLE = "xls-border-bottom-line-style";
+   public static final String BORDER_BOTTOM = "xls-border-bottom";
+
+   public static final String BORDER = "xls-border";
+
+   public static final String ALIGNMENT = "xls-alignment";
+   public static final String FORMAT_MASK = "xls-format-mask";
+   public static final String INDENTATION = "xls-indentation";
+   public static final String LOCKED = "xls-locked";
+   public static final String ORIENTATION = "xls-orientation";
+   public static final String SHRINK_TO_FIT = "xls-shrink-to-fit";
+   public static final String VERICAL_ALIGNMENT = "xls-vertical-alignment";
+   public static final String WRAP = "xls-wrap";
+   
+   public static final String COLUMN_WIDTH = "xls-column-width";
+   public static final String COLUMN_WIDTHS = "xls-column-widths";
+   public static final String COLUMN_AUTO_SIZE = "xls-column-autosize";
+   public static final String COLUMN_HIDDEN = "xls-column-hidden";
+   
+}

Added: trunk/src/excel/org/jboss/seam/excel/css/CellStyle.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/CellStyle.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/CellStyle.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,94 @@
+package org.jboss.seam.excel.css;
+
+import java.util.Map;
+
+public class CellStyle
+{
+
+   public class Font
+   {
+      public String family;
+      public Integer pointSize;
+      public String color;
+      public Boolean bold;
+      public Boolean italic;
+      public String scriptStyle;
+      public String underlineStyle;
+      public Boolean struckOut;
+
+      public boolean isUsed()
+      {
+         return family != null || pointSize != null || color != null || bold != null || italic != null || 
+         scriptStyle != null || underlineStyle != null || struckOut != null;
+      }
+   }
+
+   public class Background
+   {
+      public String color;
+      public String pattern;
+
+      public boolean isUsed()
+      {
+         return color != null || pattern != null;
+      }
+   }
+
+   public class Border
+   {
+      public String color;
+      public String lineStyle;
+
+      public boolean isUsed()
+      {
+         return color != null || lineStyle != null;
+      }
+
+   }
+
+   public Font font = new Font();
+   public Background background = new Background();
+   public Border leftBorder = new Border();
+   public Border topBorder = new Border();
+   public Border bottomBorder = new Border();
+   public Border rightBorder = new Border();
+   public String alignment;
+   public Integer indentation;
+   public Boolean locked;
+   public String orientation;
+   public Boolean shrinkToFit;
+   public Boolean wrap;
+   public String verticalAlignment;
+   public String formatMask;
+
+   public CellStyle(Map<String, Object> styleMap)
+   {
+      font.family = (String) styleMap.get(CSSNames.FONT_FAMILY);
+      font.color = (String) styleMap.get(CSSNames.FONT_COLOR);
+      font.pointSize = (Integer) styleMap.get(CSSNames.FONT_SIZE);
+      font.italic = (Boolean) styleMap.get(CSSNames.FONT_ITALIC);
+      font.scriptStyle = (String) styleMap.get(CSSNames.FONT_SCRIPT_STYLE);
+      font.struckOut = (Boolean) styleMap.get(CSSNames.FONT_STRUCK_OUT);
+      font.underlineStyle = (String) styleMap.get(CSSNames.FONT_UNDERLINE_STYLE);
+      font.bold = (Boolean) styleMap.get(CSSNames.FONT_BOLD);
+      background.color = (String) styleMap.get(CSSNames.BACKGROUND_PATTERN);
+      background.pattern = (String) styleMap.get(CSSNames.BACKGROUND_COLOR);
+      leftBorder.color = (String) styleMap.get(CSSNames.BORDER_LEFT_COLOR);
+      leftBorder.lineStyle = (String) styleMap.get(CSSNames.BORDER_LEFT_LINE_STYLE);
+      topBorder.color = (String) styleMap.get(CSSNames.BORDER_TOP_COLOR);
+      topBorder.lineStyle = (String) styleMap.get(CSSNames.BORDER_TOP_LINE_STYLE);
+      rightBorder.color = (String) styleMap.get(CSSNames.BORDER_RIGHT_COLOR);
+      rightBorder.lineStyle = (String) styleMap.get(CSSNames.BORDER_RIGHT_LINE_STYLE);
+      bottomBorder.color = (String) styleMap.get(CSSNames.BORDER_BOTTOM_COLOR);
+      bottomBorder.lineStyle = (String) styleMap.get(CSSNames.BORDER_BOTTOM_LINE_STYLE);
+      alignment = (String) styleMap.get(CSSNames.ALIGNMENT);
+      indentation = (Integer) styleMap.get(CSSNames.INDENTATION);
+      locked = (Boolean) styleMap.get(CSSNames.LOCKED);
+      orientation = (String) styleMap.get(CSSNames.ORIENTATION);
+      shrinkToFit = (Boolean) styleMap.get(CSSNames.SHRINK_TO_FIT);
+      wrap = (Boolean) styleMap.get(CSSNames.WRAP);
+      verticalAlignment = (String) styleMap.get(CSSNames.VERICAL_ALIGNMENT);
+      formatMask = (String) styleMap.get(CSSNames.FORMAT_MASK);
+   }
+
+}

Added: trunk/src/excel/org/jboss/seam/excel/css/ColumnStyle.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/ColumnStyle.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/ColumnStyle.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,16 @@
+package org.jboss.seam.excel.css;
+
+import java.util.Map;
+
+public class ColumnStyle
+{
+   public Boolean autoSize;
+   public Boolean hidden;
+   public Integer width;
+   
+   public ColumnStyle(Map<String, Object> styleMap) {
+      autoSize = (Boolean) styleMap.get(CSSNames.COLUMN_AUTO_SIZE);
+      hidden = (Boolean) styleMap.get(CSSNames.COLUMN_HIDDEN);
+      width = (Integer) styleMap.get(CSSNames.COLUMN_WIDTH);
+   }
+}

Added: trunk/src/excel/org/jboss/seam/excel/css/Parser.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/Parser.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/Parser.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,248 @@
+package org.jboss.seam.excel.css;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.jboss.seam.core.Interpolator;
+import org.jboss.seam.excel.ExcelWorkbookException;
+import org.jboss.seam.excel.ui.UILink;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.log.Logging;
+
+public class Parser
+{
+   private static final String STYLE_ATTRIBUTE = "style";
+   private static final String STYLE_CLASS_ATTRIBUTE = "styleClass";
+   private static final String STYLES_SEPARATOR = ";";
+   private static final String STYLE_NAME_VALUE_SEPARATOR = ":";
+   private static final String STYLE_SHORTHAND_SEPARATOR = " ";
+
+   private Map<String, StyleMap> definedStyleClasses = new HashMap<String, StyleMap>();
+   private Map<String, PropertyBuilder> propertyBuilders = new HashMap<String, PropertyBuilder>();
+   private Map<UIComponent, StyleMap> cellStyleCache = new HashMap<UIComponent, StyleMap>();
+
+   private Log log = Logging.getLog(Parser.class);
+
+   public Parser()
+   {
+      initPropertyBuilders();
+   }
+
+   public Parser(List<UILink> stylesheets) throws MalformedURLException, IOException
+   {
+      initPropertyBuilders();
+      loadStylesheets(stylesheets);
+   }
+
+   private void loadStylesheets(List<UILink> stylesheets) throws MalformedURLException, IOException
+   {
+      for (UILink stylesheet : stylesheets)
+      {
+         definedStyleClasses.putAll(parseStylesheet(stylesheet.getURL()));
+      }
+   }
+
+   private void initPropertyBuilders()
+   {
+      propertyBuilders.put(CSSNames.FONT_FAMILY, new PropertyBuilders.FontFamily());
+      propertyBuilders.put(CSSNames.FONT_SIZE, new PropertyBuilders.FontSize());
+      propertyBuilders.put(CSSNames.FONT_COLOR, new PropertyBuilders.FontColor());
+      propertyBuilders.put(CSSNames.FONT_ITALIC, new PropertyBuilders.FontItalic());
+      propertyBuilders.put(CSSNames.FONT_SCRIPT_STYLE, new PropertyBuilders.FontScriptStyle());
+      propertyBuilders.put(CSSNames.FONT_STRUCK_OUT, new PropertyBuilders.FontStruckOut());
+      propertyBuilders.put(CSSNames.FONT_UNDERLINE_STYLE, new PropertyBuilders.FontUnderlineStyle());
+      propertyBuilders.put(CSSNames.FONT_BOLD, new PropertyBuilders.FontBold());
+      propertyBuilders.put(CSSNames.FONT, new PropertyBuilders.FontShorthand());
+      propertyBuilders.put(CSSNames.BACKGROUND_PATTERN, new PropertyBuilders.BackgroundPattern());
+      propertyBuilders.put(CSSNames.BACKGROUND_COLOR, new PropertyBuilders.BackgroundColor());
+      propertyBuilders.put(CSSNames.BACKGROUND, new PropertyBuilders.BackgroundShorthand());
+      propertyBuilders.put(CSSNames.BORDER_LEFT_COLOR, new PropertyBuilders.BorderLeftColor());
+      propertyBuilders.put(CSSNames.BORDER_LEFT_LINE_STYLE, new PropertyBuilders.BorderLeftLineStyle());
+      propertyBuilders.put(CSSNames.BORDER_LEFT, new PropertyBuilders.BorderLeftShorthand());
+      propertyBuilders.put(CSSNames.BORDER_TOP_COLOR, new PropertyBuilders.BorderTopColor());
+      propertyBuilders.put(CSSNames.BORDER_TOP_LINE_STYLE, new PropertyBuilders.BorderTopLineStyle());
+      propertyBuilders.put(CSSNames.BORDER_TOP, new PropertyBuilders.BorderTopShorthand());
+      propertyBuilders.put(CSSNames.BORDER_RIGHT_COLOR, new PropertyBuilders.BorderRightColor());
+      propertyBuilders.put(CSSNames.BORDER_RIGHT_LINE_STYLE, new PropertyBuilders.BorderRightLineStyle());
+      propertyBuilders.put(CSSNames.BORDER_RIGHT, new PropertyBuilders.BorderRightShorthand());
+      propertyBuilders.put(CSSNames.BORDER_BOTTOM_COLOR, new PropertyBuilders.BorderBottomColor());
+      propertyBuilders.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, new PropertyBuilders.BorderBottomLineStyle());
+      propertyBuilders.put(CSSNames.BORDER_BOTTOM, new PropertyBuilders.BorderBottomShorthand());
+      propertyBuilders.put(CSSNames.BORDER, new PropertyBuilders.BorderShorthand());
+      propertyBuilders.put(CSSNames.FORMAT_MASK, new PropertyBuilders.FormatMask());
+      propertyBuilders.put(CSSNames.ALIGNMENT, new PropertyBuilders.Alignment());
+      propertyBuilders.put(CSSNames.INDENTATION, new PropertyBuilders.Indentation());
+      propertyBuilders.put(CSSNames.ORIENTATION, new PropertyBuilders.Orientation());
+      propertyBuilders.put(CSSNames.LOCKED, new PropertyBuilders.Locked());
+      propertyBuilders.put(CSSNames.SHRINK_TO_FIT, new PropertyBuilders.ShrinkToFit());
+      propertyBuilders.put(CSSNames.WRAP, new PropertyBuilders.Wrap());
+      propertyBuilders.put(CSSNames.VERICAL_ALIGNMENT, new PropertyBuilders.VericalAlignment());
+      propertyBuilders.put(CSSNames.COLUMN_WIDTH, new PropertyBuilders.ColumnWidth());
+      propertyBuilders.put(CSSNames.COLUMN_AUTO_SIZE, new PropertyBuilders.ColumnAutoSize());
+      propertyBuilders.put(CSSNames.COLUMN_HIDDEN, new PropertyBuilders.ColumnHidden());
+      propertyBuilders.put(CSSNames.COLUMN_WIDTHS, new PropertyBuilders.ColumnWidths());
+   }
+
+   private Map<String, StyleMap> parseStylesheet(String URL) throws MalformedURLException, IOException
+   {
+      Map<String, StyleMap> styleClasses = new HashMap<String, StyleMap>();
+      BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(URL).openStream()));
+      String line;
+      while ((line = reader.readLine()) != null)
+      {
+         String[] spaceParts = line.split(" ");
+         String name = spaceParts[0];
+         if (name.startsWith("."))
+         {
+            name = name.substring(1);
+         }
+         int startbrace = line.indexOf("{");
+         int stopbrace = line.indexOf("}");
+         if (startbrace < 0 || stopbrace < 0)
+         {
+            String message = Interpolator.instance().interpolate("Could not find braces in #0", line);
+            throw new ExcelWorkbookException(message);
+         }
+         String styleData = line.substring(startbrace + 1, stopbrace).trim();
+         StyleMap styleMap = parseStyleString(styleData);
+         styleClasses.put(name, styleMap);
+      }
+      reader.close();
+      return styleClasses;
+   }
+
+   public static String getStyle(UIComponent component) {
+      return getStyleProperty(component, STYLE_ATTRIBUTE);
+   }
+   
+   public static String getStyleClass(UIComponent component) {
+      return getStyleProperty(component, STYLE_CLASS_ATTRIBUTE);
+   }
+   
+   private static String getStyleProperty(UIComponent component, String field)
+   {
+      try
+      {
+         return (String) PropertyUtils.getProperty(component, field);
+      }
+      catch (NoSuchMethodException e)
+      {
+         // No panic, no property
+         return null;
+      }
+      catch (Exception e)
+      {
+         String message = Interpolator.instance().interpolate("Could not read field #0 of bean #1", field, component.getId());
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+
+   private List<StyleMap> cascadeStyleMap(UIComponent component, List<StyleMap> styleMaps) {
+      styleMaps.add(getStyleMap(component));
+      if (component.getParent() != null) {
+         cascadeStyleMap(component.getParent(), styleMaps);
+      }
+      return styleMaps;
+   }
+   
+   public StyleMap getCascadedStyleMap(UIComponent component) {
+      List<StyleMap> styleMaps = cascadeStyleMap(component, new ArrayList<StyleMap>());
+      Collections.reverse(styleMaps);
+      StyleMap cascadedStyleMap = new StyleMap();
+      for (StyleMap styleMap : styleMaps) {
+         cascadedStyleMap.putAll(styleMap);
+      }
+      return cascadedStyleMap;
+   }
+   
+   private StyleMap getStyleMap(UIComponent component)
+   {
+      if (cellStyleCache.containsKey(component))
+      {
+         return cellStyleCache.get(component);
+      }
+
+      StyleMap styleMap = new StyleMap();
+
+      String componentStyleClass = getStyleProperty(component, STYLE_CLASS_ATTRIBUTE);
+      if (componentStyleClass != null)
+      {
+         String[] styleClasses = trimArray(componentStyleClass.split(STYLE_SHORTHAND_SEPARATOR));
+         for (String styleClass : styleClasses)
+         {
+            if (!definedStyleClasses.containsKey(styleClass))
+            {
+               log.warn("Uknown style class #0", styleClass);
+               continue;
+            }
+            styleMap.putAll(definedStyleClasses.get(styleClass));
+         }
+      }
+
+      String componentStyle = getStyleProperty(component, STYLE_ATTRIBUTE);
+      if (componentStyle != null)
+      {
+         styleMap.putAll(parseStyleString(componentStyle));
+      }
+
+      cellStyleCache.put(component, styleMap);
+      return styleMap;
+   }
+
+   private StyleMap parseStyleString(String styleString)
+   {
+      StyleMap styleMap = new StyleMap();
+
+      String[] styles = trimArray(styleString.split(STYLES_SEPARATOR));
+      for (String style : styles)
+      {
+         String[] styleParts = style.split(STYLE_NAME_VALUE_SEPARATOR);
+         if (styleParts.length != 2)
+         {
+            log.warn("Style component #0 should be of form <key>#1<value>", style, STYLE_NAME_VALUE_SEPARATOR);
+            continue;
+         }
+         String styleName = styleParts[0].toLowerCase().trim();
+         if (!propertyBuilders.containsKey(styleName))
+         {
+            log.warn("No property builder (unknown style) for property #0", styleName);
+            continue;
+         }
+         PropertyBuilder propertyBuilder = propertyBuilders.get(styleName);
+         String styleValue = styleParts[1];
+         String[] styleValues = trimArray(styleValue.trim().split(STYLE_SHORTHAND_SEPARATOR));
+         styleMap.putAll(propertyBuilder.parseProperty(styleName, styleValues));
+      }
+
+      return styleMap;
+   }
+
+   private String[] trimArray(String[] array)
+   {
+      List<String> validValues = new ArrayList<String>();
+      for (int i = 0; i < array.length; i++)
+      {
+         if (!"".equals(array[i]) && !" ".equals(array[i]))
+         {
+            validValues.add(array[i].toLowerCase().trim());
+         }
+      }
+      return validValues.toArray(new String[validValues.size()]);
+   }
+
+   public void setStylesheets(List<UILink> stylesheets) throws MalformedURLException, IOException
+   {
+      loadStylesheets(stylesheets);
+   }
+}

Added: trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilder.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilder.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilder.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,6 @@
+package org.jboss.seam.excel.css;
+
+public interface PropertyBuilder
+{
+   public StyleMap parseProperty(String key, String[] values);
+}
\ No newline at end of file

Added: trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilders.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilders.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilders.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,442 @@
+package org.jboss.seam.excel.css;
+
+import org.jboss.seam.core.Interpolator;
+import org.jboss.seam.excel.ExcelWorkbookException;
+import org.jboss.seam.excel.jxl.JXLFactory;
+
+public class PropertyBuilders
+{
+   private static final String COLUMN_WIDTH_WILDCARD = "*";
+   
+   // "xls-column-widths: 100 200 * 300"
+   public static class ColumnWidths implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+         for (int i = 0; i < values.length; i++) {
+            String value = values[i];
+            String indexedKey = CSSNames.COLUMN_WIDTHS + i;
+            if (COLUMN_WIDTH_WILDCARD.equals(value)) {
+               // Skip it, just moving along
+            } else if (isNumeric(value)) {
+               styleMap.put(indexedKey, Integer.parseInt(value));
+            } else {
+               String message = Interpolator.instance().interpolate("Column widths must be numerical or *, not #0", value);
+               throw new ExcelWorkbookException(message);
+            }
+         }
+         return styleMap;
+      }
+   }
+
+   public static class ColumnWidth extends IntegerPropertyBuilder
+   {
+   }
+
+   public static class ColumnAutoSize extends BooleanPropertyBuilder
+   {
+   }
+
+   public static class ColumnHidden extends BooleanPropertyBuilder
+   {
+   }
+
+   public static class BorderBottomLineStyle extends StringPropertyBuilder
+   {
+   }
+
+   public static class BorderBottomColor extends StringPropertyBuilder
+   {
+   }
+
+   public static class BorderBottomShorthand implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+         for (int i = 0; i < values.length; i++)
+         {
+            String value = values[i];
+            if (JXLFactory.isColor(values[i]))
+            {
+               styleMap.put(CSSNames.BORDER_BOTTOM_COLOR, value);
+            }
+            else if (JXLFactory.isBorderLineStyle(values[i]))
+            {
+               styleMap.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, value);
+            }
+            else
+            {
+               throw new ExcelWorkbookException("Border bottom shorthand can only handle line style and color");
+            }
+         }
+         return styleMap;
+      }
+   }
+
+   public static class BorderRightLineStyle extends StringPropertyBuilder
+   {
+   }
+
+   public static class BorderRightColor extends StringPropertyBuilder
+   {
+   }
+
+   public static class BorderRightShorthand implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+         for (int i = 0; i < values.length; i++)
+         {
+            String value = values[i];
+            if (JXLFactory.isColor(values[i]))
+            {
+               styleMap.put(CSSNames.BORDER_RIGHT_COLOR, value);
+            }
+            else if (JXLFactory.isBorderLineStyle(values[i]))
+            {
+               styleMap.put(CSSNames.BORDER_RIGHT_LINE_STYLE, value);
+            }
+            else
+            {
+               throw new ExcelWorkbookException("Border right shorthand can only handle line style and color");
+            }
+         }
+         return styleMap;
+      }
+   }
+
+   public static class BorderTopLineStyle extends StringPropertyBuilder
+   {
+   }
+
+   public static class BorderTopColor extends StringPropertyBuilder
+   {
+   }
+
+   public static class BorderTopShorthand implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+         for (int i = 0; i < values.length; i++)
+         {
+            String value = values[i];
+            if (JXLFactory.isColor(values[i]))
+            {
+               styleMap.put(CSSNames.BORDER_TOP_COLOR, value);
+            }
+            else if (JXLFactory.isBorderLineStyle(values[i]))
+            {
+               styleMap.put(CSSNames.BORDER_TOP_LINE_STYLE, value);
+            }
+            else
+            {
+               throw new ExcelWorkbookException("Border top shorthand can only handle line style and color");
+            }
+         }
+         return styleMap;
+      }
+   }
+
+   public static class BorderLeftLineStyle extends StringPropertyBuilder
+   {
+   }
+
+   public static class BorderLeftColor extends StringPropertyBuilder
+   {
+   }
+
+   public static class BorderLeftShorthand implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+         for (int i = 0; i < values.length; i++)
+         {
+            String value = values[i];
+            if (JXLFactory.isColor(values[i]))
+            {
+               styleMap.put(CSSNames.BORDER_LEFT_COLOR, value);
+            }
+            else if (JXLFactory.isBorderLineStyle(values[i]))
+            {
+               styleMap.put(CSSNames.BORDER_LEFT_LINE_STYLE, value);
+            }
+            else
+            {
+               throw new ExcelWorkbookException("Border left shorthand can only handle line style and color");
+            }
+         }
+         return styleMap;
+      }
+   }
+
+   public static class BorderShorthand implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+         for (int i = 0; i < values.length; i++)
+         {
+            String value = values[i];
+            if (JXLFactory.isColor(value))
+            {
+               styleMap.put(CSSNames.BORDER_LEFT_COLOR, values[1]);
+               styleMap.put(CSSNames.BORDER_RIGHT_COLOR, values[1]);
+               styleMap.put(CSSNames.BORDER_TOP_COLOR, values[1]);
+               styleMap.put(CSSNames.BORDER_BOTTOM_COLOR, values[1]);
+            }
+            else if (JXLFactory.isBorderLineStyle(value))
+            {
+               styleMap.put(CSSNames.BORDER_LEFT_LINE_STYLE, values[0]);
+               styleMap.put(CSSNames.BORDER_RIGHT_LINE_STYLE, values[0]);
+               styleMap.put(CSSNames.BORDER_TOP_LINE_STYLE, values[0]);
+               styleMap.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, values[0]);
+            }
+            else
+            {
+               throw new ExcelWorkbookException("Border shorthand can only handle line style and color");
+            }
+         }
+         return styleMap;
+      }
+   }
+
+   public static class BackgroundColor extends StringPropertyBuilder
+   {
+   }
+
+   public static class BackgroundPattern extends StringPropertyBuilder
+   {
+   }
+
+   public static class BackgroundShorthand implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+         for (int i = 0; i < values.length; i++)
+         {
+            String value = values[i];
+            if (JXLFactory.isPattern(values[i]))
+            {
+               styleMap.put(CSSNames.BACKGROUND_PATTERN, value);
+            }
+            else if (JXLFactory.isColor(values[i]))
+            {
+               styleMap.put(CSSNames.BACKGROUND_COLOR, value);
+            }
+            else
+            {
+               throw new ExcelWorkbookException("Background shorthand can only handle color and pattern");
+            }
+         }
+         return styleMap;
+      }
+   }
+
+   public static class FontFamily extends MergingStringPropertyBuilder
+   {
+   }
+   
+   private static String collectString(String[] values, String delimiter) {
+      StringBuffer buffer = new StringBuffer();
+      for (int i = 0; i < values.length; i++) {
+         if (i > 0) {
+            buffer.append(delimiter);
+         }
+         buffer.append(values[i]);
+      }
+      return buffer.toString();
+   }
+   
+   private static class MergingStringPropertyBuilder extends StringPropertyBuilder {
+      @Override
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         String concatValues = collectString(values, " ");
+         return super.parseProperty(key, new String[] {concatValues});
+      }
+   }
+
+   public static class FontSize extends IntegerPropertyBuilder
+   {
+   }
+
+   public static class FontColor extends StringPropertyBuilder
+   {
+   }
+
+   public static class FontItalic extends BooleanPropertyBuilder
+   {
+   }
+
+   public static class FontScriptStyle extends StringPropertyBuilder
+   {
+   }
+
+   public static class FontUnderlineStyle extends StringPropertyBuilder
+   {
+   }
+
+   public static class FontBold extends BooleanPropertyBuilder
+   {
+   }
+
+   public static class FontStruckOut extends BooleanPropertyBuilder
+   {
+   }
+
+   // "12 'Times New Roman'"
+   public static class FontShorthand implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+
+         String valueString = collectString(values, " ");
+         int firstQuote = valueString.indexOf("'");
+         int lastQuote = valueString.lastIndexOf("'");
+         if (firstQuote > 0 && lastQuote > 0 && firstQuote != lastQuote) {
+            String fontName = valueString.substring(firstQuote, lastQuote);
+            styleMap.put(CSSNames.FONT_FAMILY, fontName);
+            String pre = valueString.substring(0, firstQuote - 1).trim();
+            String post = valueString.substring(lastQuote + 1).trim();
+            valueString = pre + post;
+            values = valueString.split(" ");
+         }
+         
+         for (int i = 0; i < values.length; i++)
+         {
+            String value = values[i];
+            if (JXLFactory.isScriptStyle(value))
+            {
+               styleMap.put(CSSNames.FONT_SCRIPT_STYLE, value);
+            }
+            else if (JXLFactory.isColor(value))
+            {
+               styleMap.put(CSSNames.FONT_COLOR, value);
+            }
+            else if (JXLFactory.isUnderlineStyle(value))
+            {
+               styleMap.put(CSSNames.FONT_UNDERLINE_STYLE, value);
+            }
+            else if ("italic".equals(value.toLowerCase()))
+            {
+               styleMap.put(CSSNames.FONT_ITALIC, Boolean.TRUE);
+            }
+            else if ("bold".equals(value.toLowerCase()))
+            {
+               styleMap.put(CSSNames.FONT_BOLD, Boolean.TRUE);
+            }
+            else if ("struck_out".equals(value.toLowerCase()))
+            {
+               styleMap.put(CSSNames.FONT_STRUCK_OUT, Boolean.TRUE);
+            }
+            else if (isNumeric(value))
+            {
+               styleMap.put(CSSNames.FONT_SIZE, Integer.parseInt(value));
+            }
+            else
+            {
+               styleMap.put(CSSNames.FONT_FAMILY, value);
+            }
+         }
+         
+         return styleMap;
+      }
+   }
+
+   private static boolean isNumeric(String value)
+   {
+      try
+      {
+         Integer.parseInt(value);
+      }
+      catch (NumberFormatException e)
+      {
+         return false;
+      }
+      return true;
+   }
+
+   private static boolean isBoolean(String value)
+   {
+      return "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
+   }
+   
+   public static class VericalAlignment extends StringPropertyBuilder
+   {
+   }
+
+   public static class Wrap extends BooleanPropertyBuilder
+   {
+   }
+
+   public static class ShrinkToFit extends BooleanPropertyBuilder
+   {
+   }
+
+   public static class Locked extends BooleanPropertyBuilder
+   {
+   }
+
+   public static class Orientation extends StringPropertyBuilder
+   {
+   }
+
+   public static class Indentation extends IntegerPropertyBuilder
+   {
+   }
+
+   public static class Alignment extends StringPropertyBuilder
+   {
+   }
+
+   public static class FormatMask extends StringPropertyBuilder
+   {
+   }
+
+   private static class StringPropertyBuilder implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         StyleMap styleMap = new StyleMap();
+         styleMap.put(key, values[0]);
+         return styleMap;
+      }
+   }
+
+   private static class IntegerPropertyBuilder implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         String value = values[0];
+         if (!isNumeric(value)) {
+            String message = Interpolator.instance().interpolate("#0 is not a number in #1", value, key);
+            throw new ExcelWorkbookException(message);
+         }
+         StyleMap styleMap = new StyleMap();
+         styleMap.put(key, Integer.parseInt(value));
+         return styleMap;
+      }
+   }
+   
+   private static class BooleanPropertyBuilder implements PropertyBuilder
+   {
+      public StyleMap parseProperty(String key, String[] values)
+      {
+         String value = values[0];
+         if (!isBoolean(value)) {
+            String message = Interpolator.instance().interpolate("#0 is not a boolean in #1", value, key);
+            throw new ExcelWorkbookException(message);
+         }
+         StyleMap styleMap = new StyleMap();
+         styleMap.put(key, Boolean.parseBoolean(value));
+         return styleMap;
+      }
+   }
+}

Added: trunk/src/excel/org/jboss/seam/excel/css/StyleMap.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/StyleMap.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/StyleMap.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,7 @@
+package org.jboss.seam.excel.css;
+
+import java.util.HashMap;
+
+public class StyleMap extends HashMap<String, Object>
+{
+}

Modified: trunk/src/excel/org/jboss/seam/excel/csv/CsvExcelWorkbook.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/csv/CsvExcelWorkbook.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/csv/CsvExcelWorkbook.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -7,16 +7,16 @@
 
 import org.jboss.seam.document.DocumentData;
 import org.jboss.seam.document.DocumentData.DocumentType;
-import org.jboss.seam.excel.Command;
 import org.jboss.seam.excel.ExcelWorkbook;
 import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.Template;
 import org.jboss.seam.excel.WorksheetItem;
 import org.jboss.seam.excel.ui.UICell;
 import org.jboss.seam.excel.ui.UIColumn;
 import org.jboss.seam.excel.ui.UIImage;
+import org.jboss.seam.excel.ui.UILink;
 import org.jboss.seam.excel.ui.UIWorkbook;
 import org.jboss.seam.excel.ui.UIWorksheet;
+import org.jboss.seam.excel.ui.command.Command;
 import org.jboss.seam.log.Log;
 import org.jboss.seam.log.Logging;
 
@@ -139,11 +139,6 @@
       addCell(sheet, column, row++, cell);
    }
 
-   public void addTemplate(Template template)
-   {
-      log.trace("addTemplate() is not supported by CSV exporter", new Object[0]);
-   }
-
    public void applyWorksheetSettings(UIWorksheet uiWorksheet)
    {
       log.trace("applyWorksheetSettings() is not supported by CSV exporter", new Object[0]);
@@ -171,4 +166,10 @@
       
    }
 
+   public void setStylesheets(List<UILink> stylesheets)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
 }

Modified: trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -22,7 +23,9 @@
 import org.jboss.seam.excel.ExcelFactory;
 import org.jboss.seam.excel.ExcelWorkbook;
 import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.Template;
+import org.jboss.seam.excel.css.CSSNames;
+import org.jboss.seam.excel.css.Parser;
+import org.jboss.seam.excel.css.StyleMap;
 import org.jboss.seam.excel.ui.ExcelComponent;
 import org.jboss.seam.excel.ui.UICell;
 import org.jboss.seam.excel.ui.UIColumn;
@@ -44,13 +47,17 @@
 @BypassInterceptors
 public class ExcelExporter
 {
+   private static Log log = Logging.getLog(ExcelExporter.class);
+   
    // The excel workbook implementation
    private ExcelWorkbook excelWorkbook = null;
+   private Map<Integer, Integer> columnWidths = new HashMap<Integer, Integer>();
+   
 
-   private List<Integer> columnWidths = new ArrayList<Integer>();
-
    /**
-    * Helper method to call the exporter and use the default excel workbook implementation
+    * Helper method to call the exporter and use the default excel workbook
+    * implementation
+    * 
     * @param dataTableId
     */
    public void export(String dataTableId)
@@ -79,28 +86,25 @@
       }
 
       // Inits the workbook and worksheet
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      excelWorkbook.createOrSelectWorksheet(new UIWorksheet());
+      UIWorkbook uiWorkbook = new UIWorkbook();
+      excelWorkbook.createWorkbook(uiWorkbook);
+      UIWorksheet uiWorksheet = new UIWorksheet();
+      uiWorkbook.getChildren().add(uiWorksheet);
+      uiWorksheet.setStyle(Parser.getStyle(dataTable));
+      uiWorksheet.setStyleClass(Parser.getStyleClass(dataTable));
+      excelWorkbook.createOrSelectWorksheet(uiWorksheet);
 
-      // Adds templates
-      String styleString = StyleParser.getComponentStyle(dataTable);
-      Map<String, Map<String, String>> templateMap = StyleParser.getTemplateMap(styleString);
-      List<Template> templates = StyleParser.getTemplates(templateMap);
-      for (Template template : templates)
-      {
-         excelWorkbook.addTemplate(template);
-      }
-      columnWidths = StyleParser.parseColumnWidths(templateMap.get(StyleParser.TEMPLATE_GLOBAL));
-
       // Saves the datatable var
       String dataTableVar = dataTable.getVar();
       Object oldValue = FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(dataTableVar);
 
       // Processes the columns
       List<javax.faces.component.UIColumn> columns = ExcelComponent.getChildrenOfType(dataTable.getChildren(), javax.faces.component.UIColumn.class);
+      columnWidths = parseColumnWidths(uiWorksheet);
       int col = 0;
       for (javax.faces.component.UIColumn column : columns)
       {
+         uiWorksheet.getChildren().add(column);
          Iterator iterator = UIWorksheet.unwrapIterator(dataTable.getValue());
          processColumn(column, iterator, dataTableVar, col++);
          excelWorkbook.nextColumn();
@@ -121,6 +125,25 @@
 
    }
 
+   private Map<Integer, Integer> parseColumnWidths(UIWorksheet worksheet)
+   {
+      Map<Integer, Integer> columnWidths = new HashMap<Integer, Integer>();
+      Parser parser = new Parser();
+
+      StyleMap styleMap = parser.getCascadedStyleMap(worksheet);
+      for (Map.Entry<String, Object> entry : styleMap.entrySet())
+      {
+         String key = entry.getKey();
+         if (key.startsWith(CSSNames.COLUMN_WIDTHS))
+         {
+            String columnIndexString = key.substring(CSSNames.COLUMN_WIDTHS.length());
+            int columnIndex = Integer.parseInt(columnIndexString);
+            columnWidths.put(columnIndex, (Integer) entry.getValue());
+         }
+      }
+      return columnWidths;
+   }
+
    /**
     * Puts document in store and redirects
     */
@@ -152,7 +175,7 @@
     * @param col
     */
    @SuppressWarnings("unchecked")
-   private void processColumn(javax.faces.component.UIColumn column, Iterator iterator, String var, int col)
+   private void processColumn(javax.faces.component.UIColumn column, Iterator iterator, String var, int columnIndex)
    {
       // Process header facet
       UIComponent headerFacet = column.getFacet(UIColumn.HEADER_FACET_NAME);
@@ -160,36 +183,22 @@
       {
          List<UIOutput> headerOutputs = new ArrayList<UIOutput>();
          headerOutputs.add((UIOutput) headerFacet);
-         processOutputs(headerOutputs, "global,header");
+         processOutputs(column, headerOutputs);
       }
 
-      try
-      {
-         String rendered = ExcelComponent.cmp2String(FacesContext.getCurrentInstance(), column);
-         Log log = Logging.getLog(getClass());
-         log.warn("Rendered as #0", rendered);
-      }
-      catch (IOException e)
-      {
-         e.printStackTrace();
-      }
-      
       // Process data
       while (iterator.hasNext())
       {
          FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(var, iterator.next());
          List<UIOutput> dataOutputs = ExcelComponent.getChildrenOfType(column.getChildren(), UIOutput.class);
-         processOutputs(dataOutputs, "global,data");
+         processOutputs(column, dataOutputs);
       }
 
-      if (columnWidths.size() > col)
-      {
-         Integer columnWidth = columnWidths.get(col);
-         if (columnWidth != null)
-         {
-            UIColumn uiColumn = new UIColumn(columnWidth);
-            excelWorkbook.applyColumnSettings(uiColumn);
-         }
+      Integer columnWidth = columnWidths.get(columnIndex);
+      if (columnWidth != null) {
+         UIColumn uiColumn = new UIColumn();
+         uiColumn.setStyle(CSSNames.COLUMN_WIDTH + ":" + columnWidth);
+         excelWorkbook.applyColumnSettings(uiColumn);
       }
 
    }
@@ -200,7 +209,7 @@
     * @param outputs The list of outputs to process
     * @param preTemplates The pre-pushed templates
     */
-   private void processOutputs(List<UIOutput> outputs, String preTemplates)
+   private void processOutputs(javax.faces.component.UIColumn column, List<UIOutput> outputs)
    {
       for (UIOutput output : outputs)
       {
@@ -209,24 +218,12 @@
             continue;
          }
          UICell cell = new UICell();
+         column.getChildren().add(cell);
          cell.setId(output.getId());
          cell.setValue(output.getValue());
+         cell.setStyle(Parser.getStyle(output));
+         cell.setStyleClass(Parser.getStyleClass(output));
 
-         String cellTemplates = preTemplates;
-         String localTemplates = null;
-         String outputStyle = StyleParser.getComponentStyle(output);
-
-         Map<String, String> globalTemplate = StyleParser.getTemplateMap(outputStyle).get(StyleParser.TEMPLATE_GLOBAL);
-         if (globalTemplate != null)
-         {
-            localTemplates = globalTemplate.get(StyleParser.LOCAL_TEMPLATE_STYLE);
-         }
-         if (localTemplates != null)
-         {
-            cellTemplates = cellTemplates + "," + localTemplates;
-         }
-         cell.setTemplates(cellTemplates);
-
          excelWorkbook.addItem(cell);
       }
    }

Deleted: trunk/src/excel/org/jboss/seam/excel/exporter/StyleParser.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/exporter/StyleParser.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/exporter/StyleParser.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,442 +0,0 @@
-package org.jboss.seam.excel.exporter;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-
-import org.apache.commons.beanutils.PropertyUtils;
-import org.jboss.seam.core.Interpolator;
-import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.Template;
-import org.jboss.seam.excel.ui.UIBackground;
-import org.jboss.seam.excel.ui.UIBorder;
-import org.jboss.seam.excel.ui.UICellTemplate;
-import org.jboss.seam.excel.ui.UIColumn;
-import org.jboss.seam.excel.ui.UIFont;
-
-/**
- * A helper class for parsing excel-specific xls* style attributes and
- * converting them to seam excel format
- * 
- * @author Nicklas Karlsson (nickarls at gmail.com)
- */
-public class StyleParser
-{
-   // General String constants
-   private static final String EXCEL_STYLE_PREFIX = "xls";
-   private static final String STYLE_TEMPLATE_SEPARATOR = "\\.";
-   protected static final String STYLE_ATTRIBUTE = "style";
-   private static final String STYLE_SEPARATOR = ";";
-   private static final String STYLE_VALUE_SEPARATOR = ":";
-   private static final String COLUMN_WIDTH_SEPARATOR = ",";
-   protected static final String LOCAL_TEMPLATE_STYLE = "xlsTemplates";
-   protected static final String TEMPLATE_GLOBAL = "global";
-
-   // Font attributes
-   private static final String FONT_NAME = "xlsFontName";
-   private static final String FONT_SIZE = "xlsFontSize";
-   private static final String FONT_COLOR = "xlsFontColor";
-   private static final String FONT_BOLD = "xlsFontBold";
-   private static final String FONT_ITALIC = "xlsFontItalic";
-   private static final String FONT_SCRIPT_STYLE = "xlsFontScriptStyle";
-   private static final String FONT_STRUCKOUT = "xlsFontStruckOut";
-   private static final String FONT_UNDERLINE_STYLE = "xlsFontUnderlineStyle";
-
-   // Background attributes
-   private static final String BACKGROUND_COLOR = "xlsBackgroundColor";
-   private static final String BACKGROUND_PATTERN = "xlsBackgroundPattern";
-
-   // Border attributes
-   private static final String BORDER_COLOR = "xlsBorderColor";
-   private static final String BORDER_COLOR_LEFT = "xlsBorderColorLeft";
-   private static final String BORDER_COLOR_TOP = "xlsBorderColorTop";
-   private static final String BORDER_COLOR_RIGHT = "xlsBorderColorRight";
-   private static final String BORDER_COLOR_BOTTOM = "xlsBorderColorBottom";
-   private static final String BORDER_LINE_STYLE = "xlsBorderLineStyle";
-   private static final String BORDER_LINE_STYLE_LEFT = "xlsBorderLineStyleLeft";
-   private static final String BORDER_LINE_STYLE_TOP = "xlsBorderLineStyleTop";
-   private static final String BORDER_LINE_STYLE_RIGHT = "xlsBorderLineStyleRight";
-   private static final String BORDER_LINE_STYLE_BOTTOM = "xlsBorderLineStyleBottom";
-
-   private static final String BORDER_COLOR_PREFIX = "xlsBorderColor";
-   private static final String BORDER_LINE_STYLE_PREFIX = "xlsBorderLineStyle";
-   private static final String BORDER_LEFT_POSTFIX = "Left";
-   private static final String BORDER_TOP_POSTFIX = "Top";
-   private static final String BORDER_RIGHT_POSTFIX = "Right";
-   private static final String BORDER_BOTTOM_POSTFIX = "Bottom";
-   private static final String BORDER_ALL_POSTFIX = null;
-
-   // Cell attributes
-   private static final String ALIGNMENT = "xlsAlignment";
-
-   // Column attributes
-   private static final String COLUMN_WIDTH = "xlsColumnWidths";
-
-   /**
-    * Gets the style-string from a UIComponent
-    * 
-    * @param uiComponent The component to examine
-    * @return The string or null if attribute wasn't present
-    */
-   public static String getComponentStyle(UIComponent uiComponent)
-   {
-      try
-      {
-         return (String) PropertyUtils.getSimpleProperty(uiComponent, STYLE_ATTRIBUTE);
-      }
-      catch (Exception e)
-      {
-         throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not read style attribute #0 from component #1", STYLE_ATTRIBUTE, uiComponent.getId() ));
-      }
-   }
-
-   /**
-    * Parses a style string and returns a map keyed with template name. The
-    * contents is a map with key->value pairs from the style string. The
-    * template name is determined from the key.temaplate:value form
-    * 
-    * @param styleString The style string to parse
-    * @return The Map of style attribute maps
-    */
-   public static Map<String, Map<String, String>> getTemplateMap(String styleString)
-   {
-      Map<String, Map<String, String>> templateMap = new HashMap<String, Map<String, String>>();
-      if (styleString == null)
-      {
-         return templateMap;
-      }
-
-      // Split up the style in components
-      String[] styleStringParts = styleString.split(STYLE_SEPARATOR);
-      for (String styleStringPart : styleStringParts)
-      {
-         // Split up the style part in key -> value pairs
-         String[] styleParts = styleStringPart.split(STYLE_VALUE_SEPARATOR);
-         if (styleParts.length != 2)
-         {
-            throw new ExcelWorkbookException(Interpolator.instance().interpolate("Unbalanced style parsing #0", styleStringPart));
-         }
-         String styleName = styleParts[0].trim();
-         // Only check for xls-styles
-         if (!styleName.startsWith(EXCEL_STYLE_PREFIX))
-         {
-            continue;
-         }
-         // Check if style name is global or named
-         String[] templateParts = styleName.split(STYLE_TEMPLATE_SEPARATOR);
-         if (templateParts.length == 1)
-         {
-            addStyleToTemplate(templateMap, TEMPLATE_GLOBAL, templateParts[0], styleParts[1]);
-         }
-         else if (templateParts.length == 2)
-         {
-            addStyleToTemplate(templateMap, templateParts[1], templateParts[0], styleParts[1]);
-         }
-         else
-         {
-            throw new ExcelWorkbookException(Interpolator.instance().interpolate("Unbalanced style parsing #0", styleName));
-         }
-      }
-
-      return templateMap;
-   }
-
-   /**
-    * Adds a style to a map
-    * 
-    * @param templateMap The template map
-    * @param template The name of the template
-    * @param key The key to insert
-    * @param value The value to insert
-    */
-   private static void addStyleToTemplate(Map<String, Map<String, String>> templateMap, String template, String key, String value)
-   {
-      Map<String, String> innerMap = templateMap.get(template.trim());
-      if (innerMap == null)
-      {
-         innerMap = new HashMap<String, String>();
-      }
-      innerMap.put(key.trim(), value.trim());
-      templateMap.put(template.trim(), innerMap);
-   }
-
-   /**
-    * Gets column settings from a style string
-    * 
-    * @param styleString The string to parse
-    * @return The column settings
-    */
-   public static UIColumn getColumnSettings(String styleString)
-   {
-      UIColumn uiColumn = new UIColumn();
-
-      Map<String, String> globalTemplate = getTemplateMap(styleString).get(TEMPLATE_GLOBAL);
-      if (globalTemplate == null)
-      {
-         return uiColumn;
-      }
-      if (globalTemplate.get(COLUMN_WIDTH) != null)
-      {
-         uiColumn.setWidth(Integer.parseInt(globalTemplate.get(COLUMN_WIDTH)));
-      }
-
-      return uiColumn;
-   }
-
-   /**
-    * Get a CellTemplate Template list from a string
-    * 
-    * @param templateMap Map with templates
-    * @return The template list
-    */
-   public static List<Template> getTemplates(Map<String, Map<String, String>> templateMap)
-   {
-      List<Template> templates = new ArrayList<Template>();
-
-      if (templateMap == null)
-      {
-         return templates;
-      }
-
-      // Flat the map out into named templates
-      for (Map.Entry<String, Map<String, String>> template : templateMap.entrySet())
-      {
-         String templateName = template.getKey();
-         Map<String, String> templateData = template.getValue();
-
-         UICellTemplate cellTemplate = new UICellTemplate();
-         cellTemplate.setName(templateName);
-         cellTemplate.setAlignment(templateData.get(ALIGNMENT));
-         if (hasFontStyle(templateData))
-         {
-            cellTemplate.getChildren().add(getFontStyle(templateData));
-         }
-         if (hasBackgroundStyle(templateData))
-         {
-            cellTemplate.getChildren().add(getBackgroundStyle(templateData));
-         }
-         if (hasBorders(templateData))
-         {
-            List<UIComponent> borders = getBorders(templateData);
-            for (UIComponent border : borders)
-            {
-               cellTemplate.getChildren().add(border);
-            }
-         }
-
-         templates.add(cellTemplate);
-      }
-
-      return templates;
-   }
-
-   /**
-    * Gets a background component from a template map
-    * 
-    * @param templateData The map to look in
-    * @return The background component
-    */
-   private static UIComponent getBackgroundStyle(Map<String, String> templateData)
-   {
-      UIBackground background = new UIBackground();
-
-      background.setColor(templateData.get(BACKGROUND_COLOR));
-      background.setPattern(templateData.get(BACKGROUND_PATTERN));
-
-      return background;
-   }
-
-   /**
-    * Checks if a template contains border data
-    * 
-    * @param templateData The template map to check
-    * @return true if present, otherwise false
-    */
-   private static boolean hasBorders(Map<String, String> templateData)
-   {
-      return templateData.containsKey(BORDER_LINE_STYLE) || templateData.containsKey(BORDER_LINE_STYLE_BOTTOM) || templateData.containsKey(BORDER_LINE_STYLE_LEFT) || templateData.containsKey(BORDER_LINE_STYLE_RIGHT) || templateData.containsKey(BORDER_LINE_STYLE_TOP) || templateData.containsKey(BORDER_COLOR) || templateData.containsKey(BORDER_COLOR_BOTTOM) || templateData.containsKey(BORDER_COLOR_LEFT) || templateData.containsKey(BORDER_COLOR_RIGHT) || templateData.containsKey(BORDER_COLOR_TOP);
-   }
-
-   /**
-    * Checks if a template contains background data
-    * 
-    * @param templateData The template map to check
-    * @return true if present, otherwise false
-    */
-   private static boolean hasBackgroundStyle(Map<String, String> templateData)
-   {
-      return templateData.containsKey(BACKGROUND_COLOR) || templateData.containsKey(BACKGROUND_PATTERN);
-   }
-
-   private static void parseBorders(Map<String, String> borderMap, String borderType, List<UIComponent> borders)
-   {
-      if (borderMap.isEmpty())
-      {
-         return;
-      }
-
-      UIBorder border = new UIBorder();
-
-      if (BORDER_ALL_POSTFIX == borderType)
-      {
-         border.setBorder("all");
-      }
-      else
-      {
-         border.setBorder(borderType.toLowerCase());
-      }
-
-      if (borderType == null)
-      {
-         borderType = "";
-      }
-
-      if (borderMap.containsKey(BORDER_COLOR + borderType))
-      {
-         border.setColor(borderMap.get(BORDER_COLOR + borderType));
-      }
-
-      if (borderMap.containsKey(BORDER_LINE_STYLE + borderType))
-      {
-         border.setLineStyle(borderMap.get(BORDER_LINE_STYLE + borderType));
-      }
-      else
-      {
-         border.setLineStyle("thin");
-      }
-
-      borders.add(border);
-   }
-
-   /**
-    * Gets a list of border components from the template map
-    * 
-    * @param templateData The map to inspect
-    * @return a list of UIBorder instances
-    */
-   private static List<UIComponent> getBorders(Map<String, String> templateData)
-   {
-      List<UIComponent> borders = new ArrayList<UIComponent>();
-
-      Map<String, String> all = new HashMap<String, String>();
-      Map<String, String> top = new HashMap<String, String>();
-      Map<String, String> left = new HashMap<String, String>();
-      Map<String, String> right = new HashMap<String, String>();
-      Map<String, String> bottom = new HashMap<String, String>();
-
-      for (Map.Entry<String, String> entry : templateData.entrySet())
-      {
-         if (!(entry.getKey().startsWith(BORDER_COLOR_PREFIX) || entry.getKey().startsWith(BORDER_LINE_STYLE_PREFIX)))
-         {
-            continue;
-         }
-         if (entry.getKey().endsWith(BORDER_TOP_POSTFIX))
-         {
-            top.put(entry.getKey(), entry.getValue());
-         }
-         else if (entry.getKey().endsWith(BORDER_LEFT_POSTFIX))
-         {
-            left.put(entry.getKey(), entry.getValue());
-         }
-         else if (entry.getKey().endsWith(BORDER_RIGHT_POSTFIX))
-         {
-            right.put(entry.getKey(), entry.getValue());
-         }
-         else if (entry.getKey().endsWith(BORDER_BOTTOM_POSTFIX))
-         {
-            right.put(entry.getKey(), entry.getValue());
-         }
-         else
-         {
-            all.put(entry.getKey(), entry.getValue());
-         }
-      }
-
-      parseBorders(all, BORDER_ALL_POSTFIX, borders);
-      parseBorders(left, BORDER_LEFT_POSTFIX, borders);
-      parseBorders(right, BORDER_RIGHT_POSTFIX, borders);
-      parseBorders(bottom, BORDER_BOTTOM_POSTFIX, borders);
-      parseBorders(top, BORDER_TOP_POSTFIX, borders);
-
-      return borders;
-   }
-
-   /**
-    * Gets font description from template map
-    * 
-    * @param templateData The template map to use
-    * @return The font description
-    */
-   private static UIComponent getFontStyle(Map<String, String> templateData)
-   {
-      UIFont font = new UIFont();
-
-      font.setName(templateData.get(FONT_NAME));
-      if (templateData.containsKey(FONT_SIZE))
-      {
-         font.setPointSize(Integer.parseInt(templateData.get(FONT_SIZE)));
-      }
-      font.setColor(templateData.get(FONT_COLOR));
-      if (templateData.containsKey(FONT_BOLD))
-      {
-         font.setBold(Boolean.parseBoolean(templateData.get(FONT_BOLD)));
-      }
-      if (templateData.containsKey(FONT_ITALIC))
-      {
-         font.setItalic(Boolean.parseBoolean(templateData.get(FONT_ITALIC)));
-      }
-      font.setScriptStyle(templateData.get(FONT_SCRIPT_STYLE));
-      if (templateData.containsKey(FONT_STRUCKOUT))
-      {
-         font.setStruckOut(Boolean.parseBoolean(templateData.get(FONT_STRUCKOUT)));
-      }
-      font.setUnderlineStyle(templateData.get(FONT_UNDERLINE_STYLE));
-
-      return font;
-   }
-
-   /**
-    * Checks if a template map contains font data
-    * 
-    * @param templateData The template map to inspect
-    * @return true if present, false otherwise
-    */
-   private static boolean hasFontStyle(Map<String, String> templateData)
-   {
-      return templateData.containsKey(FONT_NAME) || templateData.containsKey(FONT_SIZE) || templateData.containsKey(FONT_COLOR) || templateData.containsKey(FONT_BOLD) || templateData.containsKey(FONT_ITALIC) || templateData.containsKey(FONT_SCRIPT_STYLE) || templateData.containsKey(FONT_STRUCKOUT) || templateData.containsKey(FONT_UNDERLINE_STYLE);
-   }
-
-   protected static List<Integer> parseColumnWidths(Map<String, String> globalTemplate)
-   {
-      List<Integer> columnWidths = new ArrayList<Integer>();
-
-      if (globalTemplate == null)
-      {
-         return columnWidths;
-      }
-
-      if (!globalTemplate.containsKey(COLUMN_WIDTH))
-      {
-         return columnWidths;
-      }
-
-      String columnWidthString = globalTemplate.get(COLUMN_WIDTH);
-      String columnWidthParts[] = columnWidthString.split(COLUMN_WIDTH_SEPARATOR);
-      for (String columnWidthPart : columnWidthParts)
-      {
-         try
-         {
-            columnWidths.add(Integer.parseInt(columnWidthPart));
-         }
-         catch (NumberFormatException e)
-         {
-            columnWidths.add(null);
-         }
-      }
-      return columnWidths;
-   }
-
-}

Added: trunk/src/excel/org/jboss/seam/excel/jxl/CellInfo.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/CellInfo.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/CellInfo.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,49 @@
+package org.jboss.seam.excel.jxl;
+
+import jxl.write.WritableCellFeatures;
+import jxl.write.WritableCellFormat;
+
+import org.jboss.seam.excel.ui.UICell.CellType;
+
+public class CellInfo
+{
+   // Cell format of the cell
+   private WritableCellFormat cellFormat;
+
+   // Cell features of the cell
+   private WritableCellFeatures cellFeatures;
+
+   // Cell contents type of the cell
+   private CellType cellType;
+
+   public CellType getCellType()
+   {
+      return cellType;
+   }
+
+   public void setCellType(CellType cellType)
+   {
+      this.cellType = cellType;
+   }
+
+   public WritableCellFormat getCellFormat()
+   {
+      return cellFormat;
+   }
+
+   public WritableCellFeatures getCellFeatures()
+   {
+      return cellFeatures;
+   }
+
+   public void setCellFormat(WritableCellFormat cellFormat)
+   {
+      this.cellFormat = cellFormat;
+   }
+
+   public void setCellFeatures(WritableCellFeatures cellFeatures)
+   {
+      this.cellFeatures = cellFeatures;
+   }
+}
+

Added: trunk/src/excel/org/jboss/seam/excel/jxl/CellInfoCache.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/CellInfoCache.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/CellInfoCache.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,34 @@
+package org.jboss.seam.excel.jxl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import jxl.write.WritableCellFormat;
+
+import org.jboss.seam.excel.ui.UICell.CellType;
+
+public class CellInfoCache
+{
+   // A cache for cell types, mapped by UIComponent ID
+   private Map<String, CellType> cellDataTypeCache = new HashMap<String, CellType>();
+
+   // A cache for cell formattings, mapped by UIComponent ID
+   private Map<String, WritableCellFormat> cellFormatCache = new HashMap<String, WritableCellFormat>();
+
+   public CellType getCachedCellType(String componentId) {
+      return cellDataTypeCache.get(componentId);
+   }
+   
+   public void setCachedCellType(String componentId, CellType cellType) {
+      cellDataTypeCache.put(componentId, cellType);
+   }
+
+   public WritableCellFormat getCachedCellFormat(String componentId) {
+      return cellFormatCache.get(componentId);
+   }
+   
+   public void setCachedCellFormat(String componentId, WritableCellFormat cellFormat) {
+      cellFormatCache.put(componentId, cellFormat);
+   }
+
+}

Deleted: trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelFactory.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelFactory.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelFactory.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,1301 +0,0 @@
-package org.jboss.seam.excel.jxl;
-
-import java.io.File;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import javax.faces.component.UIComponent;
-
-import jxl.CellFeatures;
-import jxl.CellView;
-import jxl.HeaderFooter;
-import jxl.SheetSettings;
-import jxl.WorkbookSettings;
-import jxl.biff.DisplayFormat;
-import jxl.format.Alignment;
-import jxl.format.Border;
-import jxl.format.BorderLineStyle;
-import jxl.format.Colour;
-import jxl.format.Font;
-import jxl.format.Orientation;
-import jxl.format.PageOrientation;
-import jxl.format.PaperSize;
-import jxl.format.Pattern;
-import jxl.format.ScriptStyle;
-import jxl.format.UnderlineStyle;
-import jxl.format.VerticalAlignment;
-import jxl.write.DateFormat;
-import jxl.write.DateFormats;
-import jxl.write.DateTime;
-import jxl.write.Formula;
-import jxl.write.Label;
-import jxl.write.NumberFormat;
-import jxl.write.NumberFormats;
-import jxl.write.WritableCell;
-import jxl.write.WritableCellFeatures;
-import jxl.write.WritableCellFormat;
-import jxl.write.WritableFont;
-import jxl.write.WritableSheet;
-import jxl.write.WriteException;
-
-import org.jboss.seam.core.Interpolator;
-import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.Validation;
-import org.jboss.seam.excel.ui.ExcelComponent;
-import org.jboss.seam.excel.ui.UIBackground;
-import org.jboss.seam.excel.ui.UIBorder;
-import org.jboss.seam.excel.ui.UICellFormat;
-import org.jboss.seam.excel.ui.UIColumn;
-import org.jboss.seam.excel.ui.UIFont;
-import org.jboss.seam.excel.ui.UIHeaderFooter;
-import org.jboss.seam.excel.ui.UIHeaderFooterCommand;
-import org.jboss.seam.excel.ui.UIListValidation;
-import org.jboss.seam.excel.ui.UIListValidationItem;
-import org.jboss.seam.excel.ui.UINumericValidation;
-import org.jboss.seam.excel.ui.UIPrintArea;
-import org.jboss.seam.excel.ui.UIPrintTitles;
-import org.jboss.seam.excel.ui.UIRangeValidation;
-import org.jboss.seam.excel.ui.UIWorkbook;
-import org.jboss.seam.excel.ui.UIWorksheetSettings;
-import org.jboss.seam.excel.ui.UICell.CellType;
-import org.jboss.seam.excel.ui.UINumericValidation.ValidationCondition;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.log.Logging;
-
-/**
- * Superclass for the JExcelAPI factories. Contains common helper methods
- * 
- * @author Nicklas Karlsson (nickarls at gmail.com)
- * @author Daniel Roth (danielc.roth at gmail.com)
- * @version 0.2
- * 
- */
-public class JXLExcelFactory
-{
-   private static Log log = Logging.getLog(JXLExcelFactory.class);
-
-   private static final String JXL_VERTICAL_ALIGNMENT_CLASS_NAME = "jxl.format.VerticalAlignment";
-   private static final String JXL_ORIENTATION_CLASS_NAME = "jxl.format.Orientation";
-   private static final String JXL_ALIGNMENT_CLASS_NAME = "jxl.format.Alignment";
-   private static final String JXL_PATTERN_CLASS_NAME = "jxl.format.Pattern";
-   private static final String JXL_BORDER_LINE_STYLE_CLASS_NAME = "jxl.format.BorderLineStyle";
-   private static final String JXL_BORDER_CLASS_NAME = "jxl.format.Border";
-   private static final String JXL_UNDERLINE_STYLE_CLASS_NAME = "jxl.format.UnderlineStyle";
-   private static final String JXL_SCRIPT_STYLE_CLASS_NAME = "jxl.format.ScriptStyle";
-   private static final String JXL_COLOR_CLASS_NAME = "jxl.format.Colour";
-   private static final String JXL_PAGE_ORIENTATION_CLASS_NAME = "jxl.format.PageOrientation";
-   private static final String JXL_PAPER_SIZE_CLASS_NAME = "jxl.format.PaperSize";
-   private static final String HEADER_FOOTER_COMMAND_CLASS_NAME = "org.jboss.seam.excel.UIHeaderFooterCommand";
-
-   /**
-    * Creates a JExcelAPI Workbook settings object from the UI counterpart.
-    * Starts with an empty object and adds the setting only if it is non-null
-    * 
-    * @param uiWorkbook The UI element to interpret
-    * @return The created workbook settings
-    */
-   public static WorkbookSettings createWorkbookSettings(UIWorkbook uiWorkbook)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating workbook settings from #0", uiWorkbook);
-      }
-      WorkbookSettings workbookSettings = new WorkbookSettings();
-      if (uiWorkbook.getArrayGrowSize() != null)
-      {
-         workbookSettings.setArrayGrowSize(uiWorkbook.getArrayGrowSize());
-      }
-      if (uiWorkbook.getAutoFilterDisabled() != null)
-      {
-         workbookSettings.setAutoFilterDisabled(uiWorkbook.getAutoFilterDisabled());
-      }
-      if (uiWorkbook.getAutoFilterDisabled() != null)
-      {
-         workbookSettings.setCellValidationDisabled(uiWorkbook.getAutoFilterDisabled());
-      }
-      if (uiWorkbook.getCharacterSet() != null)
-      {
-         workbookSettings.setCharacterSet(uiWorkbook.getCharacterSet());
-      }
-      if (uiWorkbook.getDrawingsDisabled() != null)
-      {
-         workbookSettings.setDrawingsDisabled(uiWorkbook.getDrawingsDisabled());
-      }
-      if (uiWorkbook.getEncoding() != null)
-      {
-         workbookSettings.setEncoding(uiWorkbook.getEncoding());
-      }
-      if (uiWorkbook.getExcelDisplayLanguage() != null)
-      {
-         workbookSettings.setExcelDisplayLanguage(uiWorkbook.getExcelDisplayLanguage());
-      }
-      if (uiWorkbook.getExcelRegionalSettings() != null)
-      {
-         workbookSettings.setExcelRegionalSettings(uiWorkbook.getExcelRegionalSettings());
-      }
-      if (uiWorkbook.getFormulaAdjust() != null)
-      {
-         workbookSettings.setFormulaAdjust(uiWorkbook.getFormulaAdjust());
-      }
-      if (uiWorkbook.getGcDisabled() != null)
-      {
-         workbookSettings.setGCDisabled(uiWorkbook.getGcDisabled());
-      }
-      if (uiWorkbook.getIgnoreBlanks() != null)
-      {
-         workbookSettings.setIgnoreBlanks(uiWorkbook.getIgnoreBlanks());
-      }
-      if (uiWorkbook.getLocale() != null)
-      {
-         workbookSettings.setLocale(new Locale(uiWorkbook.getLocale()));
-      }
-      if (uiWorkbook.getMergedCellCheckingDisabled() != null)
-      {
-         workbookSettings.setMergedCellChecking(uiWorkbook.getMergedCellCheckingDisabled());
-      }
-      if (uiWorkbook.getNamesDisabled() != null)
-      {
-         workbookSettings.setNamesDisabled(uiWorkbook.getNamesDisabled());
-      }
-      if (uiWorkbook.getPropertySets() != null)
-      {
-         workbookSettings.setPropertySets(uiWorkbook.getPropertySets());
-      }
-      if (uiWorkbook.getRationalization() != null)
-      {
-         workbookSettings.setRationalization(uiWorkbook.getRationalization());
-      }
-      if (uiWorkbook.getSupressWarnings() != null)
-      {
-         workbookSettings.setSuppressWarnings(uiWorkbook.getSupressWarnings());
-      }
-      if (uiWorkbook.getTemporaryFileDuringWriteDirectory() != null)
-      {
-         workbookSettings.setTemporaryFileDuringWriteDirectory(new File(uiWorkbook.getTemporaryFileDuringWriteDirectory()));
-      }
-      if (uiWorkbook.getUseTemporaryFileDuringWrite() != null)
-      {
-         workbookSettings.setUseTemporaryFileDuringWrite(uiWorkbook.getUseTemporaryFileDuringWrite());
-      }
-      return workbookSettings;
-   }
-
-   /**
-    * Creates a JExcelAPI representation of a page orientation
-    * 
-    * @param orientation The type of orientation to create
-    * @return The page orientation representation
-    */
-   private static PageOrientation createPageOrientation(String orientation)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating page orientation for #0", orientation);
-      }
-      try
-      {
-         return orientation == null ? PageOrientation.LANDSCAPE : (PageOrientation) getConstant(JXL_PAGE_ORIENTATION_CLASS_NAME, orientation.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Page orientation {0} not supported, try {1}", orientation, getValidConstants(JXL_PAGE_ORIENTATION_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of a paper size
-    * 
-    * @param paperSize The type of paper size to create
-    * @return The paper size representation
-    */
-   private static PaperSize createPaperSize(String paperSize)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating paper size for #0", paperSize);
-      }
-      try
-      {
-         return paperSize == null ? PaperSize.A4 : (PaperSize) getConstant(JXL_PAPER_SIZE_CLASS_NAME, paperSize.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Page size {0} not supported, try {1}", paperSize, getValidConstants(JXL_PAPER_SIZE_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI header or footer representation. Processes the left,
-    * center and right facets using a helper method
-    * 
-    * @param uiHeaderFooter The UI header or footer to interpret
-    * @param headerFooter The JExcelAPI header or footer representation to add
-    *           to
-    * @return The JExcelAPI header or footer representation
-    */
-   private static HeaderFooter createHeaderFooter(UIHeaderFooter uiHeaderFooter, HeaderFooter headerFooter)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Processing header/footer #0", uiHeaderFooter);
-      }
-      processHeaderFooterFacet(headerFooter.getLeft(), uiHeaderFooter.getFacet(UIHeaderFooter.LEFT_FACET));
-      processHeaderFooterFacet(headerFooter.getCentre(), uiHeaderFooter.getFacet(UIHeaderFooter.CENTER_FACET));
-      processHeaderFooterFacet(headerFooter.getRight(), uiHeaderFooter.getFacet(UIHeaderFooter.RIGHT_FACET));
-      return headerFooter;
-   }
-
-   /**
-    * Processes a header or footer facet. A header or footer facet in JExcelAPI
-    * is split into three parts, left, center and right and the UI
-    * representation has facets with the saming namings. Gets the requested
-    * facet from the UI component and calls helper methods for processing the
-    * header commands in sequence
-    * 
-    * @param headerFooter The JExcelAPI header or footer facet to process
-    * @param facetName The name of the facet to process (left, center, right)
-    * @param uiHeaderFooter The UI representation to interpret
-    */
-   private static void processHeaderFooterFacet(HeaderFooter.Contents contents, UIComponent facet)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Processing facet #0 of header/footer #1", facet, contents);
-      }
-      // No facet found
-      if (facet == null)
-      {
-         return;
-      }
-      for (UIComponent child : facet.getChildren())
-      {
-         if (child.getClass() == UIHeaderFooterCommand.class)
-         {
-            processHeaderFooterCommand(contents, (UIHeaderFooterCommand) child);
-         }
-      }
-   }
-
-   /**
-    * Processes a header command and applies it to the JExcelAPI header contents
-    * 
-    * @param contents The contents to apply the command to (left, center, right)
-    * @param command The command to interpret
-    */
-   private static void processHeaderFooterCommand(HeaderFooter.Contents contents, UIHeaderFooterCommand command)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Processing header/footer command #0", command);
-      }
-      switch (command.getCommand())
-      {
-      case append:
-         contents.append((String) command.getParameter());
-         break;
-      case date:
-         contents.appendDate();
-         break;
-      case page_number:
-         contents.appendPageNumber();
-         break;
-      case time:
-         contents.appendTime();
-         break;
-      case total_pages:
-         contents.appendTotalPages();
-         break;
-      case workbook_name:
-         contents.appendWorkbookName();
-         break;
-      case worksheet_name:
-         contents.appendWorkSheetName();
-         break;
-      case font_name:
-         contents.setFontName((String) command.getParameter());
-         break;
-      case font_size:
-         contents.setFontSize((Integer) command.getParameter());
-         break;
-      case toggle_bold:
-         contents.toggleBold();
-         break;
-      case toggle_italics:
-         contents.toggleItalics();
-         break;
-      case toggle_double_underline:
-         contents.toggleDoubleUnderline();
-         break;
-      case toggle_outline:
-         contents.toggleOutline();
-         break;
-      case toggle_shadow:
-         contents.toggleShadow();
-         break;
-      case toggle_strikethrough:
-         contents.toggleStrikethrough();
-         break;
-      case toggle_subscript:
-         contents.toggleSubScript();
-         break;
-      case toggle_superscript:
-         contents.toggleSuperScript();
-         break;
-      default:
-         String message = Interpolator.instance().interpolate("Header/Footer command {0} not supported, try {1}", command.getCommand(), getValidConstants(HEADER_FOOTER_COMMAND_CLASS_NAME));
-         throw new ExcelWorkbookException(message);
-      }
-   }
-
-   /**
-    * Applies column settings to a column
-    * 
-    * @param uiColumn The settings to apply
-    * @param worksheet The worksheet to apply the column to
-    * @param columnIndex The column index to the column
-    */
-   public static void applyColumnSettings(UIColumn uiColumn, WritableSheet worksheet, int columnIndex)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Applying column settings #0 on column #1", uiColumn, columnIndex);
-      }
-      CellView cellView = worksheet.getColumnView(columnIndex);
-      if (uiColumn.getAutoSize() != null)
-      {
-         cellView.setAutosize(uiColumn.getAutoSize());
-      }
-      if (uiColumn.getHidden() != null)
-      {
-         cellView.setHidden(uiColumn.getHidden());
-      }
-      if (uiColumn.getWidth() != null)
-      {
-         cellView.setSize(uiColumn.getWidth());
-      }
-      worksheet.setColumnView(columnIndex, cellView);
-   }
-
-   /**
-    * Applies worksheet settings from the template to the settings
-    * 
-    * @param oldSettings The settings to append to
-    * @param template The template to examine for new settings
-    */
-   public static void applyWorksheetSettings(SheetSettings oldSettings, UIWorksheetSettings template)
-   {
-      if (template.getAutomaticFormulaCalculation() != null)
-      {
-         oldSettings.setAutomaticFormulaCalculation(template.getAutomaticFormulaCalculation());
-      }
-      if (template.getBottomMargin() != null)
-      {
-         oldSettings.setBottomMargin(template.getBottomMargin());
-      }
-      if (template.getCopies() != null)
-      {
-         oldSettings.setCopies(template.getCopies());
-      }
-      if (template.getDefaultColumnWidth() != null)
-      {
-         oldSettings.setDefaultColumnWidth(template.getDefaultColumnWidth());
-      }
-      if (template.getDefaultRowHeight() != null)
-      {
-         oldSettings.setDefaultRowHeight(template.getDefaultRowHeight());
-      }
-      if (template.getDisplayZeroValues() != null)
-      {
-         oldSettings.setDisplayZeroValues(template.getDisplayZeroValues());
-      }
-      if (template.getFitHeight() != null)
-      {
-         oldSettings.setFitHeight(template.getFitHeight());
-      }
-      if (template.getFitToPages() != null)
-      {
-         oldSettings.setFitToPages(template.getFitToPages());
-      }
-      if (template.getFitWidth() != null)
-      {
-         oldSettings.setFitWidth(template.getFitWidth());
-      }
-      if (template.getFooterMargin() != null)
-      {
-         oldSettings.setFooterMargin(template.getFooterMargin());
-      }
-      if (template.getHeaderMargin() != null)
-      {
-         oldSettings.setHeaderMargin(template.getHeaderMargin());
-      }
-      if (template.getHidden() != null)
-      {
-         oldSettings.setHidden(template.getHidden());
-      }
-      if (template.getHorizontalCentre() != null)
-      {
-         oldSettings.setHorizontalCentre(template.getHorizontalCentre());
-      }
-      if (template.getHorizontalFreeze() != null)
-      {
-         oldSettings.setHorizontalFreeze(template.getHorizontalFreeze());
-      }
-      if (template.getHorizontalPrintResolution() != null)
-      {
-         oldSettings.setHorizontalPrintResolution(template.getHorizontalPrintResolution());
-      }
-      if (template.getLeftMargin() != null)
-      {
-         oldSettings.setLeftMargin(template.getLeftMargin());
-      }
-      if (template.getNormalMagnification() != null)
-      {
-         oldSettings.setNormalMagnification(template.getNormalMagnification());
-      }
-      if (template.getOrientation() != null)
-      {
-         oldSettings.setOrientation(createPageOrientation(template.getOrientation()));
-      }
-      if (template.getPageBreakPreviewMagnification() != null)
-      {
-         oldSettings.setPageBreakPreviewMagnification(template.getPageBreakPreviewMagnification());
-      }
-      if (template.getPageBreakPreviewMode() != null)
-      {
-         oldSettings.setPageBreakPreviewMode(template.getPageBreakPreviewMode());
-      }
-      if (template.getPageStart() != null)
-      {
-         oldSettings.setPageStart(template.getPageStart());
-      }
-      if (template.getPaperSize() != null)
-      {
-         oldSettings.setPaperSize(createPaperSize(template.getPaperSize()));
-      }
-      if (template.getPassword() != null)
-      {
-         oldSettings.setPassword(template.getPassword());
-      }
-      if (template.getPasswordHash() != null)
-      {
-         oldSettings.setPasswordHash(template.getPasswordHash());
-      }
-      if (template.getPrintGridLines() != null)
-      {
-         oldSettings.setPrintGridLines(template.getPrintGridLines());
-      }
-      if (template.getPrintHeaders() != null)
-      {
-         oldSettings.setPrintHeaders(template.getPrintHeaders());
-      }
-      if (template.getSheetProtected() != null)
-      {
-         oldSettings.setProtected(template.getSheetProtected());
-      }
-      if (template.getRecalculateFormulasBeforeSave() != null)
-      {
-         oldSettings.setRecalculateFormulasBeforeSave(template.getRecalculateFormulasBeforeSave());
-      }
-      if (template.getRightMargin() != null)
-      {
-         oldSettings.setRightMargin(template.getRightMargin());
-      }
-      if (template.getScaleFactor() != null)
-      {
-         oldSettings.setScaleFactor(template.getScaleFactor());
-      }
-      if (template.getSelected() != null)
-      {
-         oldSettings.setSelected(template.getSelected());
-      }
-      if (template.getShowGridLines() != null)
-      {
-         oldSettings.setShowGridLines(template.getShowGridLines());
-      }
-      if (template.getTopMargin() != null)
-      {
-         oldSettings.setTopMargin(template.getTopMargin());
-      }
-      if (template.getVerticalCentre() != null)
-      {
-         oldSettings.setVerticalCentre(template.getVerticalCentre());
-      }
-      if (template.getVerticalFreeze() != null)
-      {
-         oldSettings.setVerticalFreeze(template.getVerticalFreeze());
-      }
-      if (template.getVerticalPrintResolution() != null)
-      {
-         oldSettings.setVerticalPrintResolution(template.getVerticalPrintResolution());
-      }
-      if (template.getZoomFactor() != null)
-      {
-         oldSettings.setZoomFactor(template.getZoomFactor());
-      }
-      // Iterates through the worksheet settings child elements (print areas,
-      // print titles and headers/footers)
-      for (UIComponent child : template.getChildren())
-      {
-         if (child.getClass() == UIPrintArea.class)
-         {
-            UIPrintArea printArea = (UIPrintArea) child;
-            oldSettings.setPrintArea(printArea.getFirstColumn(), printArea.getFirstRow(), printArea.getLastColumn(), printArea.getLastRow());
-         }
-         else if (child.getClass() == UIPrintTitles.class)
-         {
-            UIPrintTitles printTitles = (UIPrintTitles) child;
-            oldSettings.setPrintTitles(printTitles.getFirstCol(), printTitles.getFirstRow(), printTitles.getLastCol(), printTitles.getLastRow());
-         }
-         else if (child.getClass() == UIHeaderFooter.class)
-         {
-            UIHeaderFooter headerFooter = (UIHeaderFooter) child;
-            switch (headerFooter.getType())
-            {
-            case header:
-               oldSettings.setHeader(createHeaderFooter(headerFooter, oldSettings.getHeader()));
-               break;
-            case footer:
-               oldSettings.setFooter(createHeaderFooter(headerFooter, oldSettings.getFooter()));
-               break;
-            default:
-               throw new ExcelWorkbookException("Header/Footer type " + headerFooter.getType() + " not supported, try [header, footer]");
-            }
-         }
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI cell representation from the given input
-    * 
-    * @param column The row (0-based) to place the cell at
-    * @param row The column (0-based) to place the cell at
-    * @param type The type of cell
-    * @param data The contents of the cell
-    * @param cellFormat The cell format settings of the cell
-    * @return The prepared cell representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/write/WritableCell.html">WritableCell</a>
-    * @since 0.1
-    */
-   public static WritableCell createCell(int column, int row, CellType type, Object data, WritableCellFormat cellFormat)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating cell at (#0,#1) of type #2 with data #2", column, row, type, data);
-      }
-
-      switch (type)
-      {
-      case text:
-         return new Label(column, row, data.toString(), cellFormat);
-      case number:
-         return new jxl.write.Number(column, row, Double.parseDouble(data.toString()), cellFormat);
-      case date:
-         return new DateTime(column, row, (Date) data, cellFormat);
-      case formula:
-         return new Formula(column, row, data.toString(), cellFormat);
-      case bool:
-         return new jxl.write.Boolean(column, row, Boolean.parseBoolean(data.toString()), cellFormat);
-      default:
-         return new Label(column, row, data.toString(), cellFormat);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI font representation from the UI counterpart. Starting
-    * with a fresh cell or template and only applies settings that are non-null
-    * 
-    * @param uiFont The font settings to interpret
-    * @param templateFont The font to use as a template
-    * @return The font representation
-    * @throws WriteException If there is an error creating the font
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/write/WritableFont.html">WritableFont</a>
-    * @since 0.1
-    */
-   private static WritableFont createFont(UIFont uiFont, Font templateFont) throws WriteException
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating font for #0", uiFont);
-      }
-      WritableFont font = null;
-
-      if (uiFont.getName() != null)
-      {
-         font = new WritableFont(WritableFont.createFont(uiFont.getName()));
-      }
-      else if (templateFont != null)
-      {
-         font = new WritableFont(templateFont);
-      }
-      else
-      {
-         font = new WritableFont(WritableFont.ARIAL);
-      }
-
-      if (uiFont.getColor() != null)
-      {
-         font.setColour(createColor(uiFont.getColor()));
-      }
-      if (uiFont.getPointSize() != null)
-      {
-         font.setPointSize(uiFont.getPointSize());
-      }
-      if (uiFont.getBold() != null)
-      {
-         font.setBoldStyle(uiFont.getBold() ? WritableFont.BOLD : WritableFont.NO_BOLD);
-      }
-      if (uiFont.getItalic() != null)
-      {
-         font.setItalic(uiFont.getItalic());
-      }
-      if (uiFont.getStruckOut() != null)
-      {
-         font.setStruckout(uiFont.getStruckOut());
-      }
-      if (uiFont.getScriptStyle() != null)
-      {
-         font.setScriptStyle(createScriptStyle(uiFont.getScriptStyle()));
-      }
-      if (uiFont.getUnderlineStyle() != null)
-      {
-         font.setUnderlineStyle(createUnderlineStyle(uiFont.getUnderlineStyle()));
-      }
-      return font;
-   }
-
-   /**
-    * Creates a JExcelAPI representation of a number mask
-    * 
-    * @param mask The requested mask
-    * @return The mask representation or null if the mask couldn't be created
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/write/NumberFormats.html">NumberFormats</a>
-    * @since 0.1
-    */
-   private static DisplayFormat createNumberFormat(String mask)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating number format for mask #0", mask);
-      }
-      try 
-      {
-         return (DisplayFormat) getConstant("jxl.write.NumberFormats", mask);
-      }
-      catch (NoSuchFieldException e) {
-         // Look! An empty catch block! But this one is documented. We are using this to see if there is a constant
-         // defines for this in the class 
-         return null;
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of a date mask
-    * 
-    * @param mask The requested mask
-    * @return The mask representation or null if the mask couldn't be created
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/write/DateFormats.html">DateFormats</a>
-    * @since 0.1
-    */
-   private static DisplayFormat createDateFormat(String mask)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating date format for mask #0", mask);
-      }
-      try
-      {
-         return (DisplayFormat) getConstant("jxl.write.DateFormats", mask.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         // Look! An empty catch block! But this one is documented. We are using this to see if there is a constant
-         // defines for this in the class 
-         return null;
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of an vertical alignment
-    * 
-    * @param mask The requested alignment
-    * @return The alignment representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/VerticalAlignment.html">VerticalAlignment</a>
-    * @since 0.1
-    */
-   private static VerticalAlignment createVerticalAlignment(String verticalAlignment)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating verical alignment for #0", verticalAlignment);
-      }
-      try
-      {
-         return verticalAlignment == null ? VerticalAlignment.BOTTOM : (VerticalAlignment) getConstant(JXL_VERTICAL_ALIGNMENT_CLASS_NAME, verticalAlignment.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Verical alignment {0} not supported, try {1}", verticalAlignment, getValidConstants(JXL_VERTICAL_ALIGNMENT_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of an orientation
-    * 
-    * @param mask The requested orientation
-    * @return The orientation representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/Orientation.html">Orientation</a>
-    * @since 0.1
-    */
-   private static Orientation createOrientation(String orientation)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating orientation for #0", orientation);
-      }
-      try
-      {
-         return orientation == null ? Orientation.HORIZONTAL : (Orientation) getConstant(JXL_ORIENTATION_CLASS_NAME, orientation.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Orientation {0} not supported, try {1}", orientation, getValidConstants(JXL_ORIENTATION_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of an alignment
-    * 
-    * @param mask The requested alignment
-    * @return The alignment representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/Alignment.html">Alignment</a>
-    * @since 0.1
-    */
-   private static Alignment createAlignment(String alignment)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating alignment for #0", alignment);
-      }
-      try
-      {
-         return alignment == null ? Alignment.LEFT : (Alignment) getConstant(JXL_ALIGNMENT_CLASS_NAME, alignment.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Alignment {0} not supported, try {1}", alignment, getValidConstants(JXL_ALIGNMENT_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of an pattern
-    * 
-    * @param mask The requested pattern
-    * @return The pattern representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/Pattern.html">Pattern</a>
-    * @since 0.1
-    */
-   private static Pattern createPattern(String pattern)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating pattern for #0", pattern);
-      }
-      try
-      {
-         return pattern == null ? Pattern.SOLID : (Pattern) getConstant(JXL_PATTERN_CLASS_NAME, pattern.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Pattern {0} not supported, try {1}", pattern, getValidConstants(JXL_PATTERN_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of a border line style
-    * 
-    * @param mask The requested border line style
-    * @return The border line style representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/BorderlineStyle.html">BorderlineStyle</a>
-    * @since 0.1
-    */
-   private static BorderLineStyle createBorderLineStyle(String borderLineStyle)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating border line style for #0", borderLineStyle);
-      }
-      try
-      {
-         return borderLineStyle == null ? BorderLineStyle.NONE : (BorderLineStyle) getConstant(JXL_BORDER_LINE_STYLE_CLASS_NAME, borderLineStyle.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Border line style {0} not supported, try {1}", borderLineStyle, getValidConstants(JXL_BORDER_LINE_STYLE_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of a border
-    * 
-    * @param mask The requested border
-    * @return The border representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/Border.html"></a>
-    * @since 0.1
-    */
-   private static Border createBorder(String border)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating border for #0", border);
-      }
-      try
-      {
-         return border == null ? Border.ALL : (Border) getConstant(JXL_BORDER_CLASS_NAME, border.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Border {0} not supported, try {1}", border, getValidConstants(JXL_BORDER_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of an underline style
-    * 
-    * @param mask The requested underline style
-    * @return The underline style representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/UnderlineStyle.html">UnderlineStyle</a>
-    * @since 0.1
-    */
-   private static UnderlineStyle createUnderlineStyle(String underlineStyle)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating underline style for #0", underlineStyle);
-      }
-      try
-      {
-         return underlineStyle == null ? UnderlineStyle.NO_UNDERLINE : (UnderlineStyle) getConstant(JXL_UNDERLINE_STYLE_CLASS_NAME, underlineStyle.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Underline style {0} not supported, try {1}", underlineStyle, getValidConstants(JXL_UNDERLINE_STYLE_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of an script style
-    * 
-    * @param mask The requested script style
-    * @return The script style representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/ScriptStyle.html">ScriptStyle</a>
-    * @since 0.1
-    */
-   private static ScriptStyle createScriptStyle(String scriptStyle)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating script style for #0", scriptStyle);
-      }
-      try
-      {
-         return scriptStyle == null ? ScriptStyle.NORMAL_SCRIPT : (ScriptStyle) getConstant(JXL_SCRIPT_STYLE_CLASS_NAME, scriptStyle.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Script style {0} not supported, try {1}", scriptStyle, getValidConstants(JXL_SCRIPT_STYLE_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Creates a JExcelAPI representation of a color
-    * 
-    * @param mask The requested color
-    * @return The color representation
-    * @see <a
-    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/Colour.html">Colour</a>
-    * @since 0.1
-    */
-   private static Colour createColor(String color)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating color for #0", color);
-      }
-      // Workaround for the feature that black is... well not always black in
-      // Excel (ref: Andy Khan on yahoo groups)
-      if (color.equalsIgnoreCase("black"))
-      {
-         color = "palette_black";
-      }
-      try
-      {
-         return color == null ? Colour.AUTOMATIC : (Colour) getConstant(JXL_COLOR_CLASS_NAME, color.toUpperCase());
-      }
-      catch (NoSuchFieldException e)
-      {
-         String message = Interpolator.instance().interpolate("Color {0} not supported, try {1}", color, getValidConstants(JXL_COLOR_CLASS_NAME));
-         throw new ExcelWorkbookException(message, e);
-      }
-   }
-
-   /**
-    * Adds list validation to a cell
-    * 
-    * @param cellFeatures The cell features to add validation to
-    * @param validation The validation to parse
-    */
-   private static void addListValidation(WritableCellFeatures cellFeatures, UIListValidation validation)
-   {
-      List<UIListValidationItem> items = ExcelComponent.getChildrenOfType(validation.getChildren(), UIListValidationItem.class);
-      if (items.isEmpty())
-      {
-         throw new ExcelWorkbookException("No items in validation list");
-      }
-
-      List<String> validations = new ArrayList<String>();
-      for (UIListValidationItem item : items)
-      {
-         validations.add(item.getValue());
-      }
-
-      cellFeatures.setDataValidationList(validations);
-   }
-
-   /**
-    * Adds range validation to a cell
-    * 
-    * @param cellFeatures The cell features to apply the validation to
-    * @param validation The validation to add
-    */
-   private static void addRangeValidation(WritableCellFeatures cellFeatures, UIRangeValidation validation)
-   {
-      if (validation.getStartColumn() == null || validation.getStartRow() == null || validation.getEndColumn() == null || validation.getEndRow() == null)
-      {
-         throw new ExcelWorkbookException("Must set all start/end columns/rows for range validation");
-      }
-
-      cellFeatures.setDataValidationRange(validation.getStartColumn(), validation.getStartRow(), validation.getEndColumn(), validation.getEndRow());
-   }
-
-   private static void addNumericValidation(WritableCellFeatures cellFeatures, UINumericValidation validation)
-   {
-      if (validation.getValue() == null)
-      {
-         throw new ExcelWorkbookException("Must define value in validation");
-      }
-      if ((ValidationCondition.between.equals(validation.getCondition()) || ValidationCondition.not_between.equals(validation.getCondition())) && validation.getValue2() == null)
-      {
-         throw new ExcelWorkbookException("Must define both values in validation for between/not_between");
-      }
-      switch (validation.getCondition())
-      {
-      case equal:
-         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.EQUAL);
-         break;
-      case not_equal:
-         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.NOT_EQUAL);
-         break;
-      case greater_equal:
-         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.GREATER_EQUAL);
-         break;
-      case less_equal:
-         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.LESS_EQUAL);
-         break;
-      case less_than:
-         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.LESS_THAN);
-         break;
-      case between:
-         cellFeatures.setNumberValidation(validation.getValue(), validation.getValue2(), WritableCellFeatures.BETWEEN);
-         break;
-      case not_between:
-         cellFeatures.setNumberValidation(validation.getValue(), validation.getValue2(), WritableCellFeatures.NOT_BETWEEN);
-         break;
-      }
-   }
-
-   /**
-    * Creates a cell format from a blank cell or from a template, merges with a
-    * previous format
-    * 
-    * @param mergeCellFormat The cell format to merge
-    * @param templateCellFormat The cell format to use as a template
-    * @param dataType The data type of the cell requesting the format
-    * @return The merged cell format
-    * @throws WriteException If the cell format couldn't be created
-    */
-   public static WritableCellFormat createCellFormat(UICellFormat mergeCellFormat, WritableCellFormat templateCellFormat, CellType dataType) throws WriteException
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating cell format for #0 with type #1 and template #2", mergeCellFormat, dataType, templateCellFormat);
-      }
-      WritableCellFormat cellFormat = null;
-
-      switch (dataType)
-      {
-      case text:
-         // Creates a basic text format
-         cellFormat = templateCellFormat == null ? new WritableCellFormat(NumberFormats.TEXT) : new WritableCellFormat(templateCellFormat);
-         break;
-      case number:
-         /*
-          * If there is no mask, creates a default number format cell If there
-          * is a mask, tries to match it against a constant name If the constant
-          * can't be created, creates a custom number format from the mask
-          */
-         if (mergeCellFormat.getMask() == null)
-         {
-            cellFormat = templateCellFormat == null ? new WritableCellFormat(NumberFormats.DEFAULT) : new WritableCellFormat(templateCellFormat);
-         }
-         else
-         {
-            DisplayFormat displayFormat = createNumberFormat(mergeCellFormat.getMask());
-            if (displayFormat != null)
-            {
-               cellFormat = mergeCellFormat == null ? new WritableCellFormat(displayFormat) : new WritableCellFormat(templateCellFormat);
-            }
-            else
-            {
-               try
-               {
-                  cellFormat = templateCellFormat == null ? new WritableCellFormat(new NumberFormat(mergeCellFormat.getMask())) : new WritableCellFormat(templateCellFormat);
-               }
-               catch (IllegalArgumentException e)
-               {
-                  throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not create number format for mask {0}", mergeCellFormat.getMask()), e);
-               }
-            }
-         }
-         break;
-      case date:
-         /*
-          * If there is no mask, creates a default date format cell If there is
-          * a mask, tries to match it against a constant name If the constant
-          * can't be created, creates a custom date format from the mask
-          */
-
-         if (mergeCellFormat.getMask() == null)
-         {
-            cellFormat = templateCellFormat == null ? new WritableCellFormat(DateFormats.DEFAULT) : new WritableCellFormat(templateCellFormat);
-         }
-         else
-         {
-            DisplayFormat displayFormat = createDateFormat(mergeCellFormat.getMask());
-            if (displayFormat != null)
-            {
-               cellFormat = templateCellFormat == null ? new WritableCellFormat(displayFormat) : new WritableCellFormat(templateCellFormat);
-            }
-            else
-            {
-               try
-               {
-                  cellFormat = templateCellFormat == null ? new WritableCellFormat(new DateFormat(mergeCellFormat.getMask())) : new WritableCellFormat(templateCellFormat);
-               }
-               catch (IllegalArgumentException e)
-               {
-                  throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not create date format for mask {0}", mergeCellFormat.getMask()), e);
-               }
-            }
-         }
-         break;
-      case formula:
-         cellFormat = templateCellFormat == null ? new WritableCellFormat() : new WritableCellFormat(templateCellFormat);
-         break;
-      case bool:
-         cellFormat = templateCellFormat == null ? new WritableCellFormat() : new WritableCellFormat(templateCellFormat);
-         break;
-      default:
-         cellFormat = templateCellFormat == null ? new WritableCellFormat() : new WritableCellFormat(templateCellFormat);
-         break;
-      }
-
-      if (mergeCellFormat.getAlignment() != null)
-      {
-         cellFormat.setAlignment(createAlignment(mergeCellFormat.getAlignment()));
-      }
-      if (mergeCellFormat.getIndentation() != null)
-      {
-         cellFormat.setIndentation(mergeCellFormat.getIndentation());
-      }
-      if (mergeCellFormat.getLocked() != null)
-      {
-         cellFormat.setLocked(mergeCellFormat.getLocked());
-      }
-      if (mergeCellFormat.getOrientation() != null)
-      {
-         cellFormat.setOrientation(createOrientation(mergeCellFormat.getOrientation()));
-      }
-      if (mergeCellFormat.getShrinkToFit() != null)
-      {
-         cellFormat.setShrinkToFit(mergeCellFormat.getShrinkToFit());
-      }
-      if (mergeCellFormat.getVerticalAlignment() != null)
-      {
-         cellFormat.setVerticalAlignment(createVerticalAlignment(mergeCellFormat.getVerticalAlignment()));
-      }
-      if (mergeCellFormat.getWrap() != null)
-      {
-         cellFormat.setWrap(mergeCellFormat.getWrap());
-      }
-      for (UIComponent child : mergeCellFormat.getChildren())
-      {
-         if (child instanceof UIFont)
-         {
-            Font templateFont = templateCellFormat == null ? null : templateCellFormat.getFont();
-            cellFormat.setFont(createFont((UIFont) child, templateFont));
-         }
-         else if (child.getClass() == UIBorder.class)
-         {
-            cellFormat.setBorder(createBorder(((UIBorder) child).getBorder()), createBorderLineStyle(((UIBorder) child).getLineStyle()), createColor(((UIBorder) child).getColor()));
-         }
-         else if (child.getClass() == UIBackground.class)
-         {
-            cellFormat.setBackground(createColor(((UIBackground) child).getColor()), createPattern(((UIBackground) child).getPattern()));
-         }
-         else
-         {
-            // throw new ExcelWorkbookException("Invalid UICell child class " +
-            // child.getClass().getName());
-         }
-      }
-
-      return cellFormat;
-   }
-
-   /**
-    * Creates cell features from a template
-    * 
-    * @param uiCellFormat The cell format to apply
-    * @param template The template to use as a base
-    * @return The cell features
-    */
-   public static WritableCellFeatures createCellFeatures(UICellFormat uiCellFormat, CellFeatures template)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Creating cell features for #0", uiCellFormat);
-      }
-      WritableCellFeatures cellFeatures = template != null ? new WritableCellFeatures(template) : new WritableCellFeatures();
-
-      if (uiCellFormat.getComment() != null)
-      {
-         if (uiCellFormat.getCommentHeight() != null && uiCellFormat.getCommentWidth() != null)
-         {
-            cellFeatures.setComment(uiCellFormat.getComment(), uiCellFormat.getCommentWidth(), uiCellFormat.getCommentHeight());
-         }
-         else
-         {
-            cellFeatures.setComment(uiCellFormat.getComment());
-         }
-      }
-      List<Validation> validations = ExcelComponent.getChildrenOfType(uiCellFormat.getChildren(), Validation.class);
-      for (Validation validation : validations)
-      {
-         switch (validation.getType())
-         {
-         case numeric:
-            addNumericValidation(cellFeatures, (UINumericValidation) validation);
-            break;
-         case range:
-            addRangeValidation(cellFeatures, (UIRangeValidation) validation);
-            break;
-         case list:
-            addListValidation(cellFeatures, (UIListValidation) validation);
-            break;
-         default:
-            throw new ExcelWorkbookException(Interpolator.instance().interpolate("Unknown validation type {0}", validation.getType()));
-         }
-      }
-      return cellFeatures;
-   }
-
-   /**
-    * Gets a static constant from a class
-    * 
-    * @param className The name of the class containing the constant
-    * @param fieldName The name of the constant
-    * @return The constant
-    * @throws NoSuchFieldException if the field is not found
-    */
-   protected static Object getConstant(String className, String fieldName) throws NoSuchFieldException
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Looking for constant #0 in class #1", fieldName, className);
-      }
-      try
-      {
-         return Class.forName(className).getField(fieldName).get(null);
-      } catch (NoSuchFieldException e) {
-         throw e;
-      } catch (Exception e) {
-         throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not read field #0 from class #1", fieldName, className), e);
-      }
-   }
-
-   /**
-    * Fetches a list of public static constants in a class. Used for showing
-    * valid values in case of an exception fetching e.g. constants from a class.
-    * 
-    * @param className The name of the class to inspect
-    * @return A comma separated string with declared constants in the class
-    */
-   @SuppressWarnings("unchecked")
-   protected static String getValidConstants(String className)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Getting valid constants from #0", className);
-      }
-      Class clazz = null;
-      try
-      {
-         clazz = Class.forName(className);
-      }
-      catch (ClassNotFoundException e)
-      {
-         throw new ExcelWorkbookException("Could not find class while getting valid constants", e);
-      }
-      StringBuffer buffer = new StringBuffer();
-      int i = 0;
-      // Loop through the fields
-      for (Field field : clazz.getFields())
-      {
-         int modifiers = field.getModifiers();
-         // Append to list if it's public and static (as most our constants are)
-         if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers))
-         {
-            String name = field.getName().toLowerCase();
-            buffer.append(i++ == 0 ? name : ", " + name);
-         }
-      }
-      return Interpolator.instance().interpolate("[#0]", buffer.toString());
-   }
-
-}

Modified: trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelWorkbook.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelWorkbook.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelWorkbook.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -7,6 +7,7 @@
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.util.List;
 
 import javax.imageio.ImageIO;
 
@@ -23,22 +24,22 @@
 import org.jboss.seam.core.Interpolator;
 import org.jboss.seam.document.DocumentData;
 import org.jboss.seam.document.DocumentData.DocumentType;
-import org.jboss.seam.excel.Command;
 import org.jboss.seam.excel.ExcelWorkbook;
 import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.Template;
 import org.jboss.seam.excel.WorksheetItem;
-import org.jboss.seam.excel.jxl.JXLTemplates.CellInfo;
+import org.jboss.seam.excel.css.ColumnStyle;
 import org.jboss.seam.excel.ui.UICell;
 import org.jboss.seam.excel.ui.UIColumn;
-import org.jboss.seam.excel.ui.UIGroupColumns;
-import org.jboss.seam.excel.ui.UIGroupRows;
 import org.jboss.seam.excel.ui.UIHyperlink;
 import org.jboss.seam.excel.ui.UIImage;
-import org.jboss.seam.excel.ui.UIMergeCells;
-import org.jboss.seam.excel.ui.UIRowPageBreak;
+import org.jboss.seam.excel.ui.UILink;
 import org.jboss.seam.excel.ui.UIWorkbook;
 import org.jboss.seam.excel.ui.UIWorksheet;
+import org.jboss.seam.excel.ui.command.Command;
+import org.jboss.seam.excel.ui.command.UIGroupColumns;
+import org.jboss.seam.excel.ui.command.UIGroupRows;
+import org.jboss.seam.excel.ui.command.UIMergeCells;
+import org.jboss.seam.excel.ui.command.UIRowPageBreak;
 import org.jboss.seam.log.Log;
 import org.jboss.seam.log.Logging;
 
@@ -106,15 +107,14 @@
     * user-defined worksheets in the workbook.
     */
    private int currentWorksheetIndex = 0;
-   
+
    /**
-    * The maximum row index we have seen. Used for determining where to place the 
-    * worksheet footer (if any)
+    * The maximum row index we have seen. Used for determining where to place
+    * the worksheet footer (if any)
     */
    private int maxRowIndex;
 
-   // Template helper class for cell formats
-   private JXLTemplates templates = new JXLTemplates();
+   private JXLHelper jxlHelper = new JXLHelper();
 
    /**
     * Moves the row pointer to the next row. Used internally when adding data
@@ -133,7 +133,7 @@
          throw new ExcelWorkbookException(Interpolator.instance().interpolate("Excel only supports {0} rows", MAX_COLUMNS));
       }
    }
-   
+
    /**
     * Moves the internal column pointer to the next column, called by the tag to
     * indicate that a new column has been started. If the pointer exceeds the
@@ -153,7 +153,8 @@
       {
          throw new ExcelWorkbookException(Interpolator.instance().interpolate("Excel doesn't support more than {0} columns", MAX_COLUMNS));
       }
-      if (currentRowIndex > maxRowIndex) {
+      if (currentRowIndex > maxRowIndex)
+      {
          maxRowIndex = currentRowIndex;
       }
       currentRowIndex = startRowIndex;
@@ -227,7 +228,7 @@
          worksheet = workbook.createSheet(name, currentWorksheetIndex);
       }
 
-      templates.applyWorksheetSettings(worksheet, uiWorksheet);
+      jxlHelper.applyWorksheetSettings(worksheet, uiWorksheet);
       currentWorksheetIndex++;
       startColumnIndex = uiWorksheet.getStartColumn() == null ? 0 : uiWorksheet.getStartColumn();
       currentColumnIndex = startColumnIndex;
@@ -272,8 +273,8 @@
       int useRow = uiCell.getRow() != null ? uiCell.getRow() : currentRowIndex;
       int useColumn = uiCell.getColumn() != null ? uiCell.getColumn() : currentColumnIndex;
 
-      CellInfo cellInfo = templates.getCellInfo(uiCell);
-      WritableCell cell = JXLExcelFactory.createCell(useColumn, useRow, cellInfo.getCellType(), uiCell.getValue(), cellInfo.getCellFormat());
+      CellInfo cellInfo = jxlHelper.getCellInfo(uiCell);
+      WritableCell cell = JXLHelper.createCell(useColumn, useRow, cellInfo.getCellType(), uiCell.getValue(), cellInfo.getCellFormat());
       if (cellInfo.getCellFeatures() != null)
       {
          cell.setCellFeatures(cellInfo.getCellFeatures());
@@ -364,7 +365,7 @@
       WorkbookSettings workbookSettings = null;
       if (uiWorkbook.hasSettings())
       {
-         workbookSettings = JXLExcelFactory.createWorkbookSettings(uiWorkbook);
+         workbookSettings = jxlHelper.createWorkbookSettings(uiWorkbook);
       }
       if (log.isDebugEnabled())
       {
@@ -423,7 +424,7 @@
       {
          throw new ExcelWorkbookException("You can't set column settings before creating a worksheet");
       }
-      JXLExcelFactory.applyColumnSettings(uiColumn, worksheet, currentColumnIndex);
+      jxlHelper.applyColumnSettings(uiColumn, worksheet, currentColumnIndex);
    }
 
    /**
@@ -528,17 +529,6 @@
    }
 
    /**
-    * Adds a template to the template stack
-    * 
-    * @param template The template to add
-    * @since 0.2
-    */
-   public void addTemplate(Template template)
-   {
-      templates.addTemplate(template);
-   }
-
-   /**
     * Executes a command for a worksheet
     * 
     * @param command The command to execute
@@ -714,4 +704,16 @@
       startRowIndex++;
    }
 
+   public void setStylesheets(List<UILink> stylesheets)
+   {
+      try
+      {
+         jxlHelper.setStylesheets(stylesheets);
+      }
+      catch (Exception e)
+      {
+         throw new ExcelWorkbookException("Could not parse stylesheet", e);
+      }
+   }
+
 }

Added: trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,565 @@
+package org.jboss.seam.excel.jxl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+
+import jxl.HeaderFooter;
+import jxl.biff.DisplayFormat;
+import jxl.biff.FontRecord;
+import jxl.format.Alignment;
+import jxl.format.Border;
+import jxl.format.BorderLineStyle;
+import jxl.format.Colour;
+import jxl.format.Orientation;
+import jxl.format.PageOrientation;
+import jxl.format.PaperSize;
+import jxl.format.Pattern;
+import jxl.format.ScriptStyle;
+import jxl.format.UnderlineStyle;
+import jxl.format.VerticalAlignment;
+import jxl.write.WritableFont;
+import jxl.write.WriteException;
+
+import org.jboss.seam.core.Interpolator;
+import org.jboss.seam.excel.ExcelWorkbookException;
+import org.jboss.seam.excel.css.CellStyle;
+import org.jboss.seam.excel.ui.UIHeaderFooter;
+import org.jboss.seam.excel.ui.UIHeaderFooterCommand;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.log.Logging;
+
+public class JXLFactory
+{
+   private static final String DATEFORMATS_CLASSNAME = "jxl.write.DateFormats";
+   private static final String NUMBERFORMATS_CLASSNAME = "jxl.write.NumberFormats";
+   private static final String ALIGNMENT_CLASS_NAME = "jxl.format.Alignment";
+   private static final String ORIENTATION_CLASS_NAME = "jxl.format.Orientation";
+   private static final String VERTICAL_ALIGNMENT_CLASS_NAME = "jxl.format.VerticalAlignment";
+   private static final String COLOR_CLASS_NAME = "jxl.format.Colour";
+   private static final String BORDER_CLASS_NAME = "jxl.format.Border";
+   private static final String BORDER_LINE_STYLE_CLASS_NAME = "jxl.format.BorderLineStyle";
+   private static final String PATTERN_CLASS_NAME = "jxl.format.Pattern";
+   private static final String PAGE_ORIENTATION_CLASS_NAME = "jxl.format.PageOrientation";
+   private static final String PAPER_SIZE_CLASS_NAME = "jxl.format.PaperSize";
+   private static final String HEADER_FOOTER_COMMAND_CLASS_NAME = "org.jboss.seam.excel.UIHeaderFooterCommand";
+   private static final String SCRIPT_STYLE_CLASS_NAME = "jxl.format.ScriptStyle";
+   private static final String UNDERLINE_STYLE_CLASS_NAME = "jxl.format.UnderlineStyle";
+   
+   private static final Log log = Logging.getLog(JXLFactory.class);
+
+   public static boolean isBorderLineStyle(String text) {
+      return getValidContants(BORDER_LINE_STYLE_CLASS_NAME).contains(text.toLowerCase());
+   }
+   
+   public static boolean isPattern(String text) {
+      return getValidContants(PATTERN_CLASS_NAME).contains(text.toLowerCase());
+   }
+   
+   public static boolean isColor(String text) {
+      return getValidContants(COLOR_CLASS_NAME).contains(text.toLowerCase());
+   }
+
+   public static boolean isAlignment(String text) {
+      return getValidContants(ALIGNMENT_CLASS_NAME).contains(text.toLowerCase());
+   }
+
+   public static boolean isOrientation(String text) {
+      return getValidContants(ORIENTATION_CLASS_NAME).contains(text.toLowerCase());
+   }
+
+   public static boolean isVerticalAlignment(String text) {
+      return getValidContants(VERTICAL_ALIGNMENT_CLASS_NAME).contains(text.toLowerCase());
+   }
+
+   public static boolean isUnderlineStyle(String text) {
+      return getValidContants(UNDERLINE_STYLE_CLASS_NAME).contains(text.toLowerCase());
+   }
+
+   public static boolean isScriptStyle(String text) {
+      return getValidContants(SCRIPT_STYLE_CLASS_NAME).contains(text.toLowerCase());
+   }
+
+   private static List<String> getValidContants(String className) {
+      List<String> constants = new ArrayList<String>();
+      
+      if (log.isTraceEnabled())
+      {
+         log.trace("Getting valid constants from #0", className);
+      }
+      Class clazz = null;
+      try
+      {
+         clazz = Class.forName(className);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new ExcelWorkbookException("Could not find class while getting valid constants", e);
+      }
+      // Loop through the fields
+      for (Field field : clazz.getFields())
+      {
+         int modifiers = field.getModifiers();
+         // Append to list if it's public and static (as most our constants are)
+         if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers))
+         {
+            constants.add(field.getName().toLowerCase());
+         }
+      }
+      return constants;
+   }
+   
+   public static String getValidConstantsSuggestion(String className)
+   {
+      List<String> constants = getValidContants(className);
+      StringBuffer buffer = new StringBuffer();
+      int i = 0;
+      // Loop through the fields
+      for (String field : constants)
+      {
+         buffer.append(i++ == 0 ? field : ", " + field);
+      }
+      return Interpolator.instance().interpolate("[#0]", buffer.toString());
+   }   
+   
+   private static Object getConstant(String className, String fieldName) throws NoSuchFieldException
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Looking for constant #0 in class #1", fieldName, className);
+      }
+      try
+      {
+         return Class.forName(className).getField(fieldName).get(null);
+      }
+      catch (NoSuchFieldException e)
+      {
+         throw e;
+      }
+      catch (Exception e)
+      {
+         throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not read field #0 from class #1", fieldName, className), e);
+      }
+   }   
+   
+   public static Alignment createAlignment(String alignment)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating alignment for #0", alignment);
+      }
+      try
+      {
+         return alignment == null ? Alignment.LEFT : (Alignment) getConstant(ALIGNMENT_CLASS_NAME, alignment.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Alignment {0} not supported, try {1}", alignment, getValidConstantsSuggestion(ALIGNMENT_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+   
+   /**
+    * Creates a JExcelAPI representation of an script style
+    * 
+    * @param mask The requested script style
+    * @return The script style representation
+    * @see <a
+    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/ScriptStyle.html">ScriptStyle</a>
+    * @since 0.1
+    */
+   private static ScriptStyle createScriptStyle(String scriptStyle)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating script style for #0", scriptStyle);
+      }
+      try
+      {
+         return scriptStyle == null ? ScriptStyle.NORMAL_SCRIPT : (ScriptStyle) getConstant(SCRIPT_STYLE_CLASS_NAME, scriptStyle.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Script style {0} not supported, try {1}", scriptStyle, getValidConstantsSuggestion(SCRIPT_STYLE_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }   
+   
+   /**
+    * Creates a JExcelAPI representation of an underline style
+    * 
+    * @param mask The requested underline style
+    * @return The underline style representation
+    * @see <a
+    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/UnderlineStyle.html">UnderlineStyle</a>
+    * @since 0.1
+    */
+   private static UnderlineStyle createUnderlineStyle(String underlineStyle)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating underline style for #0", underlineStyle);
+      }
+      try
+      {
+         return underlineStyle == null ? UnderlineStyle.NO_UNDERLINE : (UnderlineStyle) getConstant(UNDERLINE_STYLE_CLASS_NAME, underlineStyle.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Underline style {0} not supported, try {1}", underlineStyle, getValidConstantsSuggestion(UNDERLINE_STYLE_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }   
+ 
+   public static FontRecord createFont(CellStyle.Font fontspecs) throws WriteException
+   {
+      WritableFont font = null;
+      if (fontspecs.family != null) {
+         font = new WritableFont(WritableFont.createFont(fontspecs.family));
+      }
+      else
+      {
+         font = new WritableFont(WritableFont.ARIAL);
+      }
+      if (fontspecs.pointSize != null) {
+         font.setPointSize(fontspecs.pointSize);
+      }
+      if (fontspecs.color != null) {
+         font.setColour(createColor(fontspecs.color));
+      }
+      if (fontspecs.bold != null) {
+         font.setBoldStyle(fontspecs.bold ? WritableFont.BOLD : WritableFont.NO_BOLD);
+      }
+      if (fontspecs.italic != null) {
+         font.setItalic(fontspecs.italic);
+      }
+      if (fontspecs.struckOut != null) {
+         font.setStruckout(fontspecs.struckOut);
+      }
+      if (fontspecs.scriptStyle != null) {
+         font.setScriptStyle(createScriptStyle(fontspecs.scriptStyle));
+      }
+      if (fontspecs.underlineStyle != null) {
+         font.setUnderlineStyle(createUnderlineStyle(fontspecs.underlineStyle));
+      }
+      return font;
+   }
+
+   public static DisplayFormat createNumberFormat(String mask)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating number format for mask #0", mask);
+      }
+      try
+      {
+         return (DisplayFormat) getConstant(NUMBERFORMATS_CLASSNAME, mask);
+      }
+      catch (NoSuchFieldException e)
+      {
+         // Look! An empty catch block! But this one is documented. We are using
+         // this to see if there is a constant
+         // defines for this in the class
+         return null;
+      }
+   }
+
+   public static DisplayFormat createDateFormat(String mask)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating date format for mask #0", mask);
+      }
+      try
+      {
+         return (DisplayFormat) getConstant(DATEFORMATS_CLASSNAME, mask.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         // Look! An empty catch block! But this one is documented. We are using
+         // this to see if there is a constant
+         // defines for this in the class
+         return null;
+      }
+   }
+
+   public static Colour createColor(String color)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating color for #0", color);
+      }
+      // Workaround for the feature that black is... well not always black in
+      // Excel (ref: Andy Khan on yahoo groups)
+      if (color.equalsIgnoreCase("black"))
+      {
+         color = "palette_black";
+      }
+      try
+      {
+         return color == null ? Colour.AUTOMATIC : (Colour) getConstant(COLOR_CLASS_NAME, color.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Color {0} not supported, try {1}", color, getValidConstantsSuggestion(COLOR_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+
+   public static Orientation createOrientation(String orientation)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating orientation for #0", orientation);
+      }
+      try
+      {
+         return orientation == null ? Orientation.HORIZONTAL : (Orientation) getConstant(ORIENTATION_CLASS_NAME, orientation.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Orientation {0} not supported, try {1}", orientation, getValidConstantsSuggestion(ORIENTATION_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+
+   public static VerticalAlignment createVerticalAlignment(String verticalAlignment)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating verical alignment for #0", verticalAlignment);
+      }
+      try
+      {
+         return verticalAlignment == null ? VerticalAlignment.BOTTOM : (VerticalAlignment) getConstant(VERTICAL_ALIGNMENT_CLASS_NAME, verticalAlignment.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Verical alignment {0} not supported, try {1}", verticalAlignment, getValidConstantsSuggestion(VERTICAL_ALIGNMENT_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+
+   public static Border createBorder(String border)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating border for #0", border);
+      }
+      try
+      {
+         return border == null ? Border.ALL : (Border) getConstant(BORDER_CLASS_NAME, border.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Border {0} not supported, try {1}", border, getValidConstantsSuggestion(BORDER_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+
+   public static BorderLineStyle createLineStyle(String string)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating border line style for #0", string);
+      }
+      try
+      {
+         return string == null ? BorderLineStyle.NONE : (BorderLineStyle) getConstant(BORDER_LINE_STYLE_CLASS_NAME, string.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Border line style {0} not supported, try {1}", string, getValidConstantsSuggestion(BORDER_LINE_STYLE_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+
+   public static Pattern createPattern(String pattern)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating pattern for #0", pattern);
+      }
+      try
+      {
+         return pattern == null ? Pattern.SOLID : (Pattern) getConstant(PATTERN_CLASS_NAME, pattern.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Pattern {0} not supported, try {1}", pattern, getValidConstantsSuggestion(PATTERN_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+   
+   /**
+    * Creates a JExcelAPI representation of a page orientation
+    * 
+    * @param orientation The type of orientation to create
+    * @return The page orientation representation
+    */
+   public static PageOrientation createPageOrientation(String orientation)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating page orientation for #0", orientation);
+      }
+      try
+      {
+         return orientation == null ? PageOrientation.LANDSCAPE : (PageOrientation) getConstant(PAGE_ORIENTATION_CLASS_NAME, orientation.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Page orientation {0} not supported, try {1}", orientation, getValidConstantsSuggestion(PAGE_ORIENTATION_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }   
+
+   /**
+    * Creates a JExcelAPI representation of a paper size
+    * 
+    * @param paperSize The type of paper size to create
+    * @return The paper size representation
+    */
+   public static PaperSize createPaperSize(String paperSize)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating paper size for #0", paperSize);
+      }
+      try
+      {
+         return paperSize == null ? PaperSize.A4 : (PaperSize) getConstant(PAPER_SIZE_CLASS_NAME, paperSize.toUpperCase());
+      }
+      catch (NoSuchFieldException e)
+      {
+         String message = Interpolator.instance().interpolate("Page size {0} not supported, try {1}", paperSize, getValidConstantsSuggestion(PAPER_SIZE_CLASS_NAME));
+         throw new ExcelWorkbookException(message, e);
+      }
+   }
+   
+   /**
+    * Creates a JExcelAPI header or footer representation. Processes the left,
+    * center and right facets using a helper method
+    * 
+    * @param uiHeaderFooter The UI header or footer to interpret
+    * @param headerFooter The JExcelAPI header or footer representation to add
+    *           to
+    * @return The JExcelAPI header or footer representation
+    */
+   public static HeaderFooter createHeaderFooter(UIHeaderFooter uiHeaderFooter, HeaderFooter headerFooter)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Processing header/footer #0", uiHeaderFooter);
+      }
+      processHeaderFooterFacet(headerFooter.getLeft(), uiHeaderFooter.getFacet(UIHeaderFooter.LEFT_FACET));
+      processHeaderFooterFacet(headerFooter.getCentre(), uiHeaderFooter.getFacet(UIHeaderFooter.CENTER_FACET));
+      processHeaderFooterFacet(headerFooter.getRight(), uiHeaderFooter.getFacet(UIHeaderFooter.RIGHT_FACET));
+      return headerFooter;
+   }
+
+   /**
+    * Processes a header or footer facet. A header or footer facet in JExcelAPI
+    * is split into three parts, left, center and right and the UI
+    * representation has facets with the same namings. Gets the requested
+    * facet from the UI component and calls helper methods for processing the
+    * header commands in sequence
+    * 
+    * @param headerFooter The JExcelAPI header or footer facet to process
+    * @param facetName The name of the facet to process (left, center, right)
+    * @param uiHeaderFooter The UI representation to interpret
+    */
+   private static void processHeaderFooterFacet(HeaderFooter.Contents contents, UIComponent facet)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Processing facet #0 of header/footer #1", facet, contents);
+      }
+      // No facet found
+      if (facet == null)
+      {
+         return;
+      }
+      for (UIComponent child : facet.getChildren())
+      {
+         if (child.getClass() == UIHeaderFooterCommand.class)
+         {
+            processHeaderFooterCommand(contents, (UIHeaderFooterCommand) child);
+         }
+      }
+   }
+
+   /**
+    * Processes a header command and applies it to the JExcelAPI header contents
+    * 
+    * @param contents The contents to apply the command to (left, center, right)
+    * @param command The command to interpret
+    */
+   private static void processHeaderFooterCommand(HeaderFooter.Contents contents, UIHeaderFooterCommand command)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Processing header/footer command #0", command);
+      }
+      switch (command.getCommand())
+      {
+      case append:
+         contents.append((String) command.getParameter());
+         break;
+      case date:
+         contents.appendDate();
+         break;
+      case page_number:
+         contents.appendPageNumber();
+         break;
+      case time:
+         contents.appendTime();
+         break;
+      case total_pages:
+         contents.appendTotalPages();
+         break;
+      case workbook_name:
+         contents.appendWorkbookName();
+         break;
+      case worksheet_name:
+         contents.appendWorkSheetName();
+         break;
+      case font_name:
+         contents.setFontName((String) command.getParameter());
+         break;
+      case font_size:
+         contents.setFontSize((Integer) command.getParameter());
+         break;
+      case toggle_bold:
+         contents.toggleBold();
+         break;
+      case toggle_italics:
+         contents.toggleItalics();
+         break;
+      case toggle_double_underline:
+         contents.toggleDoubleUnderline();
+         break;
+      case toggle_outline:
+         contents.toggleOutline();
+         break;
+      case toggle_shadow:
+         contents.toggleShadow();
+         break;
+      case toggle_strikethrough:
+         contents.toggleStrikethrough();
+         break;
+      case toggle_subscript:
+         contents.toggleSubScript();
+         break;
+      case toggle_superscript:
+         contents.toggleSuperScript();
+         break;
+      default:
+         String message = Interpolator.instance().interpolate("Header/Footer command {0} not supported, try {1}", command.getCommand(), getValidConstantsSuggestion(HEADER_FOOTER_COMMAND_CLASS_NAME));
+         throw new ExcelWorkbookException(message);
+      }
+   }      
+}

Added: trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,755 @@
+package org.jboss.seam.excel.jxl;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import javax.faces.component.UIComponent;
+
+import jxl.CellView;
+import jxl.SheetSettings;
+import jxl.WorkbookSettings;
+import jxl.biff.DisplayFormat;
+import jxl.write.DateFormat;
+import jxl.write.DateFormats;
+import jxl.write.DateTime;
+import jxl.write.Formula;
+import jxl.write.Label;
+import jxl.write.NumberFormat;
+import jxl.write.NumberFormats;
+import jxl.write.WritableCell;
+import jxl.write.WritableCellFeatures;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableSheet;
+import jxl.write.WriteException;
+
+import org.jboss.seam.core.Interpolator;
+import org.jboss.seam.excel.ExcelWorkbookException;
+import org.jboss.seam.excel.css.CellStyle;
+import org.jboss.seam.excel.css.ColumnStyle;
+import org.jboss.seam.excel.css.Parser;
+import org.jboss.seam.excel.ui.ExcelComponent;
+import org.jboss.seam.excel.ui.UICell;
+import org.jboss.seam.excel.ui.UICellBase;
+import org.jboss.seam.excel.ui.UIColumn;
+import org.jboss.seam.excel.ui.UIHeaderFooter;
+import org.jboss.seam.excel.ui.UILink;
+import org.jboss.seam.excel.ui.UIPrintArea;
+import org.jboss.seam.excel.ui.UIPrintTitles;
+import org.jboss.seam.excel.ui.UIWorkbook;
+import org.jboss.seam.excel.ui.UIWorksheet;
+import org.jboss.seam.excel.ui.UICell.CellType;
+import org.jboss.seam.excel.ui.validation.UIListValidation;
+import org.jboss.seam.excel.ui.validation.UIListValidationItem;
+import org.jboss.seam.excel.ui.validation.UINumericValidation;
+import org.jboss.seam.excel.ui.validation.UIRangeValidation;
+import org.jboss.seam.excel.ui.validation.Validation;
+import org.jboss.seam.excel.ui.validation.UINumericValidation.ValidationCondition;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.log.Logging;
+
+public class JXLHelper
+{
+
+   private static Log log = Logging.getLog(JXLHelper.class);
+
+   private Parser parser = new Parser();
+   private CellInfoCache cellInfoCache = new CellInfoCache();
+      
+   public WritableCellFormat createCellFormat(UICell uiCell) throws WriteException
+   {
+      WritableCellFormat cellFormat = null;
+      CellStyle cellStyle = new CellStyle(parser.getCascadedStyleMap(uiCell));
+
+      switch (uiCell.getDataType())
+      {
+      case text:
+         // Creates a basic text format
+         cellFormat = new WritableCellFormat(NumberFormats.TEXT);
+         break;
+      case number:
+         /*
+          * If there is no mask, creates a default number format cell If there
+          * is a mask, tries to match it against a constant name If the constant
+          * can't be created, creates a custom number format from the mask
+          */
+
+         if (cellStyle.formatMask == null)
+         {
+            cellFormat = new WritableCellFormat(NumberFormats.DEFAULT);
+         }
+         else
+         {
+            DisplayFormat displayFormat = JXLFactory.createNumberFormat(cellStyle.formatMask);
+            if (displayFormat != null)
+            {
+               cellFormat = new WritableCellFormat(displayFormat);
+            }
+            else
+            {
+               try
+               {
+                  cellFormat = new WritableCellFormat(new NumberFormat(cellStyle.formatMask));
+               }
+               catch (IllegalArgumentException e)
+               {
+                  throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not create number format for mask {0}", cellStyle.formatMask), e);
+               }
+            }
+         }
+         break;
+      case date:
+         /*
+          * If there is no mask, creates a default date format cell If there is
+          * a mask, tries to match it against a constant name If the constant
+          * can't be created, creates a custom date format from the mask
+          */
+
+         if (cellStyle.formatMask == null)
+         {
+            cellFormat = new WritableCellFormat(DateFormats.DEFAULT);
+         }
+         else
+         {
+            DisplayFormat displayFormat = JXLFactory.createDateFormat(cellStyle.formatMask);
+            if (displayFormat != null)
+            {
+               cellFormat = new WritableCellFormat(displayFormat);
+            }
+            else
+            {
+               try
+               {
+                  cellFormat = new WritableCellFormat(new DateFormat(cellStyle.formatMask));
+               }
+               catch (IllegalArgumentException e)
+               {
+                  throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not create date format for mask {0}", cellStyle.formatMask), e);
+               }
+            }
+         }
+         break;
+      case formula:
+         cellFormat = new WritableCellFormat();
+         break;
+      case bool:
+         cellFormat = new WritableCellFormat();
+         break;
+      default:
+         cellFormat = new WritableCellFormat();
+         break;
+      }
+
+      if (cellStyle.alignment != null)
+      {
+         cellFormat.setAlignment(JXLFactory.createAlignment(cellStyle.alignment));
+      }
+
+      if (cellStyle.indentation != null)
+      {
+         cellFormat.setIndentation(cellStyle.indentation);
+      }
+
+      if (cellStyle.locked != null)
+      {
+         cellFormat.setLocked(cellStyle.locked);
+      }
+
+      if (cellStyle.orientation != null)
+      {
+         cellFormat.setOrientation(JXLFactory.createOrientation(cellStyle.orientation));
+      }
+
+      if (cellStyle.shrinkToFit != null)
+      {
+         cellFormat.setShrinkToFit(cellStyle.shrinkToFit);
+      }
+
+      if (cellStyle.verticalAlignment != null)
+      {
+         cellFormat.setVerticalAlignment(JXLFactory.createVerticalAlignment(cellStyle.verticalAlignment));
+      }
+
+      if (cellStyle.wrap != null)
+      {
+         cellFormat.setWrap(cellStyle.wrap);
+      }
+
+      if (cellStyle.font.isUsed())
+      {
+         cellFormat.setFont(JXLFactory.createFont(cellStyle.font));
+      }
+
+      if (cellStyle.leftBorder.isUsed())
+      {
+         cellFormat.setBorder(JXLFactory.createBorder("left"), 
+               JXLFactory.createLineStyle(cellStyle.leftBorder.lineStyle), 
+               JXLFactory.createColor(cellStyle.leftBorder.color));
+      }
+      if (cellStyle.topBorder.isUsed())
+      {
+         cellFormat.setBorder(JXLFactory.createBorder("top"), 
+               JXLFactory.createLineStyle(cellStyle.topBorder.lineStyle), 
+               JXLFactory.createColor(cellStyle.topBorder.color));
+      }
+      if (cellStyle.rightBorder.isUsed())
+      {
+         cellFormat.setBorder(JXLFactory.createBorder("right"), 
+               JXLFactory.createLineStyle(cellStyle.rightBorder.lineStyle), 
+               JXLFactory.createColor(cellStyle.rightBorder.color));
+      }
+      if (cellStyle.bottomBorder.isUsed())
+      {
+         cellFormat.setBorder(JXLFactory.createBorder("bottom"), 
+               JXLFactory.createLineStyle(cellStyle.bottomBorder.lineStyle), 
+               JXLFactory.createColor(cellStyle.bottomBorder.color));
+      }
+      if (cellStyle.background.isUsed())
+      {
+         cellFormat.setBackground(JXLFactory.createColor(cellStyle.background.color), 
+               JXLFactory.createPattern(cellStyle.background.pattern));
+      }
+      return cellFormat;
+   }
+
+   public void setStylesheets(List<UILink> stylesheets) throws MalformedURLException, IOException
+   {
+      parser.setStylesheets(stylesheets);
+   }
+
+   protected void applyWorksheetSettings(WritableSheet worksheet, UIWorksheet uiWorksheet)
+   {
+      SheetSettings settings = worksheet.getSettings();
+      if (uiWorksheet.getAutomaticFormulaCalculation() != null)
+      {
+         settings.setAutomaticFormulaCalculation(uiWorksheet.getAutomaticFormulaCalculation());
+      }
+      if (uiWorksheet.getBottomMargin() != null)
+      {
+         settings.setBottomMargin(uiWorksheet.getBottomMargin());
+      }
+      if (uiWorksheet.getCopies() != null)
+      {
+         settings.setCopies(uiWorksheet.getCopies());
+      }
+      if (uiWorksheet.getDefaultColumnWidth() != null)
+      {
+         settings.setDefaultColumnWidth(uiWorksheet.getDefaultColumnWidth());
+      }
+      if (uiWorksheet.getDefaultRowHeight() != null)
+      {
+         settings.setDefaultRowHeight(uiWorksheet.getDefaultRowHeight());
+      }
+      if (uiWorksheet.getDisplayZeroValues() != null)
+      {
+         settings.setDisplayZeroValues(uiWorksheet.getDisplayZeroValues());
+      }
+      if (uiWorksheet.getFitHeight() != null)
+      {
+         settings.setFitHeight(uiWorksheet.getFitHeight());
+      }
+      if (uiWorksheet.getFitToPages() != null)
+      {
+         settings.setFitToPages(uiWorksheet.getFitToPages());
+      }
+      if (uiWorksheet.getFitWidth() != null)
+      {
+         settings.setFitWidth(uiWorksheet.getFitWidth());
+      }
+      if (uiWorksheet.getFooterMargin() != null)
+      {
+         settings.setFooterMargin(uiWorksheet.getFooterMargin());
+      }
+      if (uiWorksheet.getHeaderMargin() != null)
+      {
+         settings.setHeaderMargin(uiWorksheet.getHeaderMargin());
+      }
+      if (uiWorksheet.getHidden() != null)
+      {
+         settings.setHidden(uiWorksheet.getHidden());
+      }
+      if (uiWorksheet.getHorizontalCentre() != null)
+      {
+         settings.setHorizontalCentre(uiWorksheet.getHorizontalCentre());
+      }
+      if (uiWorksheet.getHorizontalFreeze() != null)
+      {
+         settings.setHorizontalFreeze(uiWorksheet.getHorizontalFreeze());
+      }
+      if (uiWorksheet.getHorizontalPrintResolution() != null)
+      {
+         settings.setHorizontalPrintResolution(uiWorksheet.getHorizontalPrintResolution());
+      }
+      if (uiWorksheet.getLeftMargin() != null)
+      {
+         settings.setLeftMargin(uiWorksheet.getLeftMargin());
+      }
+      if (uiWorksheet.getNormalMagnification() != null)
+      {
+         settings.setNormalMagnification(uiWorksheet.getNormalMagnification());
+      }
+      if (uiWorksheet.getOrientation() != null)
+      {
+         settings.setOrientation(JXLFactory.createPageOrientation(uiWorksheet.getOrientation()));
+      }
+      if (uiWorksheet.getPageBreakPreviewMagnification() != null)
+      {
+         settings.setPageBreakPreviewMagnification(uiWorksheet.getPageBreakPreviewMagnification());
+      }
+      if (uiWorksheet.getPageBreakPreviewMode() != null)
+      {
+         settings.setPageBreakPreviewMode(uiWorksheet.getPageBreakPreviewMode());
+      }
+      if (uiWorksheet.getPageStart() != null)
+      {
+         settings.setPageStart(uiWorksheet.getPageStart());
+      }
+      if (uiWorksheet.getPaperSize() != null)
+      {
+         settings.setPaperSize(JXLFactory.createPaperSize(uiWorksheet.getPaperSize()));
+      }
+      if (uiWorksheet.getPassword() != null)
+      {
+         settings.setPassword(uiWorksheet.getPassword());
+      }
+      if (uiWorksheet.getPasswordHash() != null)
+      {
+         settings.setPasswordHash(uiWorksheet.getPasswordHash());
+      }
+      if (uiWorksheet.getPrintGridLines() != null)
+      {
+         settings.setPrintGridLines(uiWorksheet.getPrintGridLines());
+      }
+      if (uiWorksheet.getPrintHeaders() != null)
+      {
+         settings.setPrintHeaders(uiWorksheet.getPrintHeaders());
+      }
+      if (uiWorksheet.getSheetProtected() != null)
+      {
+         settings.setProtected(uiWorksheet.getSheetProtected());
+      }
+      if (uiWorksheet.getRecalculateFormulasBeforeSave() != null)
+      {
+         settings.setRecalculateFormulasBeforeSave(uiWorksheet.getRecalculateFormulasBeforeSave());
+      }
+      if (uiWorksheet.getRightMargin() != null)
+      {
+         settings.setRightMargin(uiWorksheet.getRightMargin());
+      }
+      if (uiWorksheet.getScaleFactor() != null)
+      {
+         settings.setScaleFactor(uiWorksheet.getScaleFactor());
+      }
+      if (uiWorksheet.getSelected() != null)
+      {
+         settings.setSelected(uiWorksheet.getSelected());
+      }
+      if (uiWorksheet.getShowGridLines() != null)
+      {
+         settings.setShowGridLines(uiWorksheet.getShowGridLines());
+      }
+      if (uiWorksheet.getTopMargin() != null)
+      {
+         settings.setTopMargin(uiWorksheet.getTopMargin());
+      }
+      if (uiWorksheet.getVerticalCentre() != null)
+      {
+         settings.setVerticalCentre(uiWorksheet.getVerticalCentre());
+      }
+      if (uiWorksheet.getVerticalFreeze() != null)
+      {
+         settings.setVerticalFreeze(uiWorksheet.getVerticalFreeze());
+      }
+      if (uiWorksheet.getVerticalPrintResolution() != null)
+      {
+         settings.setVerticalPrintResolution(uiWorksheet.getVerticalPrintResolution());
+      }
+      if (uiWorksheet.getZoomFactor() != null)
+      {
+         settings.setZoomFactor(uiWorksheet.getZoomFactor());
+      }
+      // Iterates through the worksheet uiWorksheet child elements (print areas,
+      // print titles and headers/footers)
+      for (UIComponent child : uiWorksheet.getChildren())
+      {
+         if (child.getClass() == UIPrintArea.class)
+         {
+            UIPrintArea printArea = (UIPrintArea) child;
+            settings.setPrintArea(printArea.getFirstColumn(), printArea.getFirstRow(), printArea.getLastColumn(), printArea.getLastRow());
+         }
+         else if (child.getClass() == UIPrintTitles.class)
+         {
+            UIPrintTitles printTitles = (UIPrintTitles) child;
+            settings.setPrintTitles(printTitles.getFirstCol(), printTitles.getFirstRow(), printTitles.getLastCol(), printTitles.getLastRow());
+         }
+         else if (child.getClass() == UIHeaderFooter.class)
+         {
+            UIHeaderFooter headerFooter = (UIHeaderFooter) child;
+            switch (headerFooter.getType())
+            {
+            case header:
+               settings.setHeader(JXLFactory.createHeaderFooter(headerFooter, settings.getHeader()));
+               break;
+            case footer:
+               settings.setFooter(JXLFactory.createHeaderFooter(headerFooter, settings.getFooter()));
+               break;
+            default:
+               throw new ExcelWorkbookException("Header/Footer type " + headerFooter.getType() + " not supported, try [header, footer]");
+            }
+         }
+      }
+   }
+
+   /**
+    * Gets cell info needed for cell creation
+    * 
+    * @param uiCell The cell to get info for
+    * @return The cell info
+    */
+   protected CellInfo getCellInfo(UICell uiCell)
+   {
+      CellInfo cellInfo = new CellInfo();
+      cellInfo.setCellFeatures(createCellFeatures(uiCell));
+      cellInfo.setCellType(getCellDataType(uiCell));
+      cellInfo.setCellFormat(getCellFormat(uiCell));
+      return cellInfo;
+   }
+
+   /**
+    * Creates cell features from a template
+    * 
+    * @param uiCellFormat The cell format to apply
+    * @return The cell features
+    */
+   public WritableCellFeatures createCellFeatures(UICellBase uiCellFormat)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating cell features for #0", uiCellFormat);
+      }
+      WritableCellFeatures cellFeatures = new WritableCellFeatures();
+
+      if (uiCellFormat.getComment() != null)
+      {
+         if (uiCellFormat.getCommentHeight() != null && uiCellFormat.getCommentWidth() != null)
+         {
+            cellFeatures.setComment(uiCellFormat.getComment(), uiCellFormat.getCommentWidth(), uiCellFormat.getCommentHeight());
+         }
+         else
+         {
+            cellFeatures.setComment(uiCellFormat.getComment());
+         }
+      }
+      List<Validation> validations = ExcelComponent.getChildrenOfType(uiCellFormat.getChildren(), Validation.class);
+      for (Validation validation : validations)
+      {
+         switch (validation.getType())
+         {
+         case numeric:
+            addNumericValidation(cellFeatures, (UINumericValidation) validation);
+            break;
+         case range:
+            addRangeValidation(cellFeatures, (UIRangeValidation) validation);
+            break;
+         case list:
+            addListValidation(cellFeatures, (UIListValidation) validation);
+            break;
+         default:
+            throw new ExcelWorkbookException(Interpolator.instance().interpolate("Unknown validation type {0}", validation.getType()));
+         }
+      }
+      return cellFeatures;
+   }
+
+   /**
+    * Gets the cell type for a cell. Tries to look it up in a cache based on the
+    * component id of the cell. If it's not found, it's created and cached.
+    * 
+    * @param uiCell The cell to look up
+    * @return The data type of a cell
+    */
+   private CellType getCellDataType(UICell uiCell)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Getting cell data type from cache for #0", uiCell.getId());
+      }
+      CellType cellDataType = cellInfoCache.getCachedCellType(uiCell.getId());
+      if (cellDataType == null)
+      {
+         cellDataType = uiCell.getDataType();
+         cellInfoCache.setCachedCellType(uiCell.getId(), cellDataType);
+      }
+      return cellDataType;
+   }
+
+   /**
+    * Gets a cell format for a cell. Tries to look it up in a cache based on the
+    * component id of the cell. If it's not found, it's created and cached.
+    * 
+    * @param uiCell The cell to format
+    * @return The cell format
+    */
+   private WritableCellFormat getCellFormat(UICell uiCell)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Getting cell format for #0", uiCell.getId());
+      }
+      WritableCellFormat cellFormat = cellInfoCache.getCachedCellFormat(uiCell.getId());
+      if (cellFormat == null)
+      {
+         try
+         {
+            cellFormat = createCellFormat(uiCell);
+         }
+         catch (WriteException e)
+         {
+            throw new ExcelWorkbookException("Could not create cellformat", e);
+         }
+         cellInfoCache.setCachedCellFormat(uiCell.getId(), cellFormat);
+      }
+      return cellFormat;
+   }
+
+   /**
+    * Adds list validation to a cell
+    * 
+    * @param cellFeatures The cell features to add validation to
+    * @param validation The validation to parse
+    */
+   private static void addListValidation(WritableCellFeatures cellFeatures, UIListValidation validation)
+   {
+      List<UIListValidationItem> items = ExcelComponent.getChildrenOfType(validation.getChildren(), UIListValidationItem.class);
+      if (items.isEmpty())
+      {
+         throw new ExcelWorkbookException("No items in validation list");
+      }
+
+      List<String> validations = new ArrayList<String>();
+      for (UIListValidationItem item : items)
+      {
+         validations.add(item.getValue());
+      }
+
+      cellFeatures.setDataValidationList(validations);
+   }
+
+   /**
+    * Adds range validation to a cell
+    * 
+    * @param cellFeatures The cell features to apply the validation to
+    * @param validation The validation to add
+    */
+   private static void addRangeValidation(WritableCellFeatures cellFeatures, UIRangeValidation validation)
+   {
+      if (validation.getStartColumn() == null || validation.getStartRow() == null || validation.getEndColumn() == null || validation.getEndRow() == null)
+      {
+         throw new ExcelWorkbookException("Must set all start/end columns/rows for range validation");
+      }
+
+      cellFeatures.setDataValidationRange(validation.getStartColumn(), validation.getStartRow(), validation.getEndColumn(), validation.getEndRow());
+   }
+
+   private static void addNumericValidation(WritableCellFeatures cellFeatures, UINumericValidation validation)
+   {
+      if (validation.getValue() == null)
+      {
+         throw new ExcelWorkbookException("Must define value in validation");
+      }
+      if ((ValidationCondition.between.equals(validation.getCondition()) || ValidationCondition.not_between.equals(validation.getCondition())) && validation.getValue2() == null)
+      {
+         throw new ExcelWorkbookException("Must define both values in validation for between/not_between");
+      }
+      switch (validation.getCondition())
+      {
+      case equal:
+         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.EQUAL);
+         break;
+      case not_equal:
+         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.NOT_EQUAL);
+         break;
+      case greater_equal:
+         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.GREATER_EQUAL);
+         break;
+      case less_equal:
+         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.LESS_EQUAL);
+         break;
+      case less_than:
+         cellFeatures.setNumberValidation(validation.getValue(), WritableCellFeatures.LESS_THAN);
+         break;
+      case between:
+         cellFeatures.setNumberValidation(validation.getValue(), validation.getValue2(), WritableCellFeatures.BETWEEN);
+         break;
+      case not_between:
+         cellFeatures.setNumberValidation(validation.getValue(), validation.getValue2(), WritableCellFeatures.NOT_BETWEEN);
+         break;
+      }
+   }
+
+   /**
+    * Creates a JExcelAPI cell representation from the given input
+    * 
+    * @param column The row (0-based) to place the cell at
+    * @param row The column (0-based) to place the cell at
+    * @param type The type of cell
+    * @param data The contents of the cell
+    * @param cellFormat The cell format settings of the cell
+    * @return The prepared cell representation
+    * @see <a
+    *      href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/write/WritableCell.html">WritableCell</a>
+    * @since 0.1
+    */
+   public static WritableCell createCell(int column, int row, CellType type, Object data, WritableCellFormat cellFormat)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating cell at (#0,#1) of type #2 with data #2", column, row, type, data);
+      }
+
+      switch (type)
+      {
+      case text:
+         return new Label(column, row, data.toString(), cellFormat);
+      case number:
+         return new jxl.write.Number(column, row, Double.parseDouble(data.toString()), cellFormat);
+      case date:
+         return new DateTime(column, row, (Date) data, cellFormat);
+      case formula:
+         return new Formula(column, row, data.toString(), cellFormat);
+      case bool:
+         return new jxl.write.Boolean(column, row, Boolean.parseBoolean(data.toString()), cellFormat);
+      default:
+         return new Label(column, row, data.toString(), cellFormat);
+      }
+   }
+
+   /**
+    * Creates a JExcelAPI Workbook settings object from the UI counterpart.
+    * Starts with an empty object and adds the setting only if it is non-null
+    * 
+    * @param uiWorkbook The UI element to interpret
+    * @return The created workbook settings
+    */
+   public WorkbookSettings createWorkbookSettings(UIWorkbook uiWorkbook)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Creating workbook settings from #0", uiWorkbook);
+      }
+      WorkbookSettings workbookSettings = new WorkbookSettings();
+      if (uiWorkbook.getArrayGrowSize() != null)
+      {
+         workbookSettings.setArrayGrowSize(uiWorkbook.getArrayGrowSize());
+      }
+      if (uiWorkbook.getAutoFilterDisabled() != null)
+      {
+         workbookSettings.setAutoFilterDisabled(uiWorkbook.getAutoFilterDisabled());
+      }
+      if (uiWorkbook.getAutoFilterDisabled() != null)
+      {
+         workbookSettings.setCellValidationDisabled(uiWorkbook.getAutoFilterDisabled());
+      }
+      if (uiWorkbook.getCharacterSet() != null)
+      {
+         workbookSettings.setCharacterSet(uiWorkbook.getCharacterSet());
+      }
+      if (uiWorkbook.getDrawingsDisabled() != null)
+      {
+         workbookSettings.setDrawingsDisabled(uiWorkbook.getDrawingsDisabled());
+      }
+      if (uiWorkbook.getEncoding() != null)
+      {
+         workbookSettings.setEncoding(uiWorkbook.getEncoding());
+      }
+      if (uiWorkbook.getExcelDisplayLanguage() != null)
+      {
+         workbookSettings.setExcelDisplayLanguage(uiWorkbook.getExcelDisplayLanguage());
+      }
+      if (uiWorkbook.getExcelRegionalSettings() != null)
+      {
+         workbookSettings.setExcelRegionalSettings(uiWorkbook.getExcelRegionalSettings());
+      }
+      if (uiWorkbook.getFormulaAdjust() != null)
+      {
+         workbookSettings.setFormulaAdjust(uiWorkbook.getFormulaAdjust());
+      }
+      if (uiWorkbook.getGcDisabled() != null)
+      {
+         workbookSettings.setGCDisabled(uiWorkbook.getGcDisabled());
+      }
+      if (uiWorkbook.getIgnoreBlanks() != null)
+      {
+         workbookSettings.setIgnoreBlanks(uiWorkbook.getIgnoreBlanks());
+      }
+      if (uiWorkbook.getLocale() != null)
+      {
+         workbookSettings.setLocale(new Locale(uiWorkbook.getLocale()));
+      }
+      if (uiWorkbook.getMergedCellCheckingDisabled() != null)
+      {
+         workbookSettings.setMergedCellChecking(uiWorkbook.getMergedCellCheckingDisabled());
+      }
+      if (uiWorkbook.getNamesDisabled() != null)
+      {
+         workbookSettings.setNamesDisabled(uiWorkbook.getNamesDisabled());
+      }
+      if (uiWorkbook.getPropertySets() != null)
+      {
+         workbookSettings.setPropertySets(uiWorkbook.getPropertySets());
+      }
+      if (uiWorkbook.getRationalization() != null)
+      {
+         workbookSettings.setRationalization(uiWorkbook.getRationalization());
+      }
+      if (uiWorkbook.getSupressWarnings() != null)
+      {
+         workbookSettings.setSuppressWarnings(uiWorkbook.getSupressWarnings());
+      }
+      if (uiWorkbook.getTemporaryFileDuringWriteDirectory() != null)
+      {
+         workbookSettings.setTemporaryFileDuringWriteDirectory(new File(uiWorkbook.getTemporaryFileDuringWriteDirectory()));
+      }
+      if (uiWorkbook.getUseTemporaryFileDuringWrite() != null)
+      {
+         workbookSettings.setUseTemporaryFileDuringWrite(uiWorkbook.getUseTemporaryFileDuringWrite());
+      }
+      return workbookSettings;
+   }
+
+   /**
+    * Applies column settings to a column
+    * 
+    * @param uiColumn The settings to apply
+    * @param worksheet The worksheet to apply the column to
+    * @param columnIndex The column index to the column
+    */
+   public void applyColumnSettings(UIColumn uiColumn, WritableSheet worksheet, int columnIndex)
+   {
+      ColumnStyle columnStyle = new ColumnStyle(parser.getCascadedStyleMap(uiColumn));
+      
+      if (log.isTraceEnabled())
+      {
+         log.trace("Applying column settings #0 on column #1", columnStyle, columnIndex);
+      }
+      CellView cellView = worksheet.getColumnView(columnIndex);
+      if (columnStyle.autoSize != null)
+      {
+         cellView.setAutosize(columnStyle.autoSize);
+      }
+      if (columnStyle.hidden != null)
+      {
+         cellView.setHidden(columnStyle.hidden);
+      }
+      if (columnStyle.width != null)
+      {
+         cellView.setSize(columnStyle.width);
+      }
+      worksheet.setColumnView(columnIndex, cellView);
+   }
+
+}

Deleted: trunk/src/excel/org/jboss/seam/excel/jxl/JXLTemplates.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/JXLTemplates.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/JXLTemplates.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,317 +0,0 @@
-package org.jboss.seam.excel.jxl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import jxl.SheetSettings;
-import jxl.write.WritableCellFeatures;
-import jxl.write.WritableCellFormat;
-import jxl.write.WritableSheet;
-import jxl.write.WriteException;
-
-import org.jboss.seam.core.Interpolator;
-import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.Template;
-import org.jboss.seam.excel.ui.UICell;
-import org.jboss.seam.excel.ui.UICellFormat;
-import org.jboss.seam.excel.ui.UICellTemplate;
-import org.jboss.seam.excel.ui.UIWorksheet;
-import org.jboss.seam.excel.ui.UIWorksheetSettings;
-import org.jboss.seam.excel.ui.UIWorksheetTemplate;
-import org.jboss.seam.excel.ui.UICell.CellType;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.log.Logging;
-
-/**
- * A helper class that is used to cache and merge the cell format templates
- * 
- * @author nik
- * @since 0.2
- */
-public class JXLTemplates
-{
-   private Log log = Logging.getLog(getClass());
-
-   // The separator char for the cells templates-attribute
-   private static final String TEMPLATE_SEPARATOR_CHAR = ",";
-
-   // The cache of known cell templates
-   private Map<String, UICellTemplate> cellTemplates = new HashMap<String, UICellTemplate>();
-
-   // The cache of known worksheet templates
-   private Map<String, UIWorksheetTemplate> worksheetTemplates = new HashMap<String, UIWorksheetTemplate>();
-
-   // A cache for cell types, mapped by UIComponent ID
-   private Map<String, CellType> cellDataTypeCache = new HashMap<String, CellType>();
-
-   // A cache for cell formattings, mapped by UIComponent ID
-   private Map<String, WritableCellFormat> cellFormatCache = new HashMap<String, WritableCellFormat>();
-
-   // A cache for cell features, mapped by UIComponent ID
-   @SuppressWarnings("unused")
-   private Map<String, WritableCellFeatures> cellFeaturesCache = new HashMap<String, WritableCellFeatures>();
-
-   /**
-    * A class that collects information needed for cell creation
-    * 
-    * @author Nicklas Karlsson (nickarls at gmail.com)
-    */
-   protected class CellInfo
-   {
-      // Cell format of the cell
-      private WritableCellFormat cellFormat;
-
-      // Cell features of the cell
-      private WritableCellFeatures cellFeatures;
-
-      // Cell contents type of the cell
-      private CellType cellType;
-
-      public CellType getCellType()
-      {
-         return cellType;
-      }
-
-      public void setCellType(CellType cellType)
-      {
-         this.cellType = cellType;
-      }
-
-      public WritableCellFormat getCellFormat()
-      {
-         return cellFormat;
-      }
-
-      public WritableCellFeatures getCellFeatures()
-      {
-         return cellFeatures;
-      }
-
-      public void setCellFormat(WritableCellFormat cellFormat)
-      {
-         this.cellFormat = cellFormat;
-      }
-
-      public void setCellFeatures(WritableCellFeatures cellFeatures)
-      {
-         this.cellFeatures = cellFeatures;
-      }
-   }
-
-   /**
-    * Gets the cell type for a cell. Tries to look it up in a cache based on the
-    * component id of the cell. If it's not found, it's created and cached.
-    * 
-    * @param uiCell The cell to look up
-    * @return The data type of a cell
-    */
-   private CellType getCellDataType(UICell uiCell)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Getting cell data type from cache for #0", uiCell.getId());
-      }
-      CellType cellDataType = cellDataTypeCache.get(uiCell.getId());
-      if (cellDataType == null)
-      {
-         cellDataType = uiCell.getDataType();
-         cellDataTypeCache.put(uiCell.getId(), cellDataType);
-      }
-      return cellDataType;
-   }
-
-   /**
-    * Gets a cell format for a cell. Tries to look it up in a cache based on the
-    * component id of the cell. If it's not found, it's created and cached.
-    * 
-    * @param uiCell The cell to format
-    * @return The cell format
-    */
-   private WritableCellFormat getCellFormat(UICell uiCell)
-   {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Getting cell format for #0", uiCell.getId());
-      }
-      WritableCellFormat cellFormat = cellFormatCache.get(uiCell.getId());
-      if (cellFormat == null)
-      {
-         cellFormat = createCellFormat(uiCell);
-         cellFormatCache.put(uiCell.getId(), cellFormat);
-      }
-      return cellFormat;
-   }
-
-   /**
-    * Gets cell info needed for cell creation
-    * 
-    * @param uiCell The cell to get info for
-    * @return The cell info
-    */
-   protected CellInfo getCellInfo(UICell uiCell)
-   {
-      CellInfo cellInfo = new CellInfo();
-      cellInfo.setCellFeatures(createCellFeatures(uiCell));
-      cellInfo.setCellType(getCellDataType(uiCell));
-      cellInfo.setCellFormat(getCellFormat(uiCell));
-      return cellInfo;
-   }
-
-   /**
-    * Adds a template to the stack
-    * 
-    * @param template The template to add
-    */
-   protected void addTemplate(Template template)
-   {
-      switch (template.getType())
-      {
-      case cell:
-         if (cellTemplates.containsKey(template.getName()))
-         {
-            throw new ExcelWorkbookException(Interpolator.instance().interpolate("The cell template {0} is already registered", template.getName()));
-         }
-         cellTemplates.put(template.getName(), (UICellTemplate) template);
-         break;
-      case worksheet:
-         if (worksheetTemplates.containsKey(template.getName()))
-         {
-            throw new ExcelWorkbookException(Interpolator.instance().interpolate("The worksheet template {0} is already registered", template.getName()));
-         }
-         worksheetTemplates.put(template.getName(), (UIWorksheetTemplate) template);
-         break;
-      default:
-         throw new ExcelWorkbookException(Interpolator.instance().interpolate("Unknown template type {0}", template.getType()));
-      }
-   }
-
-   /**
-    * Merges all cell templates found in the templates attribute of a uiCell to
-    * a single list and appends the cell itself to the end of the list (the last
-    * cascade step)
-    * 
-    * @param uiCell The uiCell to check for templates and merge
-    * @return The list of merged templates
-    */
-   private List<UICellFormat> mergeTemplates(UICell uiCell)
-   {
-      List<UICellFormat> mergeList = new ArrayList<UICellFormat>();
-      if (uiCell.getTemplates() != null)
-      {
-         for (String templateName : uiCell.getTemplates().split(TEMPLATE_SEPARATOR_CHAR))
-         {
-            UICellTemplate cellTemplate = cellTemplates.get(templateName.trim());
-            if (cellTemplate == null)
-            {
-               String validNames = getValidTemplateNames(cellTemplates.keySet());
-               log.trace(Interpolator.instance().interpolate("Could not find cell template {0}, try {1}", templateName, validNames));
-            }
-            else
-            {
-               mergeList.add(cellTemplate);
-            }
-         }
-      }
-      mergeList.add(uiCell);
-      return mergeList;
-   }
-
-   /**
-    * Returns a list of valid template names in case of error
-    * 
-    * @param keys The set of key strings to merge
-    * @return a comma, separated list of registered names
-    */
-   private String getValidTemplateNames(Set<String> keys)
-   {
-      StringBuffer names = new StringBuffer();
-      int i = 0;
-      for (String name : keys)
-      {
-         names.append(i++ == 0 ? name : ", " + name);
-      }
-      return names.toString();
-   }
-
-   /**
-    * Creates cell features for a list from a list of merged templates
-    * 
-    * @param uiCell The cell to use as a last step of cascade
-    * @return The cell features
-    */
-   private WritableCellFeatures createCellFeatures(UICell uiCell)
-   {
-      List<UICellFormat> mergeList = mergeTemplates(uiCell);
-
-      WritableCellFeatures mergedCellFeatures = null;
-      for (UICellFormat mergeCellFeature : mergeList)
-      {
-         mergedCellFeatures = JXLExcelFactory.createCellFeatures(mergeCellFeature, mergedCellFeatures);
-      }
-      return mergedCellFeatures;
-   }
-
-   /**
-    * Creates a cell format for a given cell. Puts all requested template to a
-    * list and merges them
-    * 
-    * @param uiCell The cell to format
-    * @return A cellformat
-    */
-   private WritableCellFormat createCellFormat(UICell uiCell)
-   {
-      List<UICellFormat> mergeList = mergeTemplates(uiCell);
-
-      WritableCellFormat mergedCellFormat = null;
-      for (UICellFormat mergeCellFormat : mergeList)
-      {
-         try
-         {
-            mergedCellFormat = JXLExcelFactory.createCellFormat(mergeCellFormat, mergedCellFormat, uiCell.getDataType());
-         }
-         catch (WriteException e)
-         {
-            throw new ExcelWorkbookException("Could not crete cell format", e);
-         }
-      }
-      return mergedCellFormat;
-   }
-
-   /**
-    * Applies worksheet settings to the active sheet. First merges templates for
-    * settings.
-    * 
-    * @param worksheet The worksheet to apply the settings to
-    * @param uiWorksheet The settings to apply (+ templates)
-    */
-   protected void applyWorksheetSettings(WritableSheet worksheet, UIWorksheet uiWorksheet)
-   {
-      List<UIWorksheetSettings> mergeList = new ArrayList<UIWorksheetSettings>();
-
-      if (uiWorksheet.getTemplates() != null)
-      {
-         for (String templateName : uiWorksheet.getTemplates().split(TEMPLATE_SEPARATOR_CHAR))
-         {
-            UIWorksheetTemplate worksheetTemplate = worksheetTemplates.get(templateName.trim());
-            if (worksheetTemplate == null)
-            {
-               String validNames = getValidTemplateNames(worksheetTemplates.keySet());
-               throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not find worksheet template #0, try [#1]", templateName, validNames));
-            }
-            mergeList.add(worksheetTemplate);
-         }
-      }
-
-      mergeList.add(uiWorksheet);
-
-      SheetSettings oldSettings = worksheet.getSettings();
-      for (UIWorksheetSettings template : mergeList)
-      {
-         JXLExcelFactory.applyWorksheetSettings(oldSettings, template);
-      }
-   }
-
-}

Modified: trunk/src/excel/org/jboss/seam/excel/ui/ExcelComponent.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/ExcelComponent.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/ExcelComponent.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -11,10 +11,9 @@
 import javax.faces.context.ResponseWriter;
 import javax.faces.render.RenderKit;
 
-import org.jboss.seam.excel.Command;
 import org.jboss.seam.excel.ExcelWorkbook;
-import org.jboss.seam.excel.Template;
 import org.jboss.seam.excel.WorksheetItem;
+import org.jboss.seam.excel.ui.command.Command;
 import org.jboss.seam.ui.util.JSF;
 
 /**
@@ -30,7 +29,9 @@
    private static final String DEFAULT_CONTENT_TYPE = "text/html";
    private static final String DEFAULT_CHARACTER_ENCODING = "utf-8";
 
-
+   private String styleClass;
+   private String style;
+   
    /**
     * Helper method for rendering a component (usually on a facescontext with a caching
     * reponsewriter)
@@ -98,17 +99,6 @@
    }
 
    /**
-    * Returns all templates from a child list
-    * 
-    * @param children The list to search
-    * @return The templates
-    */
-   protected static List<Template> getTemplates(List<UIComponent> children)
-   {
-      return getChildrenOfType(children, Template.class);
-   }
-
-   /**
     * Returns all worksheet items (cells, images, hyperlinks) from a child list
     * 
     * @param children The list to search
@@ -171,4 +161,24 @@
       return getParentByClass(root.getParent(), searchClass);
    }
 
+   public String getStyleClass()
+   {
+      return (String) valueOf("styleClass", styleClass);
+   }
+
+   public void setStyleClass(String styleClass)
+   {
+      this.styleClass = styleClass;
+   }
+
+   public String getStyle()
+   {
+      return (String) valueOf("style", style);
+   }
+
+   public void setStyle(String style)
+   {
+      this.style = style;
+   }
+
 }

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIBackground.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIBackground.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIBackground.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,36 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-public class UIBackground extends ExcelComponent
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIBackground";
-
-   private String color;
-   private String pattern;
-
-   public String getColor()
-   {
-      return (String) valueOf("color", color);
-   }
-
-   public void setColor(String color)
-   {
-      this.color = color;
-   }
-
-   public String getPattern()
-   {
-      return (String) valueOf("pattern", pattern);
-   }
-
-   public void setPattern(String pattern)
-   {
-      this.pattern = pattern;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIBorder.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIBorder.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIBorder.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,47 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-public class UIBorder extends ExcelComponent
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIBorder";
-
-   private String border;
-   private String lineStyle;
-   private String color;
-
-   public String getBorder()
-   {
-      return (String) valueOf("border", border);
-   }
-
-   public void setBorder(String border)
-   {
-      this.border = border;
-   }
-
-   public String getLineStyle()
-   {
-      return (String) valueOf("lineStyle", lineStyle);
-   }
-
-   public void setLineStyle(String lineStyle)
-   {
-      this.lineStyle = lineStyle;
-   }
-
-   public String getColor()
-   {
-      return (String) valueOf("color", color);
-   }
-
-   public void setColor(String color)
-   {
-      this.color = color;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-}

Modified: trunk/src/excel/org/jboss/seam/excel/ui/UICell.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UICell.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UICell.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -11,7 +11,7 @@
 import org.jboss.seam.excel.ExcelWorkbookException;
 import org.jboss.seam.excel.WorksheetItem;
 
-public class UICell extends UICellFormat implements WorksheetItem
+public class UICell extends UICellBase implements WorksheetItem
 {
    public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UICell";
 
@@ -24,18 +24,7 @@
    private Object value;
    private Integer column;
    private Integer row;
-   private String templates;
 
-   public String getTemplates()
-   {
-      return (String) valueOf("templates", templates);
-   }
-
-   public void setTemplates(String templates)
-   {
-      this.templates = templates;
-   }
-
    public Integer getColumn()
    {
       return (Integer) valueOf("column", column);

Copied: trunk/src/excel/org/jboss/seam/excel/ui/UICellBase.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UICellFormat.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UICellBase.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UICellBase.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,39 @@
+package org.jboss.seam.excel.ui;
+
+public abstract class UICellBase extends ExcelComponent
+{
+   private String comment;
+   private Integer commentWidth;
+   private Integer commentHeight;
+
+   public String getComment()
+   {
+      return (String) valueOf("comment", comment);
+   }
+
+   public void setComment(String comment)
+   {
+      this.comment = comment;
+   }
+
+   public Integer getCommentWidth()
+   {
+      return (Integer) valueOf("commentWidth", commentWidth);
+   }
+
+   public void setCommentWidth(Integer commentWidth)
+   {
+      this.commentWidth = commentWidth;
+   }
+
+   public Integer getCommentHeight()
+   {
+      return (Integer) valueOf("commentHeight", commentHeight);
+   }
+
+   public void setCommentHeight(Integer commentHeight)
+   {
+      this.commentHeight = commentHeight;
+   }
+
+}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UICellFormat.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UICellFormat.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UICellFormat.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,127 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-public abstract class UICellFormat extends ExcelComponent
-{
-   private String alignment;
-   private String comment;
-   private Integer commentWidth;
-   private Integer commentHeight;
-   private Integer indentation;
-   private Boolean locked;
-   private String mask;
-   private String orientation;
-   private Boolean shrinkToFit;
-   private String verticalAlignment;
-   private Boolean wrap;
-
-   public String getAlignment()
-   {
-      return (String) valueOf("alignment", alignment);
-   }
-
-   public void setAlignment(String alignment)
-   {
-      this.alignment = alignment;
-   }
-
-   public String getComment()
-   {
-      return (String) valueOf("comment", comment);
-   }
-
-   public void setComment(String comment)
-   {
-      this.comment = comment;
-   }
-
-   public Integer getIndentation()
-   {
-      return (Integer) valueOf("indentation", indentation);
-   }
-
-   public void setIndentation(Integer indentation)
-   {
-      this.indentation = indentation;
-   }
-
-   public Boolean getLocked()
-   {
-      return (Boolean) valueOf("locked", locked);
-   }
-
-   public void setLocked(Boolean locked)
-   {
-      this.locked = locked;
-   }
-
-   public String getMask()
-   {
-      return (String) valueOf("mask", mask);
-   }
-
-   public void setMask(String mask)
-   {
-      this.mask = mask;
-   }
-
-   public String getOrientation()
-   {
-      return (String) valueOf("orientation", orientation);
-   }
-
-   public void setOrientation(String orientation)
-   {
-      this.orientation = orientation;
-   }
-
-   public Boolean getShrinkToFit()
-   {
-      return (Boolean) valueOf("shrinkToFit", shrinkToFit);
-   }
-
-   public void setShrinkToFit(Boolean shrinkToFit)
-   {
-      this.shrinkToFit = shrinkToFit;
-   }
-
-   public String getVerticalAlignment()
-   {
-      return (String) valueOf("verticalAlignment", verticalAlignment);
-   }
-
-   public void setVerticalAlignment(String verticalAlignment)
-   {
-      this.verticalAlignment = verticalAlignment;
-   }
-
-   public Boolean getWrap()
-   {
-      return (Boolean) valueOf("wrap", wrap);
-   }
-
-   public void setWrap(Boolean wrap)
-   {
-      this.wrap = wrap;
-   }
-
-   public Integer getCommentWidth()
-   {
-      return (Integer) valueOf("commentWidth", commentWidth);
-   }
-
-   public void setCommentWidth(Integer commentWidth)
-   {
-      this.commentWidth = commentWidth;
-   }
-
-   public Integer getCommentHeight()
-   {
-      return (Integer) valueOf("commentHeight", commentHeight);
-   }
-
-   public void setCommentHeight(Integer commentHeight)
-   {
-      this.commentHeight = commentHeight;
-   }
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UICellTemplate.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UICellTemplate.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UICellTemplate.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,32 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Template;
-
-public class UICellTemplate extends UICellFormat implements Template
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UICellTemplate";
-
-   private String name;
-
-   public String getName()
-   {
-      return (String) valueOf("name", name);
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-   public TemplateType getType()
-   {
-      return TemplateType.cell;
-   }
-
-}

Modified: trunk/src/excel/org/jboss/seam/excel/ui/UIColumn.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIColumn.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIColumn.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -7,10 +7,10 @@
 
 import javax.faces.context.FacesContext;
 
-import org.jboss.seam.excel.Command;
 import org.jboss.seam.excel.ExcelWorkbook;
 import org.jboss.seam.excel.ExcelWorkbookException;
 import org.jboss.seam.excel.WorksheetItem;
+import org.jboss.seam.excel.ui.command.Command;
 
 public class UIColumn extends ExcelComponent
 {
@@ -19,54 +19,6 @@
    public static final String HEADER_FACET_NAME = "header";
    private static final String FOOTER_FACET_NAME = "footer";
 
-   private Boolean autoSize;
-   private Boolean hidden;
-   private Integer width;
-
-   public UIColumn()
-   {
-   }
-
-   /**
-    * Convenience constructor for settings widths through the exporter
-    * 
-    * @param width The column width to set
-    */
-   public UIColumn(Integer width)
-   {
-      this.width = width;
-   }
-
-   public Boolean getAutoSize()
-   {
-      return (Boolean) valueOf("autoSize", autoSize);
-   }
-
-   public void setAutoSize(Boolean autoSize)
-   {
-      this.autoSize = autoSize;
-   }
-
-   public Boolean getHidden()
-   {
-      return (Boolean) valueOf("hidden", hidden);
-   }
-
-   public void setHidden(Boolean hidden)
-   {
-      this.hidden = hidden;
-   }
-
-   public Integer getWidth()
-   {
-      return (Integer) valueOf("width", width);
-   }
-
-   public void setWidth(Integer width)
-   {
-      this.width = width;
-   }
-
    @Override
    public String getFamily()
    {

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIExcelExport.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIExcelExport.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIExcelExport.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,74 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import java.io.IOException;
-
-import javax.faces.component.UIData;
-import javax.faces.component.html.HtmlDataTable;
-import javax.faces.context.FacesContext;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.core.Interpolator;
-import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.exporter.ExcelExporter;
-
-public class UIExcelExport extends ExcelComponent
-{
-
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIExcelExport";
-
-   private String type;
-   private String forDataTable;
-
-   public String getType()
-   {
-      return (String) valueOf("type", type);
-   }
-
-   public void setType(String type)
-   {
-      this.type = type;
-   }
-
-   public String getForDataTable()
-   {
-      return (String) valueOf("forDataTable", forDataTable);
-   }
-
-   public void setForDataTable(String forDataTable)
-   {
-      this.forDataTable = forDataTable;
-   }
-
-   @SuppressWarnings("unchecked")
-   @Override
-   public void encodeBegin(javax.faces.context.FacesContext facesContext) throws IOException
-   {
-      UIData dataTable = (UIData) getParentByClass(getParent(), UIData.class);
-      if (dataTable == null)
-      {
-         if (getForDataTable() == null)
-         {
-            throw new ExcelWorkbookException("Must define forDataTable attribute if tag is not nested within a datatable");
-         }
-         dataTable = (HtmlDataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent(getForDataTable());
-         if (dataTable == null)
-         {
-            throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not find data table with id #0", getForDataTable()));
-         }
-      }
-      ExcelExporter exporter = (ExcelExporter) Component.getInstance(ExcelExporter.class);
-      exporter.export(dataTable.getId(), getType());
-   }
-
-   @Override
-   public void encodeEnd(FacesContext context) throws IOException
-   {
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIFont.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIFont.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIFont.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,106 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-public class UIFont extends ExcelComponent
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIFont";
-
-   private String name;
-   private String color; // TODO: support non-constant colors
-   private Integer pointSize;
-   private Boolean bold;
-   private Boolean italic;
-   private Boolean struckOut;
-   private String scriptStyle;
-   private String underlineStyle;
-
-   public String getName()
-   {
-      return (String) valueOf("name", name);
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public String getColor()
-   {
-      return (String) valueOf("color", color);
-   }
-
-   public void setColor(String color)
-   {
-      this.color = color;
-   }
-
-   public Integer getPointSize()
-   {
-      return (Integer) valueOf("pointSize", pointSize);
-   }
-
-   public void setPointSize(Integer pointSize)
-   {
-      this.pointSize = pointSize;
-   }
-
-   public Boolean getBold()
-   {
-      return (Boolean) valueOf("bold", bold);
-
-   }
-
-   public void setBold(Boolean bold)
-   {
-      this.bold = bold;
-   }
-
-   public Boolean getItalic()
-   {
-      return (Boolean) valueOf("italic", italic);
-
-   }
-
-   public void setItalic(Boolean italic)
-   {
-      this.italic = italic;
-   }
-
-   public Boolean getStruckOut()
-   {
-      return (Boolean) valueOf("struckOut", struckOut);
-
-   }
-
-   public void setStruckOut(Boolean struckOut)
-   {
-      this.struckOut = struckOut;
-   }
-
-   public String getScriptStyle()
-   {
-      return (String) valueOf("scriptStyle", scriptStyle);
-
-   }
-
-   public void setScriptStyle(String scriptStyle)
-   {
-      this.scriptStyle = scriptStyle;
-   }
-
-   public String getUnderlineStyle()
-   {
-      return (String) valueOf("underlineStyle", underlineStyle);
-   }
-
-   public void setUnderlineStyle(String underlineStyle)
-   {
-      this.underlineStyle = underlineStyle;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIGroupColumns.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIGroupColumns.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIGroupColumns.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,54 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Command;
-
-public class UIGroupColumns extends ExcelComponent implements Command
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIGroupColumns";
-
-   private Integer startColumn;
-   private Integer endColumn;
-   private Boolean collapse;
-
-   public Boolean getCollapse()
-   {
-      return (Boolean) valueOf("collapse", collapse);
-   }
-
-   public void setCollapse(Boolean collapse)
-   {
-      this.collapse = collapse;
-   }
-
-   public Integer getStartColumn()
-   {
-      return (Integer) valueOf("startColumn", startColumn);
-   }
-
-   public void setStartColumn(Integer startColumn)
-   {
-      this.startColumn = startColumn;
-   }
-
-   public Integer getEndColumn()
-   {
-      return (Integer) valueOf("endColumn", endColumn);
-   }
-
-   public void setEndColumn(Integer endColumn)
-   {
-      this.endColumn = endColumn;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-   public CommandType getCommandType()
-   {
-      return CommandType.group_columns;
-   }
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIGroupRows.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIGroupRows.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIGroupRows.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,54 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Command;
-
-public class UIGroupRows extends ExcelComponent implements Command
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIGroupRows";
-
-   private Integer startRow;
-   private Integer endRow;
-   private Boolean collapse;
-
-   public Boolean getCollapse()
-   {
-      return (Boolean) valueOf("collapse", collapse);
-   }
-
-   public void setCollapse(Boolean collapse)
-   {
-      this.collapse = collapse;
-   }
-
-   public Integer getStartRow()
-   {
-      return (Integer) valueOf("startRow", startRow);
-   }
-
-   public void setStartRow(Integer startRow)
-   {
-      this.startRow = startRow;
-   }
-
-   public Integer getEndRow()
-   {
-      return (Integer) valueOf("endRow", endRow);
-   }
-
-   public void setEndRow(Integer endRow)
-   {
-      this.endRow = endRow;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-   public CommandType getCommandType()
-   {
-      return CommandType.group_rows;
-   }
-
-}

Modified: trunk/src/excel/org/jboss/seam/excel/ui/UIHyperlink.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIHyperlink.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIHyperlink.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -2,7 +2,7 @@
 
 import org.jboss.seam.excel.WorksheetItem;
 
-public class UIHyperlink extends UICellFormat implements WorksheetItem
+public class UIHyperlink extends UICellBase implements WorksheetItem
 {
    public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIHyperlink";
 

Added: trunk/src/excel/org/jboss/seam/excel/ui/UILink.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UILink.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UILink.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,25 @@
+package org.jboss.seam.excel.ui;
+
+public class UILink extends ExcelComponent
+{
+   private static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UILink";
+   
+   private String URL;
+   
+   public String getURL()
+   {
+      return (String) valueOf("URL", URL);
+   }
+
+   public void setURL(String url)
+   {
+      URL = url;
+   }
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIListValidation.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIListValidation.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIListValidation.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,19 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Validation;
-
-public class UIListValidation extends ExcelComponent implements Validation
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIListValidation";
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-   public ValidationType getType()
-   {
-      return ValidationType.list;
-   }
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIListValidationItem.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIListValidationItem.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIListValidationItem.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,25 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-public class UIListValidationItem extends ExcelComponent
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIListValidationItem";
-
-   private String value;
-
-   public String getValue()
-   {
-      return (String) valueOf("value", value);
-   }
-
-   public void setValue(String value)
-   {
-      this.value = value;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIMergeCells.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIMergeCells.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIMergeCells.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,65 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Command;
-
-public class UIMergeCells extends ExcelComponent implements Command
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIMergeCells";
-
-   private Integer startColumn;
-   private Integer startRow;
-   private Integer endColumn;
-   private Integer endRow;
-
-   public Integer getStartColumn()
-   {
-      return (Integer) valueOf("startColumn", startColumn);
-   }
-
-   public void setStartColumn(Integer startColumn)
-   {
-      this.startColumn = startColumn;
-   }
-
-   public Integer getStartRow()
-   {
-      return (Integer) valueOf("startRow", startRow);
-   }
-
-   public void setStartRow(Integer startRow)
-   {
-      this.startRow = startRow;
-   }
-
-   public Integer getEndColumn()
-   {
-      return (Integer) valueOf("endColumn", endColumn);
-   }
-
-   public void setEndColumn(Integer endColumn)
-   {
-      this.endColumn = endColumn;
-   }
-
-   public Integer getEndRow()
-   {
-      return (Integer) valueOf("endRow", endRow);
-   }
-
-   public void setEndRow(Integer endRow)
-   {
-      this.endRow = endRow;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-   public CommandType getCommandType()
-   {
-      return CommandType.merge_cells;
-   }
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UINumericValidation.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UINumericValidation.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UINumericValidation.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,59 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Validation;
-
-public class UINumericValidation extends ExcelComponent implements Validation
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UINumericValidation";
-
-   public enum ValidationCondition
-   {
-      equal, greater_equal, less_equal, less_than, not_equal, between, not_between
-   }
-
-   private Double value;
-   private Double value2;
-   private ValidationCondition condition;
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-   public Double getValue()
-   {
-      return (Double) valueOf("value", value);
-   }
-
-   public void setValue(Double value)
-   {
-      this.value = value;
-   }
-
-   public Double getValue2()
-   {
-      return (Double) valueOf("value2", value2);
-   }
-
-   public void setValue2(Double value2)
-   {
-      this.value2 = value2;
-   }
-
-   public ValidationCondition getCondition()
-   {
-      return (ValidationCondition) valueOf("condition", condition);
-   }
-
-   public void setCondition(ValidationCondition condition)
-   {
-      this.condition = condition;
-   }
-
-   public ValidationType getType()
-   {
-      return ValidationType.numeric;
-   }
-
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIRangeValidation.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIRangeValidation.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIRangeValidation.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,64 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Validation;
-
-public class UIRangeValidation extends ExcelComponent implements Validation
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIRangeValidation";
-
-   private Integer startColumn;
-   private Integer startRow;
-   private Integer endColumn;
-   private Integer endRow;
-
-   public Integer getStartColumn()
-   {
-      return (Integer) valueOf("startColumn", startColumn);
-   }
-
-   public void setStartColumn(Integer startColumn)
-   {
-      this.startColumn = startColumn;
-   }
-
-   public Integer getStartRow()
-   {
-      return (Integer) valueOf("startRow", startRow);
-   }
-
-   public void setStartRow(Integer startRow)
-   {
-      this.startRow = startRow;
-   }
-
-   public Integer getEndColumn()
-   {
-      return (Integer) valueOf("endColumn", endColumn);
-   }
-
-   public void setEndColumn(Integer endColumn)
-   {
-      this.endColumn = endColumn;
-   }
-
-   public Integer getEndRow()
-   {
-      return (Integer) valueOf("endRow", endRow);
-   }
-
-   public void setEndRow(Integer endRow)
-   {
-      this.endRow = endRow;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-   public ValidationType getType()
-   {
-      return ValidationType.range;
-   }
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIRowPageBreak.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIRowPageBreak.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIRowPageBreak.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,32 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Command;
-
-public class UIRowPageBreak extends ExcelComponent implements Command
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIRowPageBreak";
-
-   private Integer row;
-
-   public Integer getRow()
-   {
-      return (Integer) valueOf("row", row);
-   }
-
-   public void setRow(Integer row)
-   {
-      this.row = row;
-   }
-
-   public CommandType getCommandType()
-   {
-      return CommandType.add_row_pagebreak;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-}

Modified: trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,18 +1,19 @@
 package org.jboss.seam.excel.ui;
 
 import java.io.IOException;
+import java.util.List;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.ValueHolder;
 import javax.faces.context.FacesContext;
 
+import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.core.Manager;
 import org.jboss.seam.document.DocumentData;
 import org.jboss.seam.document.DocumentStore;
 import org.jboss.seam.document.DocumentData.DocumentType;
 import org.jboss.seam.excel.ExcelFactory;
 import org.jboss.seam.excel.ExcelWorkbook;
-import org.jboss.seam.excel.Template;
 import org.jboss.seam.navigation.Pages;
 
 public class UIWorkbook extends ExcelComponent
@@ -49,7 +50,18 @@
    private String temporaryFileDuringWriteDirectory;
    private Boolean useTemporaryFileDuringWrite;
    private Boolean workbookProtected;
+   private String exportKey;
 
+   public String getExportKey()
+   {
+      return (String) valueOf("exportKey", exportKey);
+   }
+
+   public void setExportKey(String exportKey)
+   {
+      this.exportKey = exportKey;
+   }
+
    public CreationType getCreationType()
    {
       if (hasSettings())
@@ -287,13 +299,9 @@
 
       // Create a new workbook
       excelWorkbook.createWorkbook(this);
-
-      // Find global templates and push them to workbook
-      for (Template template : getTemplates(getChildren()))
-      {
-         excelWorkbook.addTemplate(template);
-      }
-
+      
+      List<UILink> stylesheets = getChildrenOfType(getChildren(), UILink.class);
+      excelWorkbook.setStylesheets(stylesheets);
    }
 
    @Override
@@ -314,6 +322,11 @@
 
       DocumentData documentData = new DocumentData(baseName, type, bytes);
 
+      if (getExportKey() != null) {
+         Contexts.getEventContext().set(getExportKey(), documentData);
+         return;
+      }
+      
       if (sendRedirect)
       {
          DocumentStore store = DocumentStore.instance();

Modified: trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheet.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheet.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheet.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -8,13 +8,13 @@
 
 import javax.faces.model.DataModel;
 
-import org.jboss.seam.excel.Command;
 import org.jboss.seam.excel.ExcelWorkbook;
 import org.jboss.seam.excel.ExcelWorkbookException;
 import org.jboss.seam.excel.WorksheetItem;
+import org.jboss.seam.excel.ui.command.Command;
 import org.jboss.seam.framework.Query;
 
-public class UIWorksheet extends UIWorksheetSettings
+public class UIWorksheet extends ExcelComponent
 {
    public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIWorksheet";
 
@@ -26,8 +26,415 @@
    private Object value;
    private Integer startRow;
    private Integer startColumn;
-   private String templates;
+   private Boolean automaticFormulaCalculation;
+   private Double bottomMargin;
+   private Integer copies;
+   private Integer defaultColumnWidth;
+   private Integer defaultRowHeight;
+   private Boolean displayZeroValues;
+   private Integer fitHeight;
+   private Boolean fitToPages;
+   private Integer fitWidth;
+   private Double footerMargin;
+   private Double headerMargin;
+   private Boolean hidden;
+   private Boolean horizontalCentre;
+   private Integer horizontalFreeze;
+   private Integer horizontalPrintResolution;
+   private Double leftMargin;
+   private Integer normalMagnification;
+   private String orientation;
+   private Integer pageBreakPreviewMagnification;
+   private Boolean pageBreakPreviewMode;
+   private Integer pageStart;
+   private String paperSize;
+   private String password;
+   private Integer passwordHash;
+   private Boolean printGridLines;
+   private Boolean printHeaders;
+   private Boolean sheetProtected;
+   private Boolean recalculateFormulasBeforeSave;
+   private Double rightMargin;
+   private Integer scaleFactor;
+   private Boolean selected;
+   private Boolean showGridLines;
+   private Double topMargin;
+   private Boolean verticalCentre;
+   private Integer verticalFreeze;
+   private Integer verticalPrintResolution;
+   private Integer zoomFactor;
 
+   public Boolean getAutomaticFormulaCalculation()
+   {
+      return (Boolean) valueOf("automaticFormulaCalculation", automaticFormulaCalculation);
+   }
+
+   public void setAutomaticFormulaCalculation(Boolean automaticFormulaCalculation)
+   {
+      this.automaticFormulaCalculation = automaticFormulaCalculation;
+   }
+
+   public Double getBottomMargin()
+   {
+      return (Double) valueOf("bottomMargin", bottomMargin);
+   }
+
+   public void setBottomMargin(Double bottomMargin)
+   {
+      this.bottomMargin = bottomMargin;
+   }
+
+   public Integer getCopies()
+   {
+      return (Integer) valueOf("copies", copies);
+   }
+
+   public void setCopies(Integer copies)
+   {
+      this.copies = copies;
+   }
+
+   public Integer getDefaultColumnWidth()
+   {
+      return (Integer) valueOf("defaultColumnWidth", defaultColumnWidth);
+   }
+
+   public void setDefaultColumnWidth(Integer defaultColumnWidth)
+   {
+      this.defaultColumnWidth = defaultColumnWidth;
+   }
+
+   public Integer getDefaultRowHeight()
+   {
+      return (Integer) valueOf("defaultRowHeight", defaultRowHeight);
+   }
+
+   public void setDefaultRowHeight(Integer defaultRowHeight)
+   {
+      this.defaultRowHeight = defaultRowHeight;
+   }
+
+   public Boolean getDisplayZeroValues()
+   {
+      return (Boolean) valueOf("displayZeroValues", displayZeroValues);
+   }
+
+   public void setDisplayZeroValues(Boolean displayZeroValues)
+   {
+      this.displayZeroValues = displayZeroValues;
+   }
+
+   public Integer getFitHeight()
+   {
+      return (Integer) valueOf("fitHeight", fitHeight);
+   }
+
+   public void setFitHeight(Integer fitHeight)
+   {
+      this.fitHeight = fitHeight;
+   }
+
+   public Boolean getFitToPages()
+   {
+      return (Boolean) valueOf("fitToPages", fitToPages);
+   }
+
+   public void setFitToPages(Boolean fitToPages)
+   {
+      this.fitToPages = fitToPages;
+   }
+
+   public Integer getFitWidth()
+   {
+      return (Integer) valueOf("fitWidth", fitWidth);
+   }
+
+   public void setFitWidth(Integer fitWidth)
+   {
+      this.fitWidth = fitWidth;
+   }
+
+   public Double getFooterMargin()
+   {
+      return (Double) valueOf("footerMargin", footerMargin);
+   }
+
+   public void setFooterMargin(Double footerMargin)
+   {
+      this.footerMargin = footerMargin;
+   }
+
+   public Double getHeaderMargin()
+   {
+      return (Double) valueOf("headerMargin", headerMargin);
+   }
+
+   public void setHeaderMargin(Double headerMargin)
+   {
+      this.headerMargin = headerMargin;
+   }
+
+   public Boolean getHidden()
+   {
+      return (Boolean) valueOf("hidden", hidden);
+   }
+
+   public void setHidden(Boolean hidden)
+   {
+      this.hidden = hidden;
+   }
+
+   public Boolean getHorizontalCentre()
+   {
+      return (Boolean) valueOf("horizontalCentre", horizontalCentre);
+   }
+
+   public void setHorizontalCentre(Boolean horizontalCentre)
+   {
+      this.horizontalCentre = horizontalCentre;
+   }
+
+   public Integer getHorizontalFreeze()
+   {
+      return (Integer) valueOf("horizontalFreeze", horizontalFreeze);
+   }
+
+   public void setHorizontalFreeze(Integer horizontalFreeze)
+   {
+      this.horizontalFreeze = horizontalFreeze;
+   }
+
+   public Integer getHorizontalPrintResolution()
+   {
+      return (Integer) valueOf("horizontalPrintResolution", horizontalPrintResolution);
+   }
+
+   public void setHorizontalPrintResolution(Integer horizontalPrintResolution)
+   {
+      this.horizontalPrintResolution = horizontalPrintResolution;
+   }
+
+   public Double getLeftMargin()
+   {
+      return (Double) valueOf("leftMargin", leftMargin);
+   }
+
+   public void setLeftMargin(Double leftMargin)
+   {
+      this.leftMargin = leftMargin;
+   }
+
+   public Integer getNormalMagnification()
+   {
+      return (Integer) valueOf("normalMagnification", normalMagnification);
+   }
+
+   public void setNormalMagnification(Integer normalMagnification)
+   {
+      this.normalMagnification = normalMagnification;
+   }
+
+   public String getOrientation()
+   {
+      return (String) valueOf("orientation", orientation);
+   }
+
+   public void setOrientation(String orientation)
+   {
+      this.orientation = orientation;
+   }
+
+   public Integer getPageBreakPreviewMagnification()
+   {
+      return (Integer) valueOf("pageBreakPreviewMagnification", pageBreakPreviewMagnification);
+   }
+
+   public void setPageBreakPreviewMagnification(Integer pageBreakPreviewMagnification)
+   {
+      this.pageBreakPreviewMagnification = pageBreakPreviewMagnification;
+   }
+
+   public Integer getPageStart()
+   {
+      return (Integer) valueOf("pageStart", pageStart);
+   }
+
+   public void setPageStart(Integer pageStart)
+   {
+      this.pageStart = pageStart;
+   }
+
+   public String getPaperSize()
+   {
+      return (String) valueOf("paperSize", paperSize);
+   }
+
+   public void setPaperSize(String paperSize)
+   {
+      this.paperSize = paperSize;
+   }
+
+   public String getPassword()
+   {
+      return (String) valueOf("password", password);
+   }
+
+   public void setPassword(String password)
+   {
+      this.password = password;
+   }
+
+   public Integer getPasswordHash()
+   {
+      return (Integer) valueOf("passwordHash", passwordHash);
+   }
+
+   public void setPasswordHash(Integer passwordHash)
+   {
+      this.passwordHash = passwordHash;
+   }
+
+   public Boolean getPrintGridLines()
+   {
+      return (Boolean) valueOf("printGridLines", printGridLines);
+   }
+
+   public void setPrintGridLines(Boolean printGridLines)
+   {
+      this.printGridLines = printGridLines;
+   }
+
+   public Boolean getPrintHeaders()
+   {
+      return (Boolean) valueOf("printHeaders", printHeaders);
+   }
+
+   public void setPrintHeaders(Boolean printHeaders)
+   {
+      this.printHeaders = printHeaders;
+   }
+
+   public Boolean getSheetProtected()
+   {
+      return (Boolean) valueOf("sheetProtected", sheetProtected);
+   }
+
+   public void setSheetProtected(Boolean sheetProtected)
+   {
+      this.sheetProtected = sheetProtected;
+   }
+
+   public Boolean getRecalculateFormulasBeforeSave()
+   {
+      return (Boolean) valueOf("recalculateFormulasBeforeSave", recalculateFormulasBeforeSave);
+   }
+
+   public void setRecalculateFormulasBeforeSave(Boolean recalculateFormulasBeforeSave)
+   {
+      this.recalculateFormulasBeforeSave = recalculateFormulasBeforeSave;
+   }
+
+   public Double getRightMargin()
+   {
+      return (Double) valueOf("rightMargin", rightMargin);
+   }
+
+   public void setRightMargin(Double rightMargin)
+   {
+      this.rightMargin = rightMargin;
+   }
+
+   public Boolean getSelected()
+   {
+      return (Boolean) valueOf("selected", selected);
+   }
+
+   public void setSelected(Boolean selected)
+   {
+      this.selected = selected;
+   }
+
+   public Boolean getShowGridLines()
+   {
+      return (Boolean) valueOf("showGridLines", showGridLines);
+   }
+
+   public void setShowGridLines(Boolean showGridLines)
+   {
+      this.showGridLines = showGridLines;
+   }
+
+   public Double getTopMargin()
+   {
+      return (Double) valueOf("topMargin", topMargin);
+   }
+
+   public void setTopMargin(Double topMargin)
+   {
+      this.topMargin = topMargin;
+   }
+
+   public Boolean getVerticalCentre()
+   {
+      return (Boolean) valueOf("verticalCentre", verticalCentre);
+   }
+
+   public void setVerticalCentre(Boolean verticalCentre)
+   {
+      this.verticalCentre = verticalCentre;
+   }
+
+   public Integer getVerticalFreeze()
+   {
+      return (Integer) valueOf("verticalFreeze", verticalFreeze);
+   }
+
+   public void setVerticalFreeze(Integer verticalFreeze)
+   {
+      this.verticalFreeze = verticalFreeze;
+   }
+
+   public Integer getVerticalPrintResolution()
+   {
+      return (Integer) valueOf("verticalPrintResolution", verticalPrintResolution);
+   }
+
+   public void setVerticalPrintResolution(Integer verticalPrintResolution)
+   {
+      this.verticalPrintResolution = verticalPrintResolution;
+   }
+
+   public Integer getZoomFactor()
+   {
+      return (Integer) valueOf("zoomFactor", zoomFactor);
+   }
+
+   public void setZoomFactor(Integer zoomFactor)
+   {
+      this.zoomFactor = zoomFactor;
+   }
+
+   public Boolean getPageBreakPreviewMode()
+   {
+      return (Boolean) valueOf("pageBreakPreviewMode", pageBreakPreviewMode);
+   }
+
+   public void setPageBreakPreviewMode(Boolean pageBreakPreviewMode)
+   {
+      this.pageBreakPreviewMode = pageBreakPreviewMode;
+   }
+
+   public Integer getScaleFactor()
+   {
+      return (Integer) valueOf("scaleFactor", scaleFactor);
+   }
+
+   public void setScaleFactor(Integer scaleFactor)
+   {
+      this.scaleFactor = scaleFactor;
+   }
+   
+
    public Integer getStartRow()
    {
       return (Integer) valueOf("startRow", startRow);
@@ -84,16 +491,6 @@
       this.value = value;
    }
 
-   public void setTemplates(String templates)
-   {
-      this.templates = templates;
-   }
-
-   public String getTemplates()
-   {
-      return (String) valueOf("templates", templates);
-   }
-
    @Override
    public void encodeBegin(javax.faces.context.FacesContext facesContext) throws java.io.IOException
    {

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetSettings.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetSettings.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetSettings.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,420 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-public class UIWorksheetSettings extends ExcelComponent
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIWorksheetSettings";
-
-   private Boolean automaticFormulaCalculation;
-   private Double bottomMargin;
-   private Integer copies;
-   private Integer defaultColumnWidth;
-   private Integer defaultRowHeight;
-   private Boolean displayZeroValues;
-   private Integer fitHeight;
-   private Boolean fitToPages;
-   private Integer fitWidth;
-   private Double footerMargin;
-   private Double headerMargin;
-   private Boolean hidden;
-   private Boolean horizontalCentre;
-   private Integer horizontalFreeze;
-   private Integer horizontalPrintResolution;
-   private Double leftMargin;
-   private Integer normalMagnification;
-   private String orientation;
-   private Integer pageBreakPreviewMagnification;
-   private Boolean pageBreakPreviewMode;
-   private Integer pageStart;
-   private String paperSize;
-   private String password;
-   private Integer passwordHash;
-   private Boolean printGridLines;
-   private Boolean printHeaders;
-   private Boolean sheetProtected;
-   private Boolean recalculateFormulasBeforeSave;
-   private Double rightMargin;
-   private Integer scaleFactor;
-   private Boolean selected;
-   private Boolean showGridLines;
-   private Double topMargin;
-   private Boolean verticalCentre;
-   private Integer verticalFreeze;
-   private Integer verticalPrintResolution;
-   private Integer zoomFactor;
-
-   public Boolean getAutomaticFormulaCalculation()
-   {
-      return (Boolean) valueOf("automaticFormulaCalculation", automaticFormulaCalculation);
-   }
-
-   public void setAutomaticFormulaCalculation(Boolean automaticFormulaCalculation)
-   {
-      this.automaticFormulaCalculation = automaticFormulaCalculation;
-   }
-
-   public Double getBottomMargin()
-   {
-      return (Double) valueOf("bottomMargin", bottomMargin);
-   }
-
-   public void setBottomMargin(Double bottomMargin)
-   {
-      this.bottomMargin = bottomMargin;
-   }
-
-   public Integer getCopies()
-   {
-      return (Integer) valueOf("copies", copies);
-   }
-
-   public void setCopies(Integer copies)
-   {
-      this.copies = copies;
-   }
-
-   public Integer getDefaultColumnWidth()
-   {
-      return (Integer) valueOf("defaultColumnWidth", defaultColumnWidth);
-   }
-
-   public void setDefaultColumnWidth(Integer defaultColumnWidth)
-   {
-      this.defaultColumnWidth = defaultColumnWidth;
-   }
-
-   public Integer getDefaultRowHeight()
-   {
-      return (Integer) valueOf("defaultRowHeight", defaultRowHeight);
-   }
-
-   public void setDefaultRowHeight(Integer defaultRowHeight)
-   {
-      this.defaultRowHeight = defaultRowHeight;
-   }
-
-   public Boolean getDisplayZeroValues()
-   {
-      return (Boolean) valueOf("displayZeroValues", displayZeroValues);
-   }
-
-   public void setDisplayZeroValues(Boolean displayZeroValues)
-   {
-      this.displayZeroValues = displayZeroValues;
-   }
-
-   public Integer getFitHeight()
-   {
-      return (Integer) valueOf("fitHeight", fitHeight);
-   }
-
-   public void setFitHeight(Integer fitHeight)
-   {
-      this.fitHeight = fitHeight;
-   }
-
-   public Boolean getFitToPages()
-   {
-      return (Boolean) valueOf("fitToPages", fitToPages);
-   }
-
-   public void setFitToPages(Boolean fitToPages)
-   {
-      this.fitToPages = fitToPages;
-   }
-
-   public Integer getFitWidth()
-   {
-      return (Integer) valueOf("fitWidth", fitWidth);
-   }
-
-   public void setFitWidth(Integer fitWidth)
-   {
-      this.fitWidth = fitWidth;
-   }
-
-   public Double getFooterMargin()
-   {
-      return (Double) valueOf("footerMargin", footerMargin);
-   }
-
-   public void setFooterMargin(Double footerMargin)
-   {
-      this.footerMargin = footerMargin;
-   }
-
-   public Double getHeaderMargin()
-   {
-      return (Double) valueOf("headerMargin", headerMargin);
-   }
-
-   public void setHeaderMargin(Double headerMargin)
-   {
-      this.headerMargin = headerMargin;
-   }
-
-   public Boolean getHidden()
-   {
-      return (Boolean) valueOf("hidden", hidden);
-   }
-
-   public void setHidden(Boolean hidden)
-   {
-      this.hidden = hidden;
-   }
-
-   public Boolean getHorizontalCentre()
-   {
-      return (Boolean) valueOf("horizontalCentre", horizontalCentre);
-   }
-
-   public void setHorizontalCentre(Boolean horizontalCentre)
-   {
-      this.horizontalCentre = horizontalCentre;
-   }
-
-   public Integer getHorizontalFreeze()
-   {
-      return (Integer) valueOf("horizontalFreeze", horizontalFreeze);
-   }
-
-   public void setHorizontalFreeze(Integer horizontalFreeze)
-   {
-      this.horizontalFreeze = horizontalFreeze;
-   }
-
-   public Integer getHorizontalPrintResolution()
-   {
-      return (Integer) valueOf("horizontalPrintResolution", horizontalPrintResolution);
-   }
-
-   public void setHorizontalPrintResolution(Integer horizontalPrintResolution)
-   {
-      this.horizontalPrintResolution = horizontalPrintResolution;
-   }
-
-   public Double getLeftMargin()
-   {
-      return (Double) valueOf("leftMargin", leftMargin);
-   }
-
-   public void setLeftMargin(Double leftMargin)
-   {
-      this.leftMargin = leftMargin;
-   }
-
-   public Integer getNormalMagnification()
-   {
-      return (Integer) valueOf("normalMagnification", normalMagnification);
-   }
-
-   public void setNormalMagnification(Integer normalMagnification)
-   {
-      this.normalMagnification = normalMagnification;
-   }
-
-   public String getOrientation()
-   {
-      return (String) valueOf("orientation", orientation);
-   }
-
-   public void setOrientation(String orientation)
-   {
-      this.orientation = orientation;
-   }
-
-   public Integer getPageBreakPreviewMagnification()
-   {
-      return (Integer) valueOf("pageBreakPreviewMagnification", pageBreakPreviewMagnification);
-   }
-
-   public void setPageBreakPreviewMagnification(Integer pageBreakPreviewMagnification)
-   {
-      this.pageBreakPreviewMagnification = pageBreakPreviewMagnification;
-   }
-
-   public Integer getPageStart()
-   {
-      return (Integer) valueOf("pageStart", pageStart);
-   }
-
-   public void setPageStart(Integer pageStart)
-   {
-      this.pageStart = pageStart;
-   }
-
-   public String getPaperSize()
-   {
-      return (String) valueOf("paperSize", paperSize);
-   }
-
-   public void setPaperSize(String paperSize)
-   {
-      this.paperSize = paperSize;
-   }
-
-   public String getPassword()
-   {
-      return (String) valueOf("password", password);
-   }
-
-   public void setPassword(String password)
-   {
-      this.password = password;
-   }
-
-   public Integer getPasswordHash()
-   {
-      return (Integer) valueOf("passwordHash", passwordHash);
-   }
-
-   public void setPasswordHash(Integer passwordHash)
-   {
-      this.passwordHash = passwordHash;
-   }
-
-   public Boolean getPrintGridLines()
-   {
-      return (Boolean) valueOf("printGridLines", printGridLines);
-   }
-
-   public void setPrintGridLines(Boolean printGridLines)
-   {
-      this.printGridLines = printGridLines;
-   }
-
-   public Boolean getPrintHeaders()
-   {
-      return (Boolean) valueOf("printHeaders", printHeaders);
-   }
-
-   public void setPrintHeaders(Boolean printHeaders)
-   {
-      this.printHeaders = printHeaders;
-   }
-
-   public Boolean getSheetProtected()
-   {
-      return (Boolean) valueOf("sheetProtected", sheetProtected);
-   }
-
-   public void setSheetProtected(Boolean sheetProtected)
-   {
-      this.sheetProtected = sheetProtected;
-   }
-
-   public Boolean getRecalculateFormulasBeforeSave()
-   {
-      return (Boolean) valueOf("recalculateFormulasBeforeSave", recalculateFormulasBeforeSave);
-   }
-
-   public void setRecalculateFormulasBeforeSave(Boolean recalculateFormulasBeforeSave)
-   {
-      this.recalculateFormulasBeforeSave = recalculateFormulasBeforeSave;
-   }
-
-   public Double getRightMargin()
-   {
-      return (Double) valueOf("rightMargin", rightMargin);
-   }
-
-   public void setRightMargin(Double rightMargin)
-   {
-      this.rightMargin = rightMargin;
-   }
-
-   public Boolean getSelected()
-   {
-      return (Boolean) valueOf("selected", selected);
-   }
-
-   public void setSelected(Boolean selected)
-   {
-      this.selected = selected;
-   }
-
-   public Boolean getShowGridLines()
-   {
-      return (Boolean) valueOf("showGridLines", showGridLines);
-   }
-
-   public void setShowGridLines(Boolean showGridLines)
-   {
-      this.showGridLines = showGridLines;
-   }
-
-   public Double getTopMargin()
-   {
-      return (Double) valueOf("topMargin", topMargin);
-   }
-
-   public void setTopMargin(Double topMargin)
-   {
-      this.topMargin = topMargin;
-   }
-
-   public Boolean getVerticalCentre()
-   {
-      return (Boolean) valueOf("verticalCentre", verticalCentre);
-   }
-
-   public void setVerticalCentre(Boolean verticalCentre)
-   {
-      this.verticalCentre = verticalCentre;
-   }
-
-   public Integer getVerticalFreeze()
-   {
-      return (Integer) valueOf("verticalFreeze", verticalFreeze);
-   }
-
-   public void setVerticalFreeze(Integer verticalFreeze)
-   {
-      this.verticalFreeze = verticalFreeze;
-   }
-
-   public Integer getVerticalPrintResolution()
-   {
-      return (Integer) valueOf("verticalPrintResolution", verticalPrintResolution);
-   }
-
-   public void setVerticalPrintResolution(Integer verticalPrintResolution)
-   {
-      this.verticalPrintResolution = verticalPrintResolution;
-   }
-
-   public Integer getZoomFactor()
-   {
-      return (Integer) valueOf("zoomFactor", zoomFactor);
-   }
-
-   public void setZoomFactor(Integer zoomFactor)
-   {
-      this.zoomFactor = zoomFactor;
-   }
-
-   public Boolean getPageBreakPreviewMode()
-   {
-      return (Boolean) valueOf("pageBreakPreviewMode", pageBreakPreviewMode);
-   }
-
-   public void setPageBreakPreviewMode(Boolean pageBreakPreviewMode)
-   {
-      this.pageBreakPreviewMode = pageBreakPreviewMode;
-   }
-
-   public Integer getScaleFactor()
-   {
-      return (Integer) valueOf("scaleFactor", scaleFactor);
-   }
-
-   public void setScaleFactor(Integer scaleFactor)
-   {
-      this.scaleFactor = scaleFactor;
-   }
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-}

Deleted: trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetTemplate.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetTemplate.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetTemplate.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,32 +0,0 @@
-package org.jboss.seam.excel.ui;
-
-import org.jboss.seam.excel.Template;
-
-public class UIWorksheetTemplate extends UIWorksheetSettings implements Template
-{
-   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.UIWorksheetTemplate";
-
-   private String name;
-
-   @Override
-   public String getFamily()
-   {
-      return COMPONENT_TYPE;
-   }
-
-   public String getName()
-   {
-      return (String) valueOf("name", name);
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public TemplateType getType()
-   {
-      return TemplateType.worksheet;
-   }
-
-}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/command/Command.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/Command.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/command/Command.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/command/Command.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,11 @@
+package org.jboss.seam.excel.ui.command;
+
+public interface Command
+{
+   public enum CommandType
+   {
+      merge_cells, add_row_pagebreak, group_rows, group_columns
+   }
+
+   public abstract CommandType getCommandType();
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupColumns.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UIGroupColumns.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupColumns.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupColumns.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,54 @@
+package org.jboss.seam.excel.ui.command;
+
+import org.jboss.seam.excel.ui.ExcelComponent;
+
+public class UIGroupColumns extends ExcelComponent implements Command
+{
+   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.command.UIGroupColumns";
+
+   private Integer startColumn;
+   private Integer endColumn;
+   private Boolean collapse;
+
+   public Boolean getCollapse()
+   {
+      return (Boolean) valueOf("collapse", collapse);
+   }
+
+   public void setCollapse(Boolean collapse)
+   {
+      this.collapse = collapse;
+   }
+
+   public Integer getStartColumn()
+   {
+      return (Integer) valueOf("startColumn", startColumn);
+   }
+
+   public void setStartColumn(Integer startColumn)
+   {
+      this.startColumn = startColumn;
+   }
+
+   public Integer getEndColumn()
+   {
+      return (Integer) valueOf("endColumn", endColumn);
+   }
+
+   public void setEndColumn(Integer endColumn)
+   {
+      this.endColumn = endColumn;
+   }
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+   public CommandType getCommandType()
+   {
+      return CommandType.group_columns;
+   }
+
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupRows.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UIGroupRows.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupRows.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupRows.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,54 @@
+package org.jboss.seam.excel.ui.command;
+
+import org.jboss.seam.excel.ui.ExcelComponent;
+
+public class UIGroupRows extends ExcelComponent implements Command
+{
+   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.command.UIGroupRows";
+
+   private Integer startRow;
+   private Integer endRow;
+   private Boolean collapse;
+
+   public Boolean getCollapse()
+   {
+      return (Boolean) valueOf("collapse", collapse);
+   }
+
+   public void setCollapse(Boolean collapse)
+   {
+      this.collapse = collapse;
+   }
+
+   public Integer getStartRow()
+   {
+      return (Integer) valueOf("startRow", startRow);
+   }
+
+   public void setStartRow(Integer startRow)
+   {
+      this.startRow = startRow;
+   }
+
+   public Integer getEndRow()
+   {
+      return (Integer) valueOf("endRow", endRow);
+   }
+
+   public void setEndRow(Integer endRow)
+   {
+      this.endRow = endRow;
+   }
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+   public CommandType getCommandType()
+   {
+      return CommandType.group_rows;
+   }
+
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/command/UIMergeCells.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UIMergeCells.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/command/UIMergeCells.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/command/UIMergeCells.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,65 @@
+package org.jboss.seam.excel.ui.command;
+
+import org.jboss.seam.excel.ui.ExcelComponent;
+
+public class UIMergeCells extends ExcelComponent implements Command
+{
+   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.command.UIMergeCells";
+
+   private Integer startColumn;
+   private Integer startRow;
+   private Integer endColumn;
+   private Integer endRow;
+
+   public Integer getStartColumn()
+   {
+      return (Integer) valueOf("startColumn", startColumn);
+   }
+
+   public void setStartColumn(Integer startColumn)
+   {
+      this.startColumn = startColumn;
+   }
+
+   public Integer getStartRow()
+   {
+      return (Integer) valueOf("startRow", startRow);
+   }
+
+   public void setStartRow(Integer startRow)
+   {
+      this.startRow = startRow;
+   }
+
+   public Integer getEndColumn()
+   {
+      return (Integer) valueOf("endColumn", endColumn);
+   }
+
+   public void setEndColumn(Integer endColumn)
+   {
+      this.endColumn = endColumn;
+   }
+
+   public Integer getEndRow()
+   {
+      return (Integer) valueOf("endRow", endRow);
+   }
+
+   public void setEndRow(Integer endRow)
+   {
+      this.endRow = endRow;
+   }
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+   public CommandType getCommandType()
+   {
+      return CommandType.merge_cells;
+   }
+
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/command/UIRowPageBreak.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UIRowPageBreak.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/command/UIRowPageBreak.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/command/UIRowPageBreak.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,32 @@
+package org.jboss.seam.excel.ui.command;
+
+import org.jboss.seam.excel.ui.ExcelComponent;
+
+public class UIRowPageBreak extends ExcelComponent implements Command
+{
+   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.command.UIRowPageBreak";
+
+   private Integer row;
+
+   public Integer getRow()
+   {
+      return (Integer) valueOf("row", row);
+   }
+
+   public void setRow(Integer row)
+   {
+      this.row = row;
+   }
+
+   public CommandType getCommandType()
+   {
+      return CommandType.add_row_pagebreak;
+   }
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidation.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UIListValidation.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidation.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidation.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,19 @@
+package org.jboss.seam.excel.ui.validation;
+
+import org.jboss.seam.excel.ui.ExcelComponent;
+
+public class UIListValidation extends ExcelComponent implements Validation
+{
+   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.validation.UIListValidation";
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+   public ValidationType getType()
+   {
+      return ValidationType.list;
+   }
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidationItem.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UIListValidationItem.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidationItem.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidationItem.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,27 @@
+package org.jboss.seam.excel.ui.validation;
+
+import org.jboss.seam.excel.ui.ExcelComponent;
+
+public class UIListValidationItem extends ExcelComponent
+{
+   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.validation.UIListValidationItem";
+
+   private String value;
+
+   public String getValue()
+   {
+      return (String) valueOf("value", value);
+   }
+
+   public void setValue(String value)
+   {
+      this.value = value;
+   }
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/validation/UINumericValidation.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UINumericValidation.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/validation/UINumericValidation.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/validation/UINumericValidation.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,59 @@
+package org.jboss.seam.excel.ui.validation;
+
+import org.jboss.seam.excel.ui.ExcelComponent;
+
+public class UINumericValidation extends ExcelComponent implements Validation
+{
+   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.validation.UINumericValidation";
+
+   public enum ValidationCondition
+   {
+      equal, greater_equal, less_equal, less_than, not_equal, between, not_between
+   }
+
+   private Double value;
+   private Double value2;
+   private ValidationCondition condition;
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+   public Double getValue()
+   {
+      return (Double) valueOf("value", value);
+   }
+
+   public void setValue(Double value)
+   {
+      this.value = value;
+   }
+
+   public Double getValue2()
+   {
+      return (Double) valueOf("value2", value2);
+   }
+
+   public void setValue2(Double value2)
+   {
+      this.value2 = value2;
+   }
+
+   public ValidationCondition getCondition()
+   {
+      return (ValidationCondition) valueOf("condition", condition);
+   }
+
+   public void setCondition(ValidationCondition condition)
+   {
+      this.condition = condition;
+   }
+
+   public ValidationType getType()
+   {
+      return ValidationType.numeric;
+   }
+
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/validation/UIRangeValidation.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/ui/UIRangeValidation.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/validation/UIRangeValidation.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/validation/UIRangeValidation.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,64 @@
+package org.jboss.seam.excel.ui.validation;
+
+import org.jboss.seam.excel.ui.ExcelComponent;
+
+public class UIRangeValidation extends ExcelComponent implements Validation
+{
+   public static final String COMPONENT_TYPE = "org.jboss.seam.excel.ui.validation.UIRangeValidation";
+
+   private Integer startColumn;
+   private Integer startRow;
+   private Integer endColumn;
+   private Integer endRow;
+
+   public Integer getStartColumn()
+   {
+      return (Integer) valueOf("startColumn", startColumn);
+   }
+
+   public void setStartColumn(Integer startColumn)
+   {
+      this.startColumn = startColumn;
+   }
+
+   public Integer getStartRow()
+   {
+      return (Integer) valueOf("startRow", startRow);
+   }
+
+   public void setStartRow(Integer startRow)
+   {
+      this.startRow = startRow;
+   }
+
+   public Integer getEndColumn()
+   {
+      return (Integer) valueOf("endColumn", endColumn);
+   }
+
+   public void setEndColumn(Integer endColumn)
+   {
+      this.endColumn = endColumn;
+   }
+
+   public Integer getEndRow()
+   {
+      return (Integer) valueOf("endRow", endRow);
+   }
+
+   public void setEndRow(Integer endRow)
+   {
+      this.endRow = endRow;
+   }
+
+   @Override
+   public String getFamily()
+   {
+      return COMPONENT_TYPE;
+   }
+
+   public ValidationType getType()
+   {
+      return ValidationType.range;
+   }
+}

Copied: trunk/src/excel/org/jboss/seam/excel/ui/validation/Validation.java (from rev 8899, trunk/src/excel/org/jboss/seam/excel/Validation.java)
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/validation/Validation.java	                        (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/ui/validation/Validation.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,11 @@
+package org.jboss.seam.excel.ui.validation;
+
+public interface Validation
+{
+   public enum ValidationType
+   {
+      numeric, range, list
+   }
+
+   public abstract ValidationType getType();
+}

Deleted: trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelCellFactoryTest.java
===================================================================
--- trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelCellFactoryTest.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelCellFactoryTest.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,38 +0,0 @@
-package org.jboss.seam.test.excel.unit;
-        
-import jxl.format.Colour;
-import jxl.write.WritableCellFormat;
-import jxl.write.WriteException;
-
-import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.jxl.JXLExcelFactory;
-import org.jboss.seam.excel.ui.UICell;
-import org.jboss.seam.excel.ui.UIFont;
-import org.jboss.seam.excel.ui.UICell.CellType;
-import org.testng.annotations.Test;
-
- at Test
-public class JXLExcelCellFactoryTest
-{
-
-   public void getRedFontColor() throws WriteException {
-      UICell cell = new UICell();
-      UIFont font = new UIFont();
-      font.setColor("red");
-      cell.getChildren().add(font);
-      WritableCellFormat cellFormat = JXLExcelFactory.createCellFormat(cell, null, CellType.text);
-      assert cellFormat.getFont().getColour() == Colour.RED;
-   }
-   
-   @Test(expectedExceptions=ExcelWorkbookException.class)
-   public void getBadFontColor() throws WriteException {
-      UICell cell = new UICell();
-      UIFont font = new UIFont();
-      font.setColor("poo");
-      cell.getChildren().add(font);
-      @SuppressWarnings("unused")
-      WritableCellFormat cellFormat = JXLExcelFactory.createCellFormat(cell, null, CellType.text);
-      assert false;
-   }
-   
-}

Deleted: trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelWorkbookTest.java
===================================================================
--- trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelWorkbookTest.java	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelWorkbookTest.java	2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,443 +0,0 @@
-package org.jboss.seam.test.excel.unit;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import jxl.Workbook;
-import jxl.format.BoldStyle;
-import jxl.format.Border;
-import jxl.format.BorderLineStyle;
-import jxl.format.Colour;
-
-import org.jboss.seam.document.DocumentData;
-import org.jboss.seam.excel.ExcelWorkbook;
-import org.jboss.seam.excel.ExcelWorkbookException;
-import org.jboss.seam.excel.jxl.JXLExcelWorkbook;
-import org.jboss.seam.excel.ui.UIBorder;
-import org.jboss.seam.excel.ui.UICell;
-import org.jboss.seam.excel.ui.UICellTemplate;
-import org.jboss.seam.excel.ui.UIColumn;
-import org.jboss.seam.excel.ui.UIFont;
-import org.jboss.seam.excel.ui.UIHeaderFooter;
-import org.jboss.seam.excel.ui.UIHeaderFooterCommand;
-import org.jboss.seam.excel.ui.UIHeaderFooterCommands;
-import org.jboss.seam.excel.ui.UIHyperlink;
-import org.jboss.seam.excel.ui.UIImage;
-import org.jboss.seam.excel.ui.UIListValidation;
-import org.jboss.seam.excel.ui.UIListValidationItem;
-import org.jboss.seam.excel.ui.UIMergeCells;
-import org.jboss.seam.excel.ui.UINumericValidation;
-import org.jboss.seam.excel.ui.UIRangeValidation;
-import org.jboss.seam.excel.ui.UIWorkbook;
-import org.jboss.seam.excel.ui.UIWorksheet;
-import org.jboss.seam.excel.ui.UIWorksheetTemplate;
-import org.jboss.seam.excel.ui.UIHeaderFooter.Type;
-import org.jboss.seam.excel.ui.UIHeaderFooterCommand.Command;
-import org.jboss.seam.excel.ui.UINumericValidation.ValidationCondition;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
- at Test
-public class JXLExcelWorkbookTest
-{
-   ExcelWorkbook excelWorkbook;
-   Workbook workbook;
-   ByteArrayInputStream ins;
-
-   public void testApplyColumnSettings()
-   {
-      UIColumn column = new UIColumn();
-      column.setWidth(1000);
-      excelWorkbook.applyColumnSettings(column);
-      flushWorkbook();
-      assert workbook.getSheet(0).getColumnView(0).getSize() == 1000;
-
-   }
-
-   public void testMergeCellCommand()
-   {
-      UIMergeCells c = new UIMergeCells();
-      c.setStartColumn(1);
-      c.setStartRow(1);
-      c.setEndColumn(5);
-      c.setEndRow(5);
-      excelWorkbook.executeCommand(c);
-      flushWorkbook();
-      assert workbook.getSheet(0).getMergedCells().length == 1;
-      assert workbook.getSheet(0).getMergedCells()[0].getTopLeft().getColumn() == 1;
-      assert workbook.getSheet(0).getMergedCells()[0].getTopLeft().getRow() == 1;
-      assert workbook.getSheet(0).getMergedCells()[0].getBottomRight().getColumn() == 5;
-      assert workbook.getSheet(0).getMergedCells()[0].getBottomRight().getRow() == 5;
-   }
-
-   public void testNumericValidation()
-   {
-      UICell c = new UICell();
-      c.setValue(5);
-      UINumericValidation v = new UINumericValidation();
-      v.setCondition(ValidationCondition.greater_equal);
-      v.setValue(10d);
-      c.getChildren().add(v);
-      excelWorkbook.addItem(c);
-      flushWorkbook();
-      // assert workbook.getSheet(0).getCell(0,
-      // 0).getCellFeatures().getDataValidationList().length() == 1;
-   }
-
-   public void testRangeValidation()
-   {
-      UICell c = new UICell();
-      c.setValue(5);
-      UIRangeValidation v = new UIRangeValidation();
-      v.setStartColumn(2);
-      v.setStartRow(2);
-      v.setEndColumn(4);
-      v.setEndRow(4);
-      c.getChildren().add(v);
-      excelWorkbook.addItem(c);
-      flushWorkbook();
-      // assert workbook.getSheet(0).getCell(0,
-      // 0).getCellFeatures().getDataValidationList().length() == 1;
-   }
-
-   public void testListValidation()
-   {
-      UICell c = new UICell();
-      c.setValue("foo");
-      UIListValidation v = new UIListValidation();
-      UIListValidationItem i = new UIListValidationItem();
-      i.setValue("foo");
-      UIListValidationItem i2 = new UIListValidationItem();
-      i2.setValue("bar");
-      v.getChildren().add(i);
-      v.getChildren().add(i2);
-      c.getChildren().add(v);
-      excelWorkbook.addItem(c);
-      flushWorkbook();
-      // assert workbook.getSheet(0).getCell(0,
-      // 0).getCellFeatures().getDataValidationList().length() == 1;
-   }
-
-   public void testHeaderCommand()
-   {
-      UIWorksheet w = new UIWorksheet();
-      UIHeaderFooterCommands hfc = new UIHeaderFooterCommands();
-      UIHeaderFooterCommand c = new UIHeaderFooterCommand();
-      c.setCommand(Command.time);
-      hfc.getChildren().add(c);
-      UIHeaderFooter hf = new UIHeaderFooter();
-      hf.setType(Type.header);
-      hf.getFacets().put("left", hfc);
-      w.getChildren().add(hf);
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      excelWorkbook.createOrSelectWorksheet(w);
-      flushWorkbook();
-      assert !workbook.getSheet(0).getSettings().getHeader().getLeft().empty();
-   }
-
-   public void testApplyWorksheetSettings() throws IOException
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      UIWorksheet uiWorksheet = new UIWorksheet();
-      uiWorksheet.setCopies(5);
-      excelWorkbook.createOrSelectWorksheet(uiWorksheet);
-      flushWorkbook();
-      assert workbook.getSheet(0).getSettings().getCopies() == 5;
-   }
-
-   @Test(expectedExceptions = ExcelWorkbookException.class)
-   public void testApplyColumnSettingsOnNoWorksheet()
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      excelWorkbook.applyColumnSettings(new UIColumn());
-      assert false;
-   }
-
-   @Test(expectedExceptions = ExcelWorkbookException.class)
-   public void testAddWorksheetOnNoWorkbook()
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createOrSelectWorksheet(new UIWorksheet());
-      assert false;
-   }
-
-   public void testCreateWorkSheetWithNullParameters()
-   {
-      flushWorkbook();
-      assert workbook.getSheets().length == 1;
-      assert workbook.getSheetNames()[0].equals("Sheet1");
-   }
-
-   public void testCreateWorksheetWithName()
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      UIWorksheet uiWorksheet = new UIWorksheet();
-      uiWorksheet.setName("Test");
-      excelWorkbook.createOrSelectWorksheet(uiWorksheet);
-      flushWorkbook();
-      assert workbook.getSheets().length == 1;
-      assert workbook.getSheetNames()[0].equals("Test");
-   }
-
-   public void testAddCell()
-   {
-      UICell uiCell = new UICell();
-      uiCell.setValue("ping");
-      excelWorkbook.addItem(uiCell);
-      flushWorkbook();
-      assert workbook.getSheet(0).getCell(0, 0).getContents().equals("ping");
-   }
-
-//   public void testAddImage()
-//   {
-//      UIImage image = new UIImage();
-//      image.setURI("file:////seam.gif");
-//      excelWorkbook.addItem(image);
-//      flushWorkbook();
-//      assert workbook.getSheet(0).getDrawing(0) != null;
-//   }
-
-   public void testAddHyperlink()
-   {
-      UIHyperlink link = new UIHyperlink();
-      link.setURL("http://www.seamframework.org");
-      excelWorkbook.addItem(link);
-      flushWorkbook();
-      assert workbook.getSheet(0).getHyperlinks().length == 1;
-      assert workbook.getSheet(0).getHyperlinks()[0].getURL().getProtocol().equals("http");
-      assert workbook.getSheet(0).getHyperlinks()[0].getURL().getHost().equals("www.seamframework.org");
-      assert workbook.getSheet(0).getHyperlinks()[0].getColumn() == 0;
-      assert workbook.getSheet(0).getHyperlinks()[0].getRow() == 0;
-   }
-
-   public void testAddTargettedCell()
-   {
-      UICell uiCell = new UICell();
-      uiCell.setValue("ping");
-      uiCell.setColumn(10);
-      uiCell.setRow(10);
-      excelWorkbook.addItem(uiCell);
-      flushWorkbook();
-      assert workbook.getSheet(0).getCell(10, 10).getContents().equals("ping");
-   }
-
-//   public void testComment()
-//   {
-//      UICell uiCell = new UICell();
-//      uiCell.setComment("comment!");
-//      excelWorkbook.addItem(uiCell);
-//      flushWorkbook();
-//      assert workbook.getSheet(0).getCell(0, 0).getCellFeatures().getComment().equals("comment!");
-//   }
-
-   public void testAddMultipleCells()
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      UIWorksheet uiWorksheet = new UIWorksheet();
-      uiWorksheet.setStartColumn(10);
-      uiWorksheet.setStartRow(10);
-      excelWorkbook.createOrSelectWorksheet(uiWorksheet);
-      UICell uiCell = new UICell();
-      uiCell.setValue("ping");
-      excelWorkbook.addItem(uiCell);
-      uiCell.setValue("pong");
-      excelWorkbook.addItem(uiCell);
-      flushWorkbook();
-      assert workbook.getSheet(0).getCell(10, 10).getContents().equals("ping");
-      assert workbook.getSheet(0).getCell(10, 11).getContents().equals("pong");
-   }
-
-   public void testNextColumn()
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      UIWorksheet uiWorksheet = new UIWorksheet();
-      uiWorksheet.setStartColumn(10);
-      uiWorksheet.setStartRow(10);
-      excelWorkbook.createOrSelectWorksheet(uiWorksheet);
-      UICell uiCell = new UICell();
-      uiCell.setValue("ping");
-      excelWorkbook.addItem(uiCell);
-      excelWorkbook.nextColumn();
-      UICell uiCell2 = new UICell();
-      uiCell2.setValue("pong");
-      excelWorkbook.addItem(uiCell2);
-      flushWorkbook();
-      assert workbook.getSheet(0).getCell(10, 10).getContents().equals("ping");
-      assert workbook.getSheet(0).getCell(11, 10).getContents().equals("pong");
-   }
-
-   public void testDocumentType()
-   {
-      DocumentData.DocumentType documentType = excelWorkbook.getDocumentType();
-      assert documentType.getExtension().equals("xls");
-      assert documentType.getMimeType().equals("application/vnd.ms-excel");
-   }
-
-   public void testSelectWorksheet()
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      UIWorksheet uiWorksheet = new UIWorksheet();
-      uiWorksheet.setStartColumn(10);
-      uiWorksheet.setStartRow(10);
-      uiWorksheet.setName("first");
-      excelWorkbook.createOrSelectWorksheet(uiWorksheet);
-      UICell uiCell = new UICell();
-      uiCell.setValue("ping");
-      excelWorkbook.addItem(uiCell);
-      UIWorksheet uiWorksheet2 = new UIWorksheet();
-      uiWorksheet2.setStartColumn(10);
-      uiWorksheet2.setStartRow(10);
-      uiWorksheet2.setName("second");
-      excelWorkbook.createOrSelectWorksheet(uiWorksheet2);
-      excelWorkbook.createOrSelectWorksheet(uiWorksheet);
-      uiCell.setValue("pong");
-      excelWorkbook.addItem(uiCell);
-      flushWorkbook();
-      assert workbook.getSheets().length == 2;
-      assert workbook.getSheet(0).getCell(10, 10).getContents().equals("pong");
-   }
-
-   public void testCascadingWorksheetSettings()
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-
-      UIWorksheetTemplate t = new UIWorksheetTemplate();
-      t.setName("a");
-      t.setCopies(5);
-      UIHeaderFooterCommands hfc1 = new UIHeaderFooterCommands();
-      UIHeaderFooterCommand c1 = new UIHeaderFooterCommand();
-      c1.setCommand(Command.time);
-      hfc1.getChildren().add(c1);
-      UIHeaderFooter hf1 = new UIHeaderFooter();
-      hf1.setType(Type.header);
-      hf1.getFacets().put("right", hfc1);
-      t.getChildren().add(hf1);
-      excelWorkbook.addTemplate(t);
-
-      UIWorksheetTemplate t2 = new UIWorksheetTemplate();
-      t2.setName("b");
-      t2.setFitWidth(666);
-      UIHeaderFooterCommands hfc2 = new UIHeaderFooterCommands();
-      UIHeaderFooterCommand c2 = new UIHeaderFooterCommand();
-      c2.setCommand(Command.time);
-      hfc2.getChildren().add(c2);
-      UIHeaderFooter hf2 = new UIHeaderFooter();
-      hf2.setType(Type.header);
-      hf2.getFacets().put("center", hfc2);
-      t2.getChildren().add(hf2);
-      excelWorkbook.addTemplate(t2);
-
-      UIWorksheet s = new UIWorksheet();
-      s.setFitHeight(333);
-      s.setTemplates("a,b");
-      UIHeaderFooterCommands hfc3 = new UIHeaderFooterCommands();
-      UIHeaderFooterCommand c3 = new UIHeaderFooterCommand();
-      c3.setCommand(Command.time);
-      hfc3.getChildren().add(c3);
-      UIHeaderFooter hf3 = new UIHeaderFooter();
-      hf3.setType(Type.header);
-      hf3.getFacets().put("left", hfc3);
-      s.getChildren().add(hf3);
-
-      excelWorkbook.createOrSelectWorksheet(s);
-      flushWorkbook();
-      assert workbook.getSheet(0).getSettings().getCopies() == 5;
-      assert workbook.getSheet(0).getSettings().getFitWidth() == 666;
-      assert workbook.getSheet(0).getSettings().getFitHeight() == 333;
-      assert !workbook.getSheet(0).getSettings().getHeader().getLeft().empty();
-      assert !workbook.getSheet(0).getSettings().getHeader().getCentre().empty();
-      assert !workbook.getSheet(0).getSettings().getHeader().getRight().empty();
-   }
-
-   public void testCascadingCellTemplate()
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      excelWorkbook.createOrSelectWorksheet(new UIWorksheet());
-
-      UICellTemplate t = new UICellTemplate();
-      UIFont f = new UIFont();
-      f.setBold(true);
-      t.getChildren().add(f);
-      t.setName("a");
-      UIBorder b = new UIBorder();
-      b.setBorder("all");
-      b.setColor("blue");
-      b.setLineStyle("thick");
-      t.getChildren().add(b);
-      excelWorkbook.addTemplate(t);
-
-      UICellTemplate t2 = new UICellTemplate();
-      UIFont f2 = new UIFont();
-      f2.setColor("blue");
-      t2.getChildren().add(f2);
-      t2.setName("b");
-      UIBorder b2 = new UIBorder();
-      b2.setBorder("left");
-      b2.setColor("red");
-      b2.setLineStyle("thin");
-      t.getChildren().add(b2);
-      excelWorkbook.addTemplate(t2);
-
-      UICell c = new UICell();
-      c.setValue("foo");
-      c.setTemplates("a,b");
-      excelWorkbook.addItem(c);
-
-      flushWorkbook();
-
-      assert workbook.getSheet(0).getCell(0, 0).getCellFormat().getFont().getBoldWeight() == BoldStyle.BOLD.getValue();
-      assert workbook.getSheet(0).getCell(0, 0).getCellFormat().getFont().getColour().equals(Colour.BLUE);
-      assert workbook.getSheet(0).getCell(0, 0).getCellFormat().getBorderColour(Border.TOP).equals(Colour.BLUE);
-      assert workbook.getSheet(0).getCell(0, 0).getCellFormat().getBorderLine(Border.TOP).equals(BorderLineStyle.THICK);
-      assert workbook.getSheet(0).getCell(0, 0).getCellFormat().getBorderColour(Border.LEFT).equals(Colour.RED);
-      assert workbook.getSheet(0).getCell(0, 0).getCellFormat().getBorderLine(Border.LEFT).equals(BorderLineStyle.THIN);
-   }
-
-   protected void flushWorkbook()
-   {
-      ins = new ByteArrayInputStream(excelWorkbook.getBytes());
-      try
-      {
-         workbook = Workbook.getWorkbook(ins);
-      }
-      catch (Exception e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   @BeforeMethod
-   public void setup() throws IOException
-   {
-      excelWorkbook = new JXLExcelWorkbook();
-      excelWorkbook.createWorkbook(new UIWorkbook());
-      excelWorkbook.createOrSelectWorksheet(new UIWorksheet());
-   }
-
-   @AfterMethod
-   public void cleanup() throws IOException
-   {
-      if (workbook != null)
-      {
-         workbook.close();
-      }
-      workbook = null;
-      excelWorkbook = null;
-      if (ins != null)
-      {
-         ins.close();
-      }
-      ins = null;
-   }
-
-}

Modified: trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/testng.xml
===================================================================
--- trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/testng.xml	2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/testng.xml	2008-09-10 20:41:17 UTC (rev 8930)
@@ -3,8 +3,6 @@
 <suite name="Seam Mail Unit Testsuite" verbose="2" parallel="false">
    <test name="Seam Unit Tests: Excel">
      <classes>
-       <class name="org.jboss.seam.test.excel.unit.JXLExcelWorkbookTest"/>
-       <class name="org.jboss.seam.test.excel.unit.JXLExcelCellFactoryTest"/>
      </classes>
    </test>
 </suite>




More information about the seam-commits mailing list