← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4151: local vn - Speed up Preview functionality when generating/importing data.

 

------------------------------------------------------------
revno: 4151
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-07-18 12:04:23 +0700
message:
  local vn - Speed up Preview functionality when generating/importing data.
modified:
  local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java
  local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java
  local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelUtils.java
  local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java
  local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/imports.js


--
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 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java	2011-06-29 07:29:06 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java	2011-07-18 05:04:23 +0000
@@ -27,21 +27,26 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.io.File;
+import static org.hisp.dhis.reportexcel.utils.ExcelUtils.convertAlignmentString;
+import static org.hisp.dhis.reportexcel.utils.ExcelUtils.convertVerticalString;
+import static org.hisp.dhis.reportexcel.utils.ExcelUtils.readSpecialValueByPOI;
+import static org.hisp.dhis.reportexcel.utils.StringUtils.applyPatternDecimalFormat;
+
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.Collection;
 
-import jxl.Cell;
-import jxl.CellType;
-import jxl.Range;
-import jxl.Sheet;
-import jxl.Workbook;
-import jxl.format.CellFormat;
-import jxl.format.Colour;
-import jxl.format.Font;
-import jxl.format.Pattern;
-
-import org.hisp.dhis.reportexcel.utils.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFPatternFormatting;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xwpf.usermodel.UnderlinePatterns;
 
 /**
  * Simple demo class which uses the api to present the contents of an excel 97
@@ -85,7 +90,7 @@
     // -------------------------------------------------------------------------
     // Get & Set methods
     // -------------------------------------------------------------------------
-    
+
     protected String getXml()
     {
         return xml.toString();
@@ -112,10 +117,9 @@
         throws Exception
     {
         this.cleanUpForResponse();
-
         this.bWRITE_DTD = bWriteDTD;
         this.bWRITE_VERSION = bWriteVersion;
-        this.WORKBOOK = Workbook.getWorkbook( new File( pathFileName ) );
+        this.WORKBOOK = new HSSFWorkbook( new FileInputStream( pathFileName ) );
 
         if ( bFormat )
         {
@@ -145,30 +149,36 @@
 
         xml.append( WORKBOOK_OPENTAG );
 
-        for ( Integer sheet : collectSheets )
+        int i = 0;
+        int j = 0;
+
+        for ( Integer sheetNo : collectSheets )
         {
-            Sheet s = WORKBOOK.getSheet( sheet - 1 );
+            Sheet sheet = WORKBOOK.getSheetAt( sheetNo - 1 );
 
             xml.append( "<sheet id='" + sheet + "'>" );
-            xml.append( "<name><![CDATA[" + s.getName() + "]]></name>" );
-
-            Cell[] row = null;
-
-            for ( int i = 0; i < s.getRows(); i++ )
+            xml.append( "<name><![CDATA[" + sheet.getSheetName() + "]]></name>" );
+
+            for ( Row row : sheet )
             {
+                j = 0;
+
                 xml.append( "<row number='" + i + "'>" );
 
-                row = s.getRow( i );
-
-                for ( int j = 0; j < row.length; j++ )
+                for ( Cell cell : row )
                 {
-                    if ( row[j].getType() != CellType.EMPTY )
+                    if ( cell.getCellType() != Cell.CELL_TYPE_BLANK )
                     {
                         xml.append( "<col number='" + j + "'>" );
-                        xml.append( "<![CDATA[" + row[j].getContents() + "]]>" );
+                        xml.append( "<![CDATA[" + readSpecialValueByPOI( i + 1, j + 1, sheet ) + "]]>" );
                         xml.append( "</col>" );
                     }
+
+                    j++;
                 }
+
+                i++;
+
                 xml.append( "</row>" );
             }
             xml.append( "</sheet>" );
@@ -218,34 +228,39 @@
 
     private void writeBySheetNo( int sheetNo, boolean bDetailed )
     {
-        Sheet s = WORKBOOK.getSheet( sheetNo - 1 );
+        Sheet s = WORKBOOK.getSheetAt( sheetNo - 1 );
 
         xml.append( "<sheet id='" + (sheetNo) + "'>" );
-        xml.append( "<name><![CDATA[" + s.getName() + "]]></name>" );
-
-        Cell[] cell = null;
-
-        for ( int i = 0; i < s.getRows(); i++ )
+        xml.append( "<name><![CDATA[" + s.getSheetName() + "]]></name>" );
+
+        int i = 0;
+        int j = 0;
+
+        for ( Row row : s )
         {
+            j = 0;
+
             xml.append( "<row index='" + i + "'>" );
 
-            cell = s.getRow( i );
-
-            for ( int j = 0; j < cell.length; j++ )
+            for ( Cell cell : row )
             {
-                // Remember that empty cells can contain format
-                // information
-                if ( !cell[j].getType().equals( CellType.EMPTY ) || (cell[j].getCellFormat() != null) )
+                // Remember that empty cells can contain format information
+                if ( (cell.getCellStyle() != null) || cell.getCellType() != Cell.CELL_TYPE_BLANK )
                 {
                     xml.append( "<col no='" + j + "'><data>" );
-                    xml.append( "<![CDATA[" + StringUtils.applyPatternDecimalFormat( cell[j].getContents() )
+                    xml.append( "<![CDATA[" + applyPatternDecimalFormat( readSpecialValueByPOI( i + 1, j + 1, s ) )
                         + "]]></data>" );
 
-                    this.readingDetailsFormattedCell( cell[j], bDetailed );
+                    this.readingDetailsFormattedCell( cell, bDetailed );
 
                     xml.append( "</col>" );
                 }
+
+                j++;
             }
+
+            i++;
+
             xml.append( "</row>" );
         }
         xml.append( "</sheet>" );
@@ -254,41 +269,36 @@
     private void readingDetailsFormattedCell( Cell objCell, boolean bDetailed )
     {
         // The format information
-        CellFormat format = objCell.getCellFormat();
-        Font font = null;
+        CellStyle format = objCell.getCellStyle();
 
         if ( format != null )
         {
-            xml.append( "<format align='" + StringUtils.convertAlignmentString( format.getAlignment().getDescription() )
-                + "'" );
-
-            if ( bDetailed )
+            xml.append( "<format align='" + convertAlignmentString( format.getAlignment() ) + "'" );
+
+            Font font = WORKBOOK.getFontAt( format.getFontIndex() );
+
+            if ( bDetailed && font != null )
             {
-                xml.append( " valign='" + format.getVerticalAlignment().getDescription() + "'>" );
-
-                // The font information
-                font = format.getFont();
-
-                xml.append( "<font point_size='" + font.getPointSize() + "'" );
-                xml.append( " bold_weight='" + font.getBoldWeight() + "'" );
-                xml.append( " italic='" + font.isItalic() + "'" );
-                xml.append( " underline='" + font.getUnderlineStyle().getDescription() + "'" );
-                xml.append( " colour='" + font.getColour().getDescription() + "'" );
+                xml.append( " valign='" + convertVerticalString( format.getVerticalAlignment() ) + "'>" );
+
+                xml.append( "<font point_size='" + font.getFontHeightInPoints() + "'" );
+                xml.append( " bold_weight='" + font.getBoldweight() + "'" );
+                xml.append( " italic='" + font.getItalic() + "'" );
+                xml.append( " underline='" + UnderlinePatterns.valueOf( font.getUnderline() ).name() + "'" );
+                xml.append( " colour='" + font.getColor() + "'" );
                 xml.append( " />" );
 
                 // The cell background information
-                if ( format.getBackgroundColour() != Colour.DEFAULT_BACKGROUND || format.getPattern() != Pattern.NONE )
+                if ( format.getFillBackgroundColor() != IndexedColors.WHITE.getIndex()
+                    || format.getFillPattern() != HSSFPatternFormatting.NO_FILL )
                 {
-                    xml.append( "<background colour='" + format.getBackgroundColour().getDescription() + "'" );
-                    xml.append( " />" );
+                    xml.append( "<background colour='" + format.getFillBackgroundColor() + "' />" );
                 }
 
                 // The cell number/date format
-                if ( !format.getFormat().getFormatString().equals( "" ) )
+                if ( !format.getDataFormatString().equals( "" ) )
                 {
-                    xml.append( "<format_string string='" );
-                    xml.append( format.getFormat().getFormatString() );
-                    xml.append( "' />" );
+                    xml.append( "<format_string string='" + format.getDataFormatString() + "' />" );
                 }
                 xml.append( "</format>" );
             }
@@ -325,23 +335,18 @@
 
     private void writeBySheetNo( int sheetNo )
     {
-        Sheet sheet = WORKBOOK.getSheet( sheetNo - 1 );
-        Range[] aMergedCell = sheet.getMergedCells();
-
-        int iColTopLeft = 0;
-        int iRowTopLeft = 0;
-        int iColBottomRight = 0;
-
-        for ( int j = 0; j < aMergedCell.length; j++ )
+        Sheet sheet = WORKBOOK.getSheetAt( sheetNo - 1 );
+        CellRangeAddress cellRangeAddress = null;
+
+        for ( int i = 0; i < sheet.getNumMergedRegions(); i++ )
         {
-            iColTopLeft = aMergedCell[j].getTopLeft().getColumn();
-            iRowTopLeft = aMergedCell[j].getTopLeft().getRow();
-            iColBottomRight = aMergedCell[j].getBottomRight().getColumn();
+            cellRangeAddress = sheet.getMergedRegion( i );
 
-            if ( iColTopLeft != iColBottomRight )
+            if ( cellRangeAddress.getFirstColumn() != cellRangeAddress.getLastColumn() )
             {
-                xml.append( "<cell " + "iKey='" + (sheetNo) + "#" + iRowTopLeft + "#" + iColTopLeft + "'>"
-                    + (iColBottomRight - iColTopLeft + 1) + "</cell>" );
+                xml.append( "<cell " + "iKey='" + (sheetNo) + "#" + cellRangeAddress.getFirstRow() + "#"
+                    + cellRangeAddress.getFirstColumn() + "'>"
+                    + (cellRangeAddress.getLastColumn() - cellRangeAddress.getFirstColumn() + 1) + "</cell>" );
             }
         }
     }

=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java	2011-07-12 05:23:15 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponseImport.java	2011-07-18 05:04:23 +0000
@@ -27,7 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.reportexcel.utils.StringUtils.convertAlignmentString;
+import static org.hisp.dhis.reportexcel.utils.ExcelUtils.convertAlignmentString;
+import static org.hisp.dhis.reportexcel.utils.ExcelUtils.readSpecialValueByPOI;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -35,13 +36,12 @@
 import java.util.Collection;
 import java.util.List;
 
-import jxl.Cell;
-import jxl.CellType;
-import jxl.Range;
-import jxl.Sheet;
-import jxl.Workbook;
-import jxl.format.CellFormat;
-
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.hisp.dhis.reportexcel.importitem.ExcelItem;
 import org.hisp.dhis.reportexcel.importitem.ExcelItemGroup;
 
@@ -61,7 +61,7 @@
     /**
      * The workbook we are reading from a given file
      */
-    private Workbook WORKBOOK;
+    private org.apache.poi.ss.usermodel.Workbook WORKBOOK;
 
     private static final String WORKBOOK_OPENTAG = "<workbook>";
 
@@ -102,37 +102,75 @@
 
         FileInputStream inputStream = new FileInputStream( new File( pathFileName ) );
 
-        this.WORKBOOK = Workbook.getWorkbook( inputStream );
+        this.WORKBOOK = new HSSFWorkbook( inputStream );
 
         this.writeFormattedXML( collectSheets, importItems, bWriteDescription, type );
     }
 
     // -------------------------------------------------------------------------
-    // Public methods
+    // Private methods
     // -------------------------------------------------------------------------
 
-    public void writeData( int sheetNo, List<ExcelItem> importItems, String TYPE )
-    {
-        Sheet s = WORKBOOK.getSheet( sheetNo - 1 );
+    private void cleanUpForResponse()
+    {
+        System.gc();
+    }
+
+    private void writeFormattedXML( Collection<Integer> collectSheets, List<ExcelItem> importItems,
+        boolean bWriteDescription, String type )
+        throws Exception
+    {
+        if ( bWriteDescription )
+        {
+            this.writeXMLMergedDescription( collectSheets );
+        }
+
+        xml.append( WORKBOOK_OPENTAG );
+
+        for ( Integer sheet : collectSheets )
+        {
+            this.writeData( sheet, importItems, type );
+        }
+
+        xml.append( WORKBOOK_CLOSETAG );
+    }
+
+    private void writeXMLMergedDescription( Collection<Integer> collectSheets )
+        throws IOException
+    {
+        xml.append( MERGEDCELL_OPENTAG );
+
+        for ( Integer sheet : collectSheets )
+        {
+            writeBySheetNo( sheet );
+        }
+
+        xml.append( MERGEDCELL_CLOSETAG );
+    }
+
+    private void writeData( int sheetNo, List<ExcelItem> importItems, String TYPE )
+    {
+        Sheet s = WORKBOOK.getSheetAt( sheetNo - 1 );
 
         xml.append( "<sheet id='" + (sheetNo) + "'>" );
-        xml.append( "<name><![CDATA[" + s.getName() + "]]></name>" );
+        xml.append( "<name><![CDATA[" + s.getSheetName() + "]]></name>" );
 
-        Cell[] cell = null;
         int run = 0;
+        int i = 0;
+        int j = 0;
 
-        for ( int i = 0; i < s.getRows(); i++ )
+        for ( Row row : s )
         {
+            j = 0;
+
             xml.append( "<row index='" + i + "'>" );
 
-            cell = s.getRow( i );
-
-            for ( int j = 0; j < cell.length; j++ )
+            for ( Cell cell : row )
             {
                 run = 0;
-                
+
                 // Remember that empty cells can contain format information
-                if ( !cell[j].getType().equals( CellType.EMPTY ) || (cell[j].getCellFormat() != null) )
+                if ( (cell.getCellStyle() != null) || cell.getCellType() != Cell.CELL_TYPE_BLANK )
                 {
                     xml.append( "<col no='" + j + "'" );
 
@@ -141,7 +179,8 @@
                         if ( (importItem.getSheetNo() == sheetNo) && (importItem.getRow() == (i + 1))
                             && (importItem.getColumn() == (j + 1)) )
                         {
-                            if ( TYPE.equals( ExcelItemGroup.TYPE.NORMAL ) || TYPE.equals( ExcelItemGroup.TYPE.CATEGORY ) )
+                            if ( TYPE.equals( ExcelItemGroup.TYPE.NORMAL )
+                                || TYPE.equals( ExcelItemGroup.TYPE.CATEGORY ) )
                             {
                                 xml.append( " id='" + importItem.getExpression() + "'>" );
                             }
@@ -153,94 +192,52 @@
                     }
 
                     if ( run == importItems.size() )
-                    {                        
+                    {
                         xml.append( ">" );
                     } // end checking
 
-                    xml.append( "<data><![CDATA[" + cell[j].getContents() + "]]></data>" );
+                    xml.append( "<data><![CDATA[" + readSpecialValueByPOI( i + 1, j + 1, s ) + "]]></data>" );
 
-                    this.readingDetailsFormattedCell( cell[j] );
+                    this.readingDetailsFormattedCell( cell );
 
                     xml.append( "</col>" );
                 }
+
+                j++;
             }
+
+            i++;
+
             xml.append( "</row>" );
         }
         xml.append( "</sheet>" );
     }
 
-    // -------------------------------------------------------------------------
-    // Private methods
-    // -------------------------------------------------------------------------
-
-    private void cleanUpForResponse()
-    {
-        System.gc();
-    }
-
-    private void writeFormattedXML( Collection<Integer> collectSheets, List<ExcelItem> importItems,
-        boolean bWriteDescription, String type )
-        throws Exception
-    {
-        if ( bWriteDescription )
-        {
-            this.writeXMLMergedDescription( collectSheets );
-        }
-
-        xml.append( WORKBOOK_OPENTAG );
-
-        for ( Integer sheet : collectSheets )
-        {
-            writeData( sheet, importItems, type );
-        }
-
-        xml.append( WORKBOOK_CLOSETAG );
-    }
-
-    private void writeXMLMergedDescription( Collection<Integer> collectSheets )
-        throws IOException
-    {
-        xml.append( MERGEDCELL_OPENTAG );
-
-        for ( Integer sheet : collectSheets )
-        {
-            writeBySheetNo( sheet );
-        }
-
-        xml.append( MERGEDCELL_CLOSETAG );
-    }
-
     private void writeBySheetNo( int sheetNo )
     {
-        Sheet sheet = WORKBOOK.getSheet( sheetNo - 1 );
-        Range[] aMergedCell = sheet.getMergedCells();
-
-        int iColTopLeft = 0;
-        int iRowTopLeft = 0;
-        int iColBottomRight = 0;
-
-        for ( int j = 0; j < aMergedCell.length; j++ )
+        Sheet sheet = WORKBOOK.getSheetAt( sheetNo - 1 );
+        CellRangeAddress cellRangeAddress = null;
+
+        for ( int i = 0; i < sheet.getNumMergedRegions(); i++ )
         {
-            iColTopLeft = aMergedCell[j].getTopLeft().getColumn();
-            iRowTopLeft = aMergedCell[j].getTopLeft().getRow();
-            iColBottomRight = aMergedCell[j].getBottomRight().getColumn();
+            cellRangeAddress = sheet.getMergedRegion( i );
 
-            if ( iColTopLeft != iColBottomRight )
+            if ( cellRangeAddress.getFirstColumn() != cellRangeAddress.getLastColumn() )
             {
-                xml.append( "<cell " + "iKey='" + (sheetNo) + "#" + iRowTopLeft + "#" + iColTopLeft + "'>"
-                    + (iColBottomRight - iColTopLeft + 1) + "</cell>" );
+                xml.append( "<cell " + "iKey='" + (sheetNo) + "#" + cellRangeAddress.getFirstRow() + "#"
+                    + cellRangeAddress.getFirstColumn() + "'>"
+                    + (cellRangeAddress.getLastColumn() - cellRangeAddress.getFirstColumn() + 1) + "</cell>" );
             }
         }
     }
 
-    private void readingDetailsFormattedCell( Cell objCell )
+    private void readingDetailsFormattedCell( org.apache.poi.ss.usermodel.Cell objCell )
     {
-        // The format information
-        CellFormat format = objCell.getCellFormat();
+        CellStyle format = objCell.getCellStyle();
 
         if ( format != null )
         {
-            xml.append( "<format align='" + convertAlignmentString( format.getAlignment().getDescription() ) + "'/>" );
+            xml.append( "<format align='" + convertAlignmentString( format.getAlignment() ) + "'/>" );
         }
     }
 }
\ No newline at end of file

=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelUtils.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelUtils.java	2011-07-08 07:52:59 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelUtils.java	2011-07-18 05:04:23 +0000
@@ -45,6 +45,9 @@
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.FormulaParser;
 import org.apache.poi.ss.formula.FormulaParsingWorkbook;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.ErrorConstants;
 
 /**
  * @author Tran Thanh Tri
@@ -83,7 +86,7 @@
     public static final String EXTENSION_XLS = ".xls";
 
     // -------------------------------------------------------------------------
-    //
+    // JXL methods
     // -------------------------------------------------------------------------
 
     /* JXL - Get the specified cell */
@@ -134,6 +137,10 @@
         }
     }
 
+    // -------------------------------------------------------------------------
+    // POI methods
+    // -------------------------------------------------------------------------
+
     /* POI - Get the specified cell */
     public static org.apache.poi.ss.usermodel.Cell getCellByPOI( int row, int column,
         org.apache.poi.ss.usermodel.Sheet sheetPOI )
@@ -168,7 +175,7 @@
                 break;
 
             case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
-                value = String.valueOf( cellPOI.getErrorCellValue() );
+                value = ErrorConstants.getText( cellPOI.getErrorCellValue() );
                 break;
 
             case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
@@ -176,7 +183,14 @@
                 break;
 
             case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
-                value = String.valueOf( cellPOI.getNumericCellValue() );
+                if ( DateUtil.isCellDateFormatted( cellPOI ) )
+                {
+                    value = String.valueOf( cellPOI.getDateCellValue() );
+                }
+                else
+                {
+                    value = String.valueOf( cellPOI.getNumericCellValue() );
+                }
                 break;
 
             default:
@@ -189,6 +203,59 @@
 
     }
 
+    /* POI - Read the special value of given cell */
+    public static String readSpecialValueByPOI( int row, int column, org.apache.poi.ss.usermodel.Sheet sheetPOI )
+    {
+        org.apache.poi.ss.usermodel.Cell cellPOI = getCellByPOI( row, column, sheetPOI );
+
+        String value = "";
+
+        if ( cellPOI != null )
+        {
+            switch ( cellPOI.getCellType() )
+            {
+            case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
+                value = cellPOI.getRichStringCellValue().toString();
+                break;
+
+            case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
+                value = String.valueOf( cellPOI.getBooleanCellValue() );
+                break;
+
+            case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
+                value = ErrorConstants.getText( cellPOI.getErrorCellValue() );
+                break;
+
+            case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
+                try
+                {
+                    value = String.valueOf( cellPOI.getNumericCellValue() );
+                }
+                catch ( IllegalStateException ise )
+                {
+                    value = cellPOI.getCellFormula();
+                }
+                break;
+            case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
+                if ( DateUtil.isCellDateFormatted( cellPOI ) )
+                {
+                    value = String.valueOf( cellPOI.getDateCellValue() );
+                }
+                else
+                {
+                    value = String.valueOf( cellPOI.getNumericCellValue() );
+                }
+                break;
+
+            default:
+                break;
+            }
+        }
+
+        return value;
+
+    }
+
     public static String readValueImportingByPOI( int row, int column, org.apache.poi.ss.usermodel.Sheet sheetPOI )
     {
         org.apache.poi.ss.usermodel.Cell cellPOI = getCellByPOI( row, column, sheetPOI );
@@ -410,6 +477,75 @@
         }
     }
 
+    public static String convertAlignmentString( String s )
+    {
+        if ( s.equalsIgnoreCase( "centre" ) )
+        {
+            return "center";
+        }
+        else
+        {
+            return s;
+        }
+    }
+
+    public static String convertAlignmentString( Short s )
+    {
+        String align = "";
+
+        switch ( s )
+        {
+        case CellStyle.ALIGN_CENTER:
+        case CellStyle.ALIGN_CENTER_SELECTION:
+            align = "center";
+            break;
+
+        case CellStyle.ALIGN_JUSTIFY:
+            align = "justify";
+            break;
+
+        case CellStyle.ALIGN_LEFT:
+            align = "left";
+            break;
+
+        case CellStyle.ALIGN_RIGHT:
+            align = "right";
+            break;
+
+        default:
+            align = "general";
+            break;
+        }
+
+        return align;
+    }
+
+    public static String convertVerticalString( Short s )
+    {
+        String valign = "";
+
+        switch ( s )
+        {
+        case CellStyle.VERTICAL_TOP:
+            valign = "top";
+            break;
+
+        case CellStyle.VERTICAL_CENTER:
+            valign = "center";
+            break;
+
+        case CellStyle.VERTICAL_BOTTOM:
+            valign = "bottom";
+            break;
+
+        default:
+            valign = "justify";
+            break;
+        }
+
+        return valign;
+    }
+
     public static String checkingExcelFormula( String string_formula, int indexRow, int indexCol )
     {
         Pattern pattern_formula = Pattern.compile( PATTERN_EXCELFORMULA );

=== modified file 'local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java'
--- local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java	2010-04-12 21:23:33 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java	2011-07-18 05:04:23 +0000
@@ -53,22 +53,6 @@
     /*                                                                        */
     /* ---------------------------------------------------------------------- */
 
-    public static String convertAlignmentString( String s )
-    {
-        if ( s.equalsIgnoreCase( "centre" ) )
-        {
-            return "center";
-        }
-        else
-        {
-            return s;
-        }
-    }
-
-    /* ---------------------------------------------------------------------- */
-    /*                                                                        */
-    /* ---------------------------------------------------------------------- */
-
     public static String refiningNumberDecimalFormat( String input )
     {
         try

=== modified file 'local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/imports.js'
--- local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/imports.js	2011-06-29 07:29:06 +0000
+++ local/vn/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/imports.js	2011-07-18 05:04:23 +0000
@@ -60,7 +60,7 @@
 		
 		for ( var i = 0 ; i < importlist.length ; i ++ )
 		{
-			importlist[i].className = 'ui-selected';
+			importlist[i].className = 'ui-widget-content ui-selected';
 			
 			idTemp = jQuery(importlist[i]).attr( 'id' ) + "_" + jQuery(importlist[i]).html();
 			
@@ -79,7 +79,7 @@
 		
 		for ( var i = 0 ; i < importlist.length ; i ++ )
 		{
-			importlist[i].className = 'ui-unselected';
+			importlist[i].className = 'ui-widget-content ui-unselected';
 		}
 		
 		importItemIds.length = 0;