← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1228: Applied wrap text and decimal format into Excel Reporting module

 

------------------------------------------------------------
revno: 1228
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2009-12-15 16:02:24 +0700
message:
  Applied wrap text and decimal format into Excel Reporting module
modified:
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/manager/DefaultInitializePOIStylesManager.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/manager/InitializePOIStylesManager.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java	2009-12-11 07:21:36 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java	2009-12-15 09:02:24 +0000
@@ -348,24 +348,24 @@
 
         initPOIStylesManager.initCellStyle( csNumber, csFont, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR,
             this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR,
-            this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_RIGHT );
+            this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_RIGHT, false );
         initPOIStylesManager.initCellStyle( csFormula, csFont11Bold, this.CELLSTYLE_BORDER,
             this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER,
             this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR,
-            this.CELLSTYLE_ALIGN_RIGHT );
+            this.CELLSTYLE_ALIGN_RIGHT, true );
         initPOIStylesManager.initCellStyle( csText10Bold, csFont10Bold, this.CELLSTYLE_BORDER,
             this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER,
-            this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_LEFT );
+            this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_LEFT, true );
         initPOIStylesManager.initCellStyle( csTextSerial, csFont, this.CELLSTYLE_BORDER,
             this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER,
-            this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_CENTER );
+            this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_CENTER, false );
         initPOIStylesManager.initCellStyle( csTextICDJustify, csFont, this.CELLSTYLE_BORDER,
             this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER,
             this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR,
-            this.CELLSTYLE_ALIGN_JUSTIFY );
+            this.CELLSTYLE_ALIGN_JUSTIFY, false );
         initPOIStylesManager.initCellStyle( csText12BoldCenter, csFont12BoldCenter, this.CELLSTYLE_BORDER,
             this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER,
-            this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_CENTER );
+            this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_CENTER, true );
 
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java	2009-12-07 09:03:49 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java	2009-12-15 09:02:24 +0000
@@ -329,12 +329,12 @@
                     if ( bFormula )
                     {
                         STRUCTURE_DATA_RESPONSE.append( "<![CDATA["
-                            + StringUtils.checkingNumberDecimal( recalculatedValue ) + "]]>" );
+                            + StringUtils.applyPatternDecimalFormat( recalculatedValue ) + "]]>" );
                     }
                     else
                     {
                         STRUCTURE_DATA_RESPONSE.append( "<![CDATA["
-                            + StringUtils.checkingNumberDecimal( cell[j].getContents() ) + "]]>" );
+                            + StringUtils.applyPatternDecimalFormat( cell[j].getContents() ) + "]]>" );
                     }
 
                     STRUCTURE_DATA_RESPONSE.append( "</data>" );

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/manager/DefaultInitializePOIStylesManager.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/manager/DefaultInitializePOIStylesManager.java	2009-11-19 07:55:13 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/manager/DefaultInitializePOIStylesManager.java	2009-12-15 09:02:24 +0000
@@ -134,7 +134,7 @@
 
     public void initCellStyle( HSSFCellStyle test_cs, HSSFFont hssffont, short borderBottom, short bottomBorderColor,
         short borderTop, short topBorderColor, short borderLeft, short leftBorderColor, short borderRight,
-        short rightBorderColor, short alignment )
+        short rightBorderColor, short alignment, boolean bAutoWrap )
     {
 
         test_cs.setFont( hssffont );
@@ -147,13 +147,14 @@
         test_cs.setBorderRight( borderRight );
         test_cs.setRightBorderColor( rightBorderColor );
         test_cs.setAlignment( alignment );
+        test_cs.setWrapText( bAutoWrap );
 
     }
 
     public void initCellStyle( HSSFCellStyle test_cs, HSSFFont hssffont, short fillBgColor, short fillFgColor,
         short fillPattern, short borderBottom, short bottomBorderColor, short borderTop, short topBorderColor,
         short borderLeft, short leftBorderColor, short borderRight, short rightBorderColor, short dataFormat,
-        short alignment )
+        short alignment, boolean bAutoWrap )
     {
 
         test_cs.setFont( hssffont );
@@ -170,5 +171,6 @@
         test_cs.setRightBorderColor( rightBorderColor );
         test_cs.setDataFormat( dataFormat );
         test_cs.setAlignment( alignment );
+        test_cs.setWrapText( bAutoWrap );
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/manager/InitializePOIStylesManager.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/manager/InitializePOIStylesManager.java	2009-10-07 10:20:08 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/manager/InitializePOIStylesManager.java	2009-12-15 09:02:24 +0000
@@ -45,13 +45,13 @@
 
     // HSSFHeader initDefaultHeader();
     void initDefaultHeader( HSSFHeader header );
-    
+
     // HSSFFont initDefaultFont();
     void initDefaultFont( HSSFFont font );
-    
+
     // HSSFCellStyle initDefaultCellStyle();
     void initDefaultCellStyle( HSSFCellStyle cs, HSSFFont font );
-    
+
     // HSSFHeader initHeader( String sCenter, String sLeft, String sRight );
 
     // HSSFFont initFont( String sFontName, short fontHeightInPoints, short
@@ -59,29 +59,28 @@
 
     // HSSFCellStyle initCellStyle( HSSFFont hssffont, short borderBottom, short
     // bottomBorderColor,
-      // short borderTop, short topBorderColor, short borderLeft, short
-        // leftBorderColor, short borderRight,
-      // short rightBorderColor, short alignment );
+    // short borderTop, short topBorderColor, short borderLeft, short
+    // leftBorderColor, short borderRight,
+    // short rightBorderColor, short alignment );
 
     // HSSFCellStyle initCellStyle( HSSFFont hssffont, short fillBgColor, short
     // fillFgColor, short fillPattern,
-      // short borderBottom, short bottomBorderColor, short borderTop, short
-        // topBorderColor, short borderLeft,
-      // short leftBorderColor, short borderRight, short rightBorderColor,
-        // short dataFormat, short alignment );
-
-    
-    void initHeader(HSSFHeader header, String sCenter, String sLeft, String sRight );
-
-    void initFont(HSSFFont test_font, String sFontName, short fontHeightInPoints, short boldWeight, short fontColor );
-
-    void initCellStyle(HSSFCellStyle test_cs, HSSFFont hssffont, short borderBottom, short bottomBorderColor,
+    // short borderBottom, short bottomBorderColor, short borderTop, short
+    // topBorderColor, short borderLeft,
+    // short leftBorderColor, short borderRight, short rightBorderColor,
+    // short dataFormat, short alignment );
+
+    void initHeader( HSSFHeader header, String sCenter, String sLeft, String sRight );
+
+    void initFont( HSSFFont test_font, String sFontName, short fontHeightInPoints, short boldWeight, short fontColor );
+
+    void initCellStyle( HSSFCellStyle test_cs, HSSFFont hssffont, short borderBottom, short bottomBorderColor,
         short borderTop, short topBorderColor, short borderLeft, short leftBorderColor, short borderRight,
-        short rightBorderColor, short alignment );
-
-    void initCellStyle(HSSFCellStyle test_cs, HSSFFont hssffont, short fillBgColor, short fillFgColor, short fillPattern,
-        short borderBottom, short bottomBorderColor, short borderTop, short topBorderColor, short borderLeft,
-        short leftBorderColor, short borderRight, short rightBorderColor, short dataFormat, short alignment );
-
-    
+        short rightBorderColor, short alignment, boolean bAutoWrap );
+
+    void initCellStyle( HSSFCellStyle test_cs, HSSFFont hssffont, short fillBgColor, short fillFgColor,
+        short fillPattern, short borderBottom, short bottomBorderColor, short borderTop, short topBorderColor,
+        short borderLeft, short leftBorderColor, short borderRight, short rightBorderColor, short dataFormat,
+        short alignment, boolean bAutoWrap );
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java	2009-11-16 04:56:59 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java	2009-12-15 09:02:24 +0000
@@ -1,5 +1,8 @@
 package org.hisp.dhis.reportexcel.utils;
 
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
 /*
  * Copyright (c) 2004-2007, University of Oslo
  * All rights reserved.
@@ -39,9 +42,13 @@
     private static final String MIDDLE_LINE = "-";
 
     public static final String NUMBER_OF_ZERO = "0";
-    
+
     private static final String SEPARATE = "/";
 
+    private static final String PATTERN_DECIMAL_FORMAT = "#0.##";
+
+    private static final NumberFormat nf = new DecimalFormat( PATTERN_DECIMAL_FORMAT );
+
     /* ---------------------------------------------------------------------- */
     /*                                                                        */
     /* ---------------------------------------------------------------------- */
@@ -89,7 +96,7 @@
                         input = String.valueOf( new Long( s1 ) ).concat( DOT + splitZeroAtEndOfNumberic( s2 ) );
                     }
                 }
-                
+
                 if ( new Double( input ) == 0.0d )
                 {
                     input = MIDDLE_LINE;
@@ -128,12 +135,33 @@
 
         return number;
     }
-    
-    /* ---------------------------------------------------------------------- */
-    /*                                                                        */
-    /* ---------------------------------------------------------------------- */
-
-    @SuppressWarnings("unused")
+
+    /* ---------------------------------------------------------------------- */
+    /*                                                                        */
+    /* ---------------------------------------------------------------------- */
+
+    public static String applyPatternDecimalFormat( String input )
+    {
+        try
+        {
+            if ( Double.parseDouble( input ) >= 0.0d )
+            {
+                input = nf.format( Double.parseDouble( input ) );
+            }
+            return input;
+        }
+        catch ( NumberFormatException nfe )
+        {
+            return input;
+        }
+
+    }
+
+    /* ---------------------------------------------------------------------- */
+    /*                                                                        */
+    /* ---------------------------------------------------------------------- */
+
+    @SuppressWarnings( "unused" )
     private static final String replacedSeparateCharacter( String path )
     {
         path = path.replace( "\\", SEPARATE );