← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6497: local vn - Fixed Preview bug.

 

------------------------------------------------------------
revno: 6497
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-04-06 13:21:25 +0700
message:
  local vn - Fixed Preview bug.
modified:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.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-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java	2012-01-12 07:06:28 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java	2012-04-06 06:21:25 +0000
@@ -261,7 +261,7 @@
                         + readValueByPOI( row.getRowNum() + 1, cell.getColumnIndex() + 1, s, evaluatorFormula )
                         + "]]></data>" );
 
-                    this.readingDetailsFormattedCell( cell, bDetailed );
+                    this.readingDetailsFormattedCell( s, cell, bDetailed );
 
                     xml.append( "</col>" );
                 }
@@ -271,7 +271,7 @@
         xml.append( "</sheet>" );
     }
 
-    private void readingDetailsFormattedCell( Cell objCell, boolean bDetailed )
+    private void readingDetailsFormattedCell( Sheet sheet, Cell objCell, boolean bDetailed )
     {
         // The format information
         CellStyle format = objCell.getCellStyle();
@@ -279,6 +279,7 @@
         if ( format != null )
         {
             xml.append( "<format align='" + convertAlignmentString( format.getAlignment() ) + "'" );
+            xml.append( " width='" + sheet.getColumnWidth( objCell.getColumnIndex() ) + "'" );
             xml.append( " border='"
                 + (format.getBorderBottom() + format.getBorderLeft() + format.getBorderRight() + format.getBorderTop())
                 + "'" );

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java	2011-11-09 07:39:59 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java	2012-04-06 06:21:25 +0000
@@ -216,7 +216,7 @@
 
                     xml.append( "<data><![CDATA[" + readValueByPOI( i + 1, j + 1, s, evaluatorFormula ) + "]]></data>" );
 
-                    this.readingDetailsFormattedCell( cell );
+                    this.readingDetailsFormattedCell( s, cell );
 
                     xml.append( "</col>" );
                 }
@@ -249,13 +249,14 @@
         }
     }
 
-    private void readingDetailsFormattedCell( org.apache.poi.ss.usermodel.Cell objCell )
+    private void readingDetailsFormattedCell( Sheet sheet, Cell objCell )
     {
         CellStyle format = objCell.getCellStyle();
 
         if ( format != null )
         {
             xml.append( "<format align='" + convertAlignmentString( format.getAlignment() ) + "'" );
+            xml.append( " width='" + sheet.getColumnWidth( objCell.getColumnIndex() ) + "'" );
             xml.append( " border='" + format.getBorderBottom() + format.getBorderLeft() + format.getBorderRight()
                 + format.getBorderTop() + "'/>" );
         }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java	2011-11-03 04:26:28 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java	2012-04-06 06:21:25 +0000
@@ -236,9 +236,9 @@
                 {
                     value = NumberUtils.getFormattedNumber( dataFormatter.formatCellValue( cellPOI, evaluator ) );
                 }
-                catch ( IllegalStateException ise )
+                catch ( Exception ex )
                 {
-                    value = cellPOI.getCellFormula();
+                    value = ErrorConstants.getText( cellPOI.getErrorCellValue() );
                 }
                 break;
             case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-02-28 08:50:46 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-04-06 06:21:25 +0000
@@ -65,7 +65,7 @@
 	var aKey 	= new Array();
 	var aMerged = new Array();	
 	var cells 	= parentElement.getElementsByTagName( 'cell' );
-	
+
 	for (var i  = 0 ; i < cells.length ; i ++)
 	{	
 		aKey[i]		= cells[i].getAttribute( 'iKey' );
@@ -80,30 +80,30 @@
 	var _sheets		= parentElement.getElementsByTagName( 'sheet' );
 	var _sHTML		= [];
 	var tabsHTML 	= ['<div id="tabs"><ul>'];
-	
+
 	for (var s = 0 ; s < _sheets.length ; s ++)
 	{
 		// Create tab name
 		tabsHTML.push( '<li><a href="#tabs-', s, '">', getElementValue( _sheets[s], "name" ), '</a></li>' );
-	
+
 		_rows 		= _sheets[s].getElementsByTagName( 'row' );
 		_orderSheet	= getRootElementAttribute( _sheets[s], "id" );
-		
+
 		_sHTML.push( '<div id="tabs-', s, '">' );
 		_sHTML.push( "<table class='ui-preview-table'>" );
-		
+
 		for (var i = 0 ; i < _rows.length ; i ++)
 		{
 			_index	= 0;
 			_sHTML.push( "<tr>" );
-			
+
 			_cols 	= _rows[i].getElementsByTagName( 'col' );
-			
+
 			for (var j 	= 0 ; j < _cols.length ; )
 			{
 				var _number	= getRootElementAttribute( _cols[j], 'no' );
 				var keyId 	= getRootElementAttribute( _cols[j], 'id' );
-				
+
 				// Printing out the unformatted cells
 				for (; _index < _number ; _index ++)
 				{
@@ -115,19 +115,20 @@
 					var _sData		= getElementValue( _cols[j], 'data' );
 					var _align		= getElementAttribute( _cols[j], 'format', 'align' );
 					var _border		= getElementAttribute( _cols[j], 'format', 'border' );
-				
+					var _width		= getElementAttribute( _cols[j], 'format', 'width' );
+
 					// If this cell is merged - Key's form: Sheet#Row#Col
 					_sPattern 		=  _orderSheet + "#" + i + "#" + _number;
 					var _colspan 	= getMergedNumberForEachCell( aKey, _sPattern, aMerged );
-					
+
 					// Jumping for <For Loop> AND <Empty Cells>
 					j 		= Number(j) + Number(_colspan);
 					_index 	= Number(_index) + Number(_colspan);
-					
-					_sHTML.push( "<td align='", _align, "' colspan='", _colspan, "'" );
+
+					_sHTML.push( "<td align='", _align, "' width='", _width, "px' colspan='", _colspan, "'" );
 					_sHTML.push( " class='printclass" );
 					_sHTML.push( _border > 0 ? " ui-widget-content" : "" );
-					
+
 					// Preview without importing
 					if ( keyId && keyId.length > 0 )
 					{
@@ -137,7 +138,6 @@
 					{
 						_sHTML.push( " ui-preview-normal" );
 					}
-					
 					_sHTML.push( "'>", _sData, "</td>" );
 				}
 			}