[seam-commits] Seam SVN: r10094 - trunk/src/excel/org/jboss/seam/excel/jxl.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Feb 26 16:06:38 EST 2009


Author: nickarls
Date: 2009-02-26 16:06:38 -0500 (Thu, 26 Feb 2009)
New Revision: 10094

Modified:
   trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java
   trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java
Log:
JBSEAM-3976

Modified: trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java	2009-02-26 19:14:39 UTC (rev 10093)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java	2009-02-26 21:06:38 UTC (rev 10094)
@@ -233,11 +233,11 @@
    {
       if (log.isTraceEnabled())
       {
-         log.trace("Looking for constant #0 in class #1", fieldName, className);
+         log.trace("Looking for constant #0 in class #1", fieldName.toUpperCase(), className);
       }
       try
       {
-         return Class.forName(className).getField(fieldName).get(null);
+         return Class.forName(className).getField(fieldName.toUpperCase()).get(null);
       }
       catch (NoSuchFieldException e)
       {

Modified: trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java	2009-02-26 19:14:39 UTC (rev 10093)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java	2009-02-26 21:06:38 UTC (rev 10094)
@@ -72,6 +72,51 @@
    private CellInfoCache cellInfoCache = new CellInfoCache();
 
    /**
+    * Tries to get a general display format (number first, then date)
+    *  
+    * @param formatMask The format mask to attempt
+    * 
+    * @return The format mask (or null if not possible)
+    */
+   private DisplayFormat getGenericDisplayFormat(String formatMask) {
+        if (formatMask == null) 
+        {
+            return null;
+        }
+        DisplayFormat displayFormat = JXLFactory.createNumberFormat(formatMask);
+        if (displayFormat != null) 
+        {
+            return displayFormat;
+        }
+        displayFormat = JXLFactory.createDateFormat(formatMask);
+        if (displayFormat != null) 
+        {
+            return displayFormat;
+        }
+        try 
+        {
+            displayFormat = new NumberFormat(formatMask);
+        } 
+        catch (IllegalArgumentException e) 
+        {
+            // no-op, it was worth a try;
+        }
+        if (displayFormat != null) 
+        {
+            return displayFormat;
+        }
+        try 
+        {
+            displayFormat = new DateFormat(formatMask);
+        } 
+        catch (IllegalArgumentException e) 
+        {
+            // no-op, it was worth a try;
+        }
+        return displayFormat;
+    }
+   
+   /**
     * Creates a cell format
     * 
     * @param uiCell The cell to model
@@ -153,7 +198,8 @@
          }
          break;
       case formula:
-         cellFormat = new WritableCellFormat();
+         DisplayFormat displayFormat = getGenericDisplayFormat(cellStyle.formatMask); 
+         cellFormat = displayFormat != null ? new WritableCellFormat(displayFormat) : new WritableCellFormat();
          break;
       case bool:
          cellFormat = new WritableCellFormat();




More information about the seam-commits mailing list