← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8792: local vn - Fixed bug generate the Category report with the singature area as footer

 

------------------------------------------------------------
revno: 8792
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-31 18:06:38 +0700
message:
  local vn - Fixed bug generate the Category report with the singature area as footer
modified:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.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 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.java	2012-10-29 10:31:16 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.java	2012-10-31 11:06:38 +0000
@@ -1,7 +1,7 @@
 package org.hisp.dhis.reportsheet.exporting.action;
 
 /*
- * Copyright (c) 2004-2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -52,6 +52,8 @@
 public class GenerateReportCategoryAction
     extends AbstractGenerateExcelReportSupport
 {
+    private static final int SHIFT_NUMBER_OF_ROWS = 5;
+
     @Autowired
     private DataElementGroupOrderService dataElementGroupOrderService;
 
@@ -93,7 +95,7 @@
             {
                 this.generateHorizontalOutPutFile( exportReportInstance, exportReportItems, organisationUnit, sheet );
             }
-            
+
             this.recalculatingFormula( sheet );
         }
 
@@ -105,12 +107,15 @@
     }
 
     // -------------------------------------------------------------------------
-    // Supportive method
+    // Supportive methods
     // -------------------------------------------------------------------------
 
     private void generateVerticalOutPutFile( List<DataElementGroupOrder> orderedGroups,
         Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
     {
+        boolean isFirst = true;
+        boolean isTitleSetup = isTitleSetup( exportReportItems );
+
         for ( ExportItem reportItem : exportReportItems )
         {
             int run = 0;
@@ -120,6 +125,13 @@
             {
                 int beginChapter = rowBegin;
 
+                // Shift the number of rows - from start-row to end-row
+
+                if ( isTitleSetup && isFirst )
+                {
+                    sheet.shiftRows( rowBegin, rowBegin + SHIFT_NUMBER_OF_ROWS, group.getDataElements().size() + 1 );
+                }
+
                 if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
                 {
                     ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), group.getName(), ExcelUtils.TEXT,
@@ -189,6 +201,8 @@
                         evaluatorFormula );
                 }
             }
+
+            isFirst = false;
         }
     }
 
@@ -243,4 +257,17 @@
 
         return true;
     }
+
+    private boolean isTitleSetup( Collection<ExportItem> exportReportItems )
+    {
+        for ( ExportItem item : exportReportItems )
+        {
+            if ( item.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
 }