← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6843: local vn - Supported in generating to multi-reports.

 

------------------------------------------------------------
revno: 6843
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-05-03 17:04:29 +0700
message:
  local vn - Supported in generating to multi-reports.
added:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateMultiExcelReportSupport.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateMultiReportAction.java
modified:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java
  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/GenerateReportNormalAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/ExportXMLAction.java
  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/resources/META-INF/dhis/beans.xml
  local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties
  local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties
  local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js
  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/exporting/AbstractGenerateExcelReportSupport.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java	2012-04-27 10:13:06 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java	2012-05-03 10:04:29 +0000
@@ -1,7 +1,7 @@
 package org.hisp.dhis.reportsheet.exporting;
 
 /*
- * 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
@@ -26,39 +26,9 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-import static org.hisp.dhis.reportsheet.utils.DateUtils.getEndQuaterly;
-import static org.hisp.dhis.reportsheet.utils.DateUtils.getEndSixMonthly;
-import static org.hisp.dhis.reportsheet.utils.DateUtils.getFirstDayOfMonth;
-import static org.hisp.dhis.reportsheet.utils.DateUtils.getFirstDayOfYear;
-import static org.hisp.dhis.reportsheet.utils.DateUtils.getLastDayOfYear;
-import static org.hisp.dhis.reportsheet.utils.DateUtils.getStartQuaterly;
-import static org.hisp.dhis.reportsheet.utils.DateUtils.getStartSixMonthly;
-import static org.hisp.dhis.reportsheet.utils.DateUtils.getTimeRoll;
-import static org.hisp.dhis.reportsheet.utils.ExpressionUtils.generateExpression;
-import static org.hisp.dhis.reportsheet.utils.ExpressionUtils.generateIndicatorExpression;
-import static org.hisp.dhis.system.util.MathUtils.calculateExpression;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.period.DailyPeriodType;
-import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.period.QuarterlyPeriodType;
-import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.reportsheet.ExportItem;
 import org.hisp.dhis.reportsheet.ExportReport;
-import org.hisp.dhis.reportsheet.utils.ExcelUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -107,279 +77,4 @@
      */
     protected abstract void executeGenerateOutputFile( ExportReport exportReport, Period period )
         throws Exception;
-
-    // -------------------------------------------------------------------------
-    // Abstract methods
-    // -------------------------------------------------------------------------
-
-    protected void installExcelFormat()
-    {
-        // override
-    }
-
-    protected void installPeriod( Period period )
-    {
-        Calendar calendar = Calendar.getInstance();
-
-        // Monthly period
-        startDate = period.getStartDate();
-        endDate = period.getEndDate();
-
-        // So-far-this-month
-        firstDayOfMonth = getFirstDayOfMonth( startDate );
-        firstDayOfMonth = getTimeRoll( firstDayOfMonth, Calendar.DATE, -1 );
-
-        // Last 3 month period
-        // Last 2 months + this month = last 3 month
-        last3MonthStartDate = getTimeRoll( startDate, Calendar.MONTH, -2 );
-        last3MonthStartDate = getTimeRoll( last3MonthStartDate, Calendar.DATE, -1 );
-        last3MonthEndDate = period.getEndDate();
-
-        // So far this year period
-        calendar.setTime( endDate );
-
-        firstDayOfYear = getFirstDayOfYear( calendar.get( Calendar.YEAR ) );
-        firstDayOfYear = getTimeRoll( firstDayOfYear, Calendar.DATE, -1 );
-        endDateOfYear = getLastDayOfYear( calendar.get( Calendar.YEAR ) );
-
-        // Last 6 month period
-        // Last 5 months + this month = last 6 month
-        last6MonthStartDate = getTimeRoll( startDate, Calendar.MONTH, -5 );
-        last6MonthStartDate = getTimeRoll( last6MonthStartDate, Calendar.DATE, -1 );
-        last6MonthEndDate = period.getEndDate();
-
-        // Quarterly
-        startQuaterly = getStartQuaterly( startDate );
-        startQuaterly = getTimeRoll( startQuaterly, Calendar.DATE, -1 );
-        endQuaterly = getEndQuaterly( startDate );
-
-        // Six monthly
-        startSixMonthly = getStartSixMonthly( startDate );
-        startSixMonthly = getTimeRoll( startSixMonthly, Calendar.DATE, -1 );
-        endSixMonthly = getEndSixMonthly( startDate );
-    }
-
-    protected void installReadTemplateFile( ExportReport exportReport, Period period, Object object )
-        throws Exception
-    {
-        Calendar calendar = Calendar.getInstance();
-
-        File reportTempDir = reportLocationManager.getExportReportTemporaryDirectory();
-
-        this.outputReportFile = new File( reportTempDir, currentUserService.getCurrentUsername()
-            + this.dateformatter.format( calendar.getTime() ) + exportReport.getExcelTemplateFile() );
-
-        this.outputStreamExcelTemplate = new FileOutputStream( outputReportFile );
-
-        this.createWorkbookInstance( exportReport );
-
-        this.initExcelFormat();
-
-        this.installDefaultExcelFormat();
-
-        if ( exportReport.getOrganisationRow() != null && exportReport.getOrganisationColumn() != null )
-        {
-            String value = "";
-
-            if ( object instanceof OrganisationUnit )
-            {
-                OrganisationUnit orgunit = (OrganisationUnit) object;
-
-                value = orgunit.getName();
-            }
-            else
-            {
-                OrganisationUnitGroup orgunitGroup = (OrganisationUnitGroup) object;
-
-                value = orgunitGroup.getName();
-            }
-
-            ExcelUtils.writeValueByPOI( exportReport.getOrganisationRow(), exportReport.getOrganisationColumn(), value,
-                ExcelUtils.TEXT, templateWorkbook.getSheetAt( 0 ), csText );
-        }
-
-        if ( exportReport.getPeriodRow() != null && exportReport.getPeriodColumn() != null )
-        {
-            ExcelUtils.writeValueByPOI( exportReport.getPeriodRow(), exportReport.getPeriodColumn(), format
-                .formatPeriod( period ), ExcelUtils.TEXT, templateWorkbook.getSheetAt( 0 ), csText );
-        }
-    }
-
-    // -------------------------------------------------------------------------
-    // DataElement Value
-    // -------------------------------------------------------------------------
-
-    protected String getTextValue( ExportItem exportItem, OrganisationUnit organisationUnit )
-    {
-        String result = "";
-        Collection<Period> periods = new ArrayList<Period>();
-
-        if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) )
-        {
-            periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( DailyPeriodType.NAME ),
-                startDate, startDate );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) )
-        {
-            periods = periodService.getPeriodsBetweenDates(
-                periodService.getPeriodTypeByName( MonthlyPeriodType.NAME ), startDate, endDate );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) )
-        {
-            periods = periodService.getPeriodsBetweenDates( periodService
-                .getPeriodTypeByName( QuarterlyPeriodType.NAME ), startQuaterly, endQuaterly );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) )
-        {
-            periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( YearlyPeriodType.NAME ),
-                firstDayOfYear, endDateOfYear );
-        }
-
-        for ( Period p : periods )
-        {
-            result += generateExpression( exportItem, p, organisationUnit, dataElementService, categoryService,
-                dataValueService ) + "\n";
-        }
-
-        return result;
-    }
-
-    protected double getDataValue( ExportItem exportItem, OrganisationUnit organisationUnit )
-    {
-        double value = 0.0;
-
-        if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, startDate, startDate, organisationUnit,
-                dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_MONTH ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, firstDayOfMonth, endDate, organisationUnit,
-                dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_QUARTER ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, startQuaterly, endDate, organisationUnit,
-                dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, startDate, endDate, organisationUnit,
-                dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_3_MONTH ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, last3MonthStartDate, last3MonthEndDate,
-                organisationUnit, dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_6_MONTH ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, last6MonthStartDate, last6MonthEndDate,
-                organisationUnit, dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, startQuaterly, endQuaterly, organisationUnit,
-                dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SIX_MONTH ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, startSixMonthly, endSixMonthly,
-                organisationUnit, dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_YEAR ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endDate, organisationUnit,
-                dataElementService, categoryService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) )
-        {
-            value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endDateOfYear,
-                organisationUnit, dataElementService, categoryService, aggregationService ) );
-        }
-
-        return value;
-    }
-
-    // -------------------------------------------------------------------------
-    // Indicator Value
-    // -------------------------------------------------------------------------
-
-    protected double getIndicatorValue( ExportItem exportItem, OrganisationUnit organisationUnit )
-    {
-        double value = 0.0;
-
-        if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) )
-        {
-            value = calculateExpression( generateIndicatorExpression( exportItem, startDate, startDate,
-                organisationUnit, indicatorService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) )
-        {
-            value = calculateExpression( generateIndicatorExpression( exportItem, startDate, endDate, organisationUnit,
-                indicatorService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_3_MONTH ) )
-        {
-            value = calculateExpression( generateIndicatorExpression( exportItem, last3MonthStartDate,
-                last3MonthEndDate, organisationUnit, indicatorService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_YEAR ) )
-        {
-            value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endDate,
-                organisationUnit, indicatorService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_6_MONTH ) )
-        {
-            value = calculateExpression( generateIndicatorExpression( exportItem, last6MonthStartDate,
-                last6MonthEndDate, organisationUnit, indicatorService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) )
-        {
-            value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endDateOfYear,
-                organisationUnit, indicatorService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) )
-        {
-            value = calculateExpression( generateIndicatorExpression( exportItem, startQuaterly, endQuaterly,
-                organisationUnit, indicatorService, aggregationService ) );
-        }
-        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SIX_MONTH ) )
-        {
-            value = calculateExpression( generateIndicatorExpression( exportItem, startSixMonthly, endSixMonthly,
-                organisationUnit, indicatorService, aggregationService ) );
-        }
-
-        return value;
-    }
-
-    // -------------------------------------------------------------------------
-    // Formulae methods
-    // -------------------------------------------------------------------------
-
-    protected void recalculatingFormula( Sheet sheet )
-    {
-        for ( Row row : sheet )
-        {
-            for ( Cell cell : row )
-            {
-                if ( (cell != null) && (cell.getCellType() == Cell.CELL_TYPE_FORMULA) )
-                {
-                    this.evaluatorFormula.evaluateFormulaCell( cell );
-                }
-            }
-        }
-    }
-
-    protected void complete()
-        throws IOException
-    {
-        this.templateWorkbook.write( outputStreamExcelTemplate );
-
-        this.outputStreamExcelTemplate.close();
-
-        selectionManager.setDownloadFilePath( outputReportFile.getPath() );
-    }
-
 }

=== added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateMultiExcelReportSupport.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateMultiExcelReportSupport.java	1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateMultiExcelReportSupport.java	2012-05-03 10:04:29 +0000
@@ -0,0 +1,102 @@
+package org.hisp.dhis.reportsheet.exporting;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.dataelement.LocalDataElementService;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.reportsheet.ExportReport;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public abstract class AbstractGenerateMultiExcelReportSupport
+    extends GenerateExcelReportGeneric
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    @Autowired
+    protected LocalDataElementService localDataElementService;
+
+    @Autowired
+    protected OrganisationUnitService organisationUnitService;
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        statementManager.initialise();
+
+        Period period = PeriodType.createPeriodExternalId( selectionManager.getSelectedPeriodIndex() );
+
+        this.installPeriod( period );
+
+        List<ExportReport> reports = new ArrayList<ExportReport>();
+
+        for ( String id : selectionManager.getListObject() )
+        {
+            reports.add( exportReportService.getExportReport( Integer.parseInt( id ) ) );
+        }
+
+        executeGenerateOutputFile( reports, period );
+
+        this.complete();
+
+        statementManager.destroy();
+
+        return SUCCESS;
+    }
+
+    // -------------------------------------------------------------------------
+    // Overriding abstract method(s)
+    // -------------------------------------------------------------------------
+
+    /**
+     * The process method which must be implemented by subclasses.
+     * 
+     * @param period
+     * @param reports
+     * @param organisationUnit
+     */
+    protected abstract void executeGenerateOutputFile( List<ExportReport> reports, Period period )
+        throws Exception;
+}

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java	2012-04-19 03:58:49 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java	2012-05-03 10:04:29 +0000
@@ -26,7 +26,18 @@
  */
 package org.hisp.dhis.reportsheet.exporting;
 
+import static org.hisp.dhis.reportsheet.utils.DateUtils.getEndQuaterly;
+import static org.hisp.dhis.reportsheet.utils.DateUtils.getEndSixMonthly;
+import static org.hisp.dhis.reportsheet.utils.DateUtils.getFirstDayOfMonth;
+import static org.hisp.dhis.reportsheet.utils.DateUtils.getFirstDayOfYear;
+import static org.hisp.dhis.reportsheet.utils.DateUtils.getLastDayOfYear;
+import static org.hisp.dhis.reportsheet.utils.DateUtils.getStartQuaterly;
+import static org.hisp.dhis.reportsheet.utils.DateUtils.getStartSixMonthly;
+import static org.hisp.dhis.reportsheet.utils.DateUtils.getTimeRoll;
+import static org.hisp.dhis.reportsheet.utils.ExpressionUtils.generateExpression;
+import static org.hisp.dhis.reportsheet.utils.ExpressionUtils.generateIndicatorExpression;
 import static org.hisp.dhis.reportsheet.utils.FileUtils.checkingExtensionExcelFile;
+import static org.hisp.dhis.system.util.MathUtils.calculateExpression;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -35,15 +46,20 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
 import java.util.Date;
 
 import org.amplecode.quick.StatementManager;
 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.DataFormat;
 import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 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.xssf.usermodel.XSSFWorkbook;
@@ -55,13 +71,22 @@
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.period.DailyPeriodType;
+import org.hisp.dhis.period.MonthlyPeriodType;
+import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.QuarterlyPeriodType;
+import org.hisp.dhis.period.YearlyPeriodType;
+import org.hisp.dhis.reportsheet.ExportItem;
 import org.hisp.dhis.reportsheet.ExportReport;
 import org.hisp.dhis.reportsheet.ExportReportService;
 import org.hisp.dhis.reportsheet.ReportLocationManager;
 import org.hisp.dhis.reportsheet.preview.manager.InitializePOIStylesManager;
 import org.hisp.dhis.reportsheet.state.SelectionManager;
+import org.hisp.dhis.reportsheet.utils.ExcelUtils;
 import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -314,8 +339,275 @@
 
     }
 
+    protected void installPeriod( Period period )
+    {
+        Calendar calendar = Calendar.getInstance();
+
+        // Monthly period
+        startDate = period.getStartDate();
+        endDate = period.getEndDate();
+
+        // So-far-this-month
+        firstDayOfMonth = getFirstDayOfMonth( startDate );
+        firstDayOfMonth = getTimeRoll( firstDayOfMonth, Calendar.DATE, -1 );
+
+        // Last 3 month period
+        // Last 2 months + this month = last 3 month
+        last3MonthStartDate = getTimeRoll( startDate, Calendar.MONTH, -2 );
+        last3MonthStartDate = getTimeRoll( last3MonthStartDate, Calendar.DATE, -1 );
+        last3MonthEndDate = period.getEndDate();
+
+        // So far this year period
+        calendar.setTime( endDate );
+
+        firstDayOfYear = getFirstDayOfYear( calendar.get( Calendar.YEAR ) );
+        firstDayOfYear = getTimeRoll( firstDayOfYear, Calendar.DATE, -1 );
+        endDateOfYear = getLastDayOfYear( calendar.get( Calendar.YEAR ) );
+
+        // Last 6 month period
+        // Last 5 months + this month = last 6 month
+        last6MonthStartDate = getTimeRoll( startDate, Calendar.MONTH, -5 );
+        last6MonthStartDate = getTimeRoll( last6MonthStartDate, Calendar.DATE, -1 );
+        last6MonthEndDate = period.getEndDate();
+
+        // Quarterly
+        startQuaterly = getStartQuaterly( startDate );
+        startQuaterly = getTimeRoll( startQuaterly, Calendar.DATE, -1 );
+        endQuaterly = getEndQuaterly( startDate );
+
+        // Six monthly
+        startSixMonthly = getStartSixMonthly( startDate );
+        startSixMonthly = getTimeRoll( startSixMonthly, Calendar.DATE, -1 );
+        endSixMonthly = getEndSixMonthly( startDate );
+    }
+
+    protected void installReadTemplateFile( ExportReport exportReport, Period period, Object object )
+        throws Exception
+    {
+        Calendar calendar = Calendar.getInstance();
+
+        File reportTempDir = reportLocationManager.getExportReportTemporaryDirectory();
+
+        this.outputReportFile = new File( reportTempDir, currentUserService.getCurrentUsername()
+            + this.dateformatter.format( calendar.getTime() ) + exportReport.getExcelTemplateFile() );
+
+        this.outputStreamExcelTemplate = new FileOutputStream( outputReportFile );
+
+        this.createWorkbookInstance( exportReport );
+
+        this.initExcelFormat();
+
+        this.installDefaultExcelFormat();
+
+        if ( exportReport.getOrganisationRow() != null && exportReport.getOrganisationColumn() != null )
+        {
+            String value = "";
+
+            if ( object instanceof OrganisationUnit )
+            {
+                OrganisationUnit orgunit = (OrganisationUnit) object;
+
+                value = orgunit.getName();
+            }
+            else
+            {
+                OrganisationUnitGroup orgunitGroup = (OrganisationUnitGroup) object;
+
+                value = orgunitGroup.getName();
+            }
+
+            ExcelUtils.writeValueByPOI( exportReport.getOrganisationRow(), exportReport.getOrganisationColumn(), value,
+                ExcelUtils.TEXT, templateWorkbook.getSheetAt( 0 ), csText );
+        }
+
+        if ( exportReport.getPeriodRow() != null && exportReport.getPeriodColumn() != null )
+        {
+            ExcelUtils.writeValueByPOI( exportReport.getPeriodRow(), exportReport.getPeriodColumn(), format
+                .formatPeriod( period ), ExcelUtils.TEXT, templateWorkbook.getSheetAt( 0 ), csText );
+        }
+    }
+
+    // -------------------------------------------------------------------------
+    // DataElement Value
+    // -------------------------------------------------------------------------
+
+    protected String getTextValue( ExportItem exportItem, OrganisationUnit organisationUnit )
+    {
+        String result = "";
+        Collection<Period> periods = new ArrayList<Period>();
+
+        if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) )
+        {
+            periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( DailyPeriodType.NAME ),
+                startDate, startDate );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) )
+        {
+            periods = periodService.getPeriodsBetweenDates(
+                periodService.getPeriodTypeByName( MonthlyPeriodType.NAME ), startDate, endDate );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) )
+        {
+            periods = periodService.getPeriodsBetweenDates( periodService
+                .getPeriodTypeByName( QuarterlyPeriodType.NAME ), startQuaterly, endQuaterly );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) )
+        {
+            periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( YearlyPeriodType.NAME ),
+                firstDayOfYear, endDateOfYear );
+        }
+
+        for ( Period p : periods )
+        {
+            result += generateExpression( exportItem, p, organisationUnit, dataElementService, categoryService,
+                dataValueService )
+                + "\n";
+        }
+
+        return result;
+    }
+
+    protected double getDataValue( ExportItem exportItem, OrganisationUnit organisationUnit )
+    {
+        double value = 0.0;
+
+        if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, startDate, startDate, organisationUnit,
+                dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_MONTH ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, firstDayOfMonth, endDate, organisationUnit,
+                dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_QUARTER ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, startQuaterly, endDate, organisationUnit,
+                dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, startDate, endDate, organisationUnit,
+                dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_3_MONTH ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, last3MonthStartDate, last3MonthEndDate,
+                organisationUnit, dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_6_MONTH ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, last6MonthStartDate, last6MonthEndDate,
+                organisationUnit, dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, startQuaterly, endQuaterly, organisationUnit,
+                dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SIX_MONTH ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, startSixMonthly, endSixMonthly,
+                organisationUnit, dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_YEAR ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endDate, organisationUnit,
+                dataElementService, categoryService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) )
+        {
+            value = calculateExpression( generateExpression( exportItem, firstDayOfYear, endDateOfYear,
+                organisationUnit, dataElementService, categoryService, aggregationService ) );
+        }
+
+        return value;
+    }
+
+    // -------------------------------------------------------------------------
+    // Indicator Value
+    // -------------------------------------------------------------------------
+
+    protected double getIndicatorValue( ExportItem exportItem, OrganisationUnit organisationUnit )
+    {
+        double value = 0.0;
+
+        if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) )
+        {
+            value = calculateExpression( generateIndicatorExpression( exportItem, startDate, startDate,
+                organisationUnit, indicatorService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) )
+        {
+            value = calculateExpression( generateIndicatorExpression( exportItem, startDate, endDate, organisationUnit,
+                indicatorService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_3_MONTH ) )
+        {
+            value = calculateExpression( generateIndicatorExpression( exportItem, last3MonthStartDate,
+                last3MonthEndDate, organisationUnit, indicatorService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SO_FAR_THIS_YEAR ) )
+        {
+            value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endDate,
+                organisationUnit, indicatorService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.LAST_6_MONTH ) )
+        {
+            value = calculateExpression( generateIndicatorExpression( exportItem, last6MonthStartDate,
+                last6MonthEndDate, organisationUnit, indicatorService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) )
+        {
+            value = calculateExpression( generateIndicatorExpression( exportItem, firstDayOfYear, endDateOfYear,
+                organisationUnit, indicatorService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) )
+        {
+            value = calculateExpression( generateIndicatorExpression( exportItem, startQuaterly, endQuaterly,
+                organisationUnit, indicatorService, aggregationService ) );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SIX_MONTH ) )
+        {
+            value = calculateExpression( generateIndicatorExpression( exportItem, startSixMonthly, endSixMonthly,
+                organisationUnit, indicatorService, aggregationService ) );
+        }
+
+        return value;
+    }
+
+    // -------------------------------------------------------------------------
+    // Formulae methods
+    // -------------------------------------------------------------------------
+
     public void initFormulaEvaluating()
     {
         this.evaluatorFormula = this.templateWorkbook.getCreationHelper().createFormulaEvaluator();
     }
+
+    protected void recalculatingFormula( Sheet sheet )
+    {
+        for ( Row row : sheet )
+        {
+            for ( Cell cell : row )
+            {
+                if ( (cell != null) && (cell.getCellType() == Cell.CELL_TYPE_FORMULA) )
+                {
+                    this.evaluatorFormula.evaluateFormulaCell( cell );
+                }
+            }
+        }
+    }
+
+    protected void complete()
+        throws IOException
+    {
+        this.templateWorkbook.write( outputStreamExcelTemplate );
+
+        this.outputStreamExcelTemplate.close();
+
+        selectionManager.setDownloadFilePath( outputReportFile.getPath() );
+    }
+
 }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java	2012-04-19 03:58:49 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateExcelReportFlowAction.java	2012-05-03 10:04:29 +0000
@@ -46,10 +46,10 @@
     // Dependency
     // -------------------------------------------------------------------------
 
-	@Autowired
+    @Autowired
     private ExportReportService exportReportService;
 
-	@Autowired
+    @Autowired
     private SelectionManager selectionManager;
 
     // -------------------------------------------------------------------------
@@ -75,7 +75,14 @@
     public String execute()
         throws Exception
     {
-        ExportReport exportReport = exportReportService.getExportReport( selectionManager.getSelectedReportId() );
+        Integer reportId = selectionManager.getSelectedReportId();
+        
+        if ( reportId == null )
+        {
+            return "MULTI";
+        }
+        
+        ExportReport exportReport = exportReportService.getExportReport( reportId );
 
         return exportReport.getReportType();
     }

=== added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateMultiReportAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateMultiReportAction.java	1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateMultiReportAction.java	2012-05-03 10:04:29 +0000
@@ -0,0 +1,649 @@
+package org.hisp.dhis.reportsheet.exporting.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.hisp.dhis.expression.Expression.SEPARATOR;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.poi.ss.usermodel.Sheet;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOption;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementFormNameComparator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.reportsheet.AttributeValueGroupOrder;
+import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder;
+import org.hisp.dhis.reportsheet.DataElementGroupOrder;
+import org.hisp.dhis.reportsheet.ExportItem;
+import org.hisp.dhis.reportsheet.ExportReport;
+import org.hisp.dhis.reportsheet.ExportReportAttribute;
+import org.hisp.dhis.reportsheet.ExportReportCategory;
+import org.hisp.dhis.reportsheet.ExportReportOrganizationGroupListing;
+import org.hisp.dhis.reportsheet.ExportReportPeriodColumnListing;
+import org.hisp.dhis.reportsheet.ExportReportVerticalCategory;
+import org.hisp.dhis.reportsheet.PeriodColumn;
+import org.hisp.dhis.reportsheet.exporting.AbstractGenerateMultiExcelReportSupport;
+import org.hisp.dhis.reportsheet.utils.ExcelUtils;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class GenerateMultiReportAction
+    extends AbstractGenerateMultiExcelReportSupport
+{
+    private static final String PREFIX_FORMULA_SUM = "SUM(";
+
+    @Override
+    protected void executeGenerateOutputFile( List<ExportReport> reports, Period period )
+        throws Exception
+    {
+        OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit();
+        DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+        Collection<ExportItem> exportItems = null;
+        
+        this.installReadTemplateFile( reports.get( 0 ), period, organisationUnit );
+
+        for ( ExportReport report : reports )
+        {            
+            for ( Integer sheetNo : exportReportService.getSheets( report.getId() ) )
+            {
+                Sheet sheet = this.templateWorkbook.getSheetAt( sheetNo - 1 );
+
+                exportItems = report.getExportItemBySheet( sheetNo );
+
+                if ( report.getReportType().equals( ExportReport.TYPE.NORMAL ) )
+                {
+                    this.generateNormal( exportItems, organisationUnit, sheet );
+                }
+                else if ( report.getReportType().equals( ExportReport.TYPE.ATTRIBUTE ) )
+                {
+                    this.generateAttribute( defaultOptionCombo, (ExportReportAttribute) report, exportItems,
+                        organisationUnit, sheet );
+                }
+                else if ( report.getReportType().equals( ExportReport.TYPE.CATEGORY ) )
+                {
+                    if ( isVerticalCategory( exportItems ) )
+                    {
+                        this.generateVerticalOutPutFile( (ExportReportCategory) report, exportItems, organisationUnit,
+                            sheet );
+                    }
+                    else
+                    {
+                        this.generateHorizontalOutPutFile( (ExportReportCategory) report, exportItems,
+                            organisationUnit, sheet );
+                    }
+                }
+                else if ( report.getReportType().equals( ExportReport.TYPE.CATEGORY_VERTICAL ) )
+                {
+                    this.generateCategoryVertical( (ExportReportVerticalCategory) report, exportItems,
+                        organisationUnit, sheet );
+                }
+                else if ( report.getReportType().equals( ExportReport.TYPE.ORGANIZATION_GROUP_LISTING ) )
+                {
+                    ExportReportOrganizationGroupListing reportInstance = (ExportReportOrganizationGroupListing) report;
+
+                    Map<OrganisationUnitGroup, OrganisationUnitLevel> orgUniGroupAtLevels = new HashMap<OrganisationUnitGroup, OrganisationUnitLevel>(
+                        reportInstance.getOrganisationUnitLevels() );
+
+                    this.generateOrgUnitListing( reportInstance, orgUniGroupAtLevels, exportItems, organisationUnit,
+                        sheet );
+                }
+                else
+                {
+                    ExportReportPeriodColumnListing reportInstance = (ExportReportPeriodColumnListing) report;
+
+                    this
+                        .generatePeriodListing( reportInstance.getPeriodColumns(), exportItems, organisationUnit, sheet );
+                }
+            }
+        }
+    }
+
+    // -------------------------------------------------------------------------
+    // Supportive method
+    // -------------------------------------------------------------------------
+
+    private void generateNormal( Collection<ExportItem> exportItems, OrganisationUnit organisationUnit, Sheet sheet )
+    {
+        for ( ExportItem reportItem : exportItems )
+        {
+            if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+            {
+                double value = getDataValue( reportItem, organisationUnit );
+
+                ExcelUtils.writeValueByPOI( reportItem.getRow(), reportItem.getColumn(), String.valueOf( value ),
+                    ExcelUtils.NUMBER, sheet, this.csNumber );
+            }
+            else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_VALUETYPE_TEXT ) )
+            {
+                String value = getTextValue( reportItem, organisationUnit );
+
+                ExcelUtils.writeValueByPOI( reportItem.getRow(), reportItem.getColumn(), value, ExcelUtils.TEXT, sheet,
+                    this.csText );
+            }
+            else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
+            {
+                double value = getIndicatorValue( reportItem, organisationUnit );
+
+                ExcelUtils.writeValueByPOI( reportItem.getRow(), reportItem.getColumn(), String.valueOf( value ),
+                    ExcelUtils.NUMBER, sheet, this.csNumber );
+            }
+            else
+            // EXCEL FORMULA
+            {
+                ExcelUtils.writeFormulaByPOI( reportItem.getRow(), reportItem.getColumn(), reportItem.getExpression(),
+                    sheet, this.csFormula );
+            }
+        }
+    }
+
+    private void generateAttribute( DataElementCategoryOptionCombo optionCombo, ExportReportAttribute exportReport,
+        Collection<ExportItem> exportItems, OrganisationUnit organisationUnit, Sheet sheet )
+    {
+        boolean flag = false;
+        int rowBegin = 0;
+
+        for ( AttributeValueGroupOrder avgOrder : exportReport.getAttributeValueOrders() )
+        {
+            int serial = 1;
+            List<DataElement> dataElements = null;
+
+            flag = true;
+
+            for ( String avalue : avgOrder.getAttributeValues() )
+            {
+                dataElements = new ArrayList<DataElement>( localDataElementService.getDataElementsByAttribute( avgOrder
+                    .getAttribute(), avalue ) );
+
+                Collections.sort( dataElements, new DataElementFormNameComparator() );
+
+                for ( ExportItem exportItem : exportItems )
+                {
+                    rowBegin = (rowBegin == 0 ? exportItem.getRow() : exportItem.getRow() + rowBegin - 1);
+
+                    if ( flag )
+                    {
+                        if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+                        {
+                            ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avgOrder.getName(),
+                                ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
+                        }
+
+                        rowBegin++;
+                    }
+
+                    if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avalue, ExcelUtils.TEXT, sheet,
+                            this.csText10Bold );
+                    }
+                    else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), serial + "", ExcelUtils.NUMBER,
+                            sheet, this.csTextSerial );
+                    }
+                    else
+                    {
+                        int id = Integer.parseInt( exportItem.getExpression().split( "@" )[0] );
+                        String value = exportItem.getExpression().split( "@" )[1];
+
+                        for ( DataElement de : dataElements )
+                        {
+                            if ( localDataElementService.getDataElementCount( de.getId(), id, value ) > 0 )
+                            {
+                                ExportItem newExportItem = new ExportItem();
+
+                                newExportItem.setPeriodType( exportItem.getPeriodType() );
+                                newExportItem.setExpression( de.getId() + SEPARATOR + optionCombo.getId() );
+
+                                double result = this.getDataValue( newExportItem, organisationUnit );
+
+                                ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), result + "",
+                                    ExcelUtils.NUMBER, sheet, this.csNumber );
+
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                flag = false;
+                rowBegin++;
+                serial++;
+            }
+        }
+    }
+
+    private void generateVerticalOutPutFile( ExportReportCategory exportReport, Collection<ExportItem> exportItems,
+        OrganisationUnit organisationUnit, Sheet sheet )
+    {
+        for ( ExportItem reportItem : exportItems )
+        {
+            int run = 0;
+            int rowBegin = reportItem.getRow();
+
+            for ( DataElementGroupOrder dataElementGroup : exportReport.getDataElementOrders() )
+            {
+                int beginChapter = rowBegin;
+
+                if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+                {
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), dataElementGroup.getName(),
+                        ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
+                }
+                else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_CODE ) )
+                {
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), dataElementGroup.getCode(),
+                        ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
+                }
+
+                run++;
+                rowBegin++;
+                int serial = 1;
+
+                for ( DataElement dataElement : dataElementGroup.getDataElements() )
+                {
+                    if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), dataElement.getName(),
+                            ExcelUtils.TEXT, sheet, this.csText10Bold );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_CODE ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), dataElement.getCode(),
+                            ExcelUtils.TEXT, sheet, this.csTextICDJustify );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ),
+                            ExcelUtils.NUMBER, sheet, this.csTextSerial );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) )
+                    {
+                        ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils
+                            .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula );
+                    }
+                    else
+                    {
+                        ExportItem newReportItem = new ExportItem();
+
+                        String expression = reportItem.getExpression();
+                        expression = expression.replace( "*", String.valueOf( dataElement.getId() ) );
+
+                        newReportItem.setPeriodType( reportItem.getPeriodType() );
+                        newReportItem.setExpression( expression );
+
+                        double value = this.getDataValue( newReportItem, organisationUnit );
+
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( value ),
+                            ExcelUtils.NUMBER, sheet, this.csNumber );
+
+                    }
+
+                    rowBegin++;
+                    serial++;
+                    run++;
+                }
+
+                if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+                {
+                    String columnName = ExcelUtils.convertColumnNumberToName( reportItem.getColumn() );
+                    String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")";
+
+                    ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, this.csFormula );
+                }
+            }
+        }
+    }
+
+    private void generateHorizontalOutPutFile( ExportReportCategory exportReport, Collection<ExportItem> exportItems,
+        OrganisationUnit organisationUnit, Sheet sheet )
+    {
+        for ( ExportItem reportItem : exportItems )
+        {
+            int colBegin = reportItem.getColumn();
+
+            for ( DataElementGroupOrder dataElementGroup : exportReport.getDataElementOrders() )
+            {
+                for ( DataElement dataElement : dataElementGroup.getDataElements() )
+                {
+                    if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+                    {
+                        ExportItem newReportItem = new ExportItem();
+                        newReportItem.setColumn( reportItem.getColumn() );
+                        newReportItem.setRow( reportItem.getRow() );
+                        newReportItem.setPeriodType( reportItem.getPeriodType() );
+                        newReportItem.setName( reportItem.getName() );
+                        newReportItem.setSheetNo( reportItem.getSheetNo() );
+                        newReportItem.setItemType( reportItem.getItemType() );
+
+                        String expression = reportItem.getExpression();
+                        expression = expression.replace( "*", String.valueOf( dataElement.getId() ) );
+                        newReportItem.setExpression( expression );
+
+                        double value = this.getDataValue( newReportItem, organisationUnit );
+
+                        ExcelUtils.writeValueByPOI( reportItem.getRow(), colBegin++, String.valueOf( value ),
+                            ExcelUtils.NUMBER, sheet, this.csNumber );
+                    }
+                }
+            }
+        }
+    }
+
+    private boolean isVerticalCategory( Collection<ExportItem> items )
+    {
+        Integer previousRow = null;
+
+        for ( ExportItem item : items )
+        {
+            if ( previousRow != null && previousRow != item.getRow() )
+            {
+                return false;
+            }
+
+            previousRow = item.getRow();
+        }
+
+        return true;
+    }
+
+    private void generateCategoryVertical( ExportReportVerticalCategory exportReport,
+        Collection<ExportItem> exportItems, OrganisationUnit organisationUnit, Sheet sheet )
+    {
+        DataElement de = null;
+        Set<DataElementCategoryOptionCombo> optionCombos = new HashSet<DataElementCategoryOptionCombo>();
+
+        for ( ExportItem reportItem : exportItems )
+        {
+            int run = 0;
+            int rowBegin = reportItem.getRow();
+
+            if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+            {
+                de = dataElementService.getDataElement( Integer.parseInt( reportItem.getExpression().split(
+                    "\\" + SEPARATOR )[0].replace( "[", "" ) ) );
+
+                optionCombos = de.getCategoryCombo().getOptionCombos();
+            }
+
+            for ( CategoryOptionGroupOrder group : exportReport.getCategoryOptionGroupOrders() )
+            {
+                int beginChapter = rowBegin;
+
+                if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+                {
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), group.getName(), ExcelUtils.TEXT,
+                        sheet, this.csText12BoldCenter );
+                }
+
+                run++;
+                rowBegin++;
+                int serial = 1;
+
+                for ( DataElementCategoryOption categoryOption : group.getCategoryOptions() )
+                {
+                    if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), categoryOption.getName(),
+                            ExcelUtils.TEXT, sheet, this.csText10Bold );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ),
+                            ExcelUtils.NUMBER, sheet, this.csTextSerial );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) )
+                    {
+                        ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils
+                            .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula );
+                    }
+                    else
+                    {
+                        for ( DataElementCategoryOptionCombo optionCombo : optionCombos )
+                        {
+                            if ( optionCombo.getCategoryOptions().contains( categoryOption ) )
+                            {
+                                ExportItem newReportItem = new ExportItem();
+
+                                String expression = reportItem.getExpression();
+                                expression = expression.replace( "*", String.valueOf( optionCombo.getId() ) );
+
+                                newReportItem.setPeriodType( reportItem.getPeriodType() );
+                                newReportItem.setExpression( expression );
+
+                                double value = this.getDataValue( newReportItem, organisationUnit );
+
+                                ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( value ),
+                                    ExcelUtils.NUMBER, sheet, this.csNumber );
+
+                                break;
+                            }
+                        }
+                    }
+
+                    rowBegin++;
+                    serial++;
+                    run++;
+                }
+
+                if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+                {
+                    String columnName = ExcelUtils.convertColumnNumberToName( reportItem.getColumn() );
+                    String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")";
+
+                    ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, this.csFormula );
+                }
+            }
+        }
+    }
+
+    private void generateOrgUnitListing( ExportReportOrganizationGroupListing exportReport,
+        Map<OrganisationUnitGroup, OrganisationUnitLevel> orgUniGroupAtLevels, Collection<ExportItem> exportItems,
+        OrganisationUnit organisationUnit, Sheet sheet )
+    {
+        List<OrganisationUnit> childrens = new ArrayList<OrganisationUnit>( organisationUnit.getChildren() );
+
+        for ( ExportItem reportItem : exportItems )
+        {
+            int run = 0;
+            int next = 0;
+            int chapperNo = 0;
+            int firstRow = reportItem.getRow();
+            int rowBegin = firstRow + 1;
+
+            String totalFormula = PREFIX_FORMULA_SUM;
+
+            for ( OrganisationUnitGroup organisationUnitGroup : exportReport.getOrganisationUnitGroups() )
+            {
+                List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitGroup
+                    .getMembers() );
+
+                OrganisationUnitLevel organisationUnitLevel = orgUniGroupAtLevels.get( organisationUnitGroup );
+
+                if ( organisationUnitLevel != null )
+                {
+                    List<OrganisationUnit> organisationUnitsAtLevel = new ArrayList<OrganisationUnit>(
+                        organisationUnitService.getOrganisationUnitsAtLevel( organisationUnitLevel.getLevel(),
+                            organisationUnit ) );
+
+                    organisationUnits.retainAll( organisationUnitsAtLevel );
+                }
+                else
+                {
+                    organisationUnits.retainAll( childrens );
+                }
+
+                Collections.sort( organisationUnits, new IdentifiableObjectNameComparator() );
+
+                int beginChapter = rowBegin;
+
+                if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION )
+                    && (!organisationUnits.isEmpty()) )
+                {
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), organisationUnitGroup.getName(),
+                        ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
+                }
+                else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL )
+                    && (!organisationUnits.isEmpty()) )
+                {
+                    ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo++],
+                        ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
+                }
+
+                run++;
+                rowBegin++;
+                int serial = 1;
+
+                for ( OrganisationUnit o : organisationUnits )
+                {
+                    if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), o.getName(), ExcelUtils.TEXT,
+                            sheet, this.csText10Bold );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
+                    {
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), serial + "", ExcelUtils.NUMBER,
+                            sheet, this.csTextSerial );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+                    {
+                        double value = this.getDataValue( reportItem, o );
+
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), value + "", ExcelUtils.NUMBER,
+                            sheet, this.csNumber );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
+                    {
+                        double value = this.getIndicatorValue( reportItem, o );
+
+                        ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), value + "", ExcelUtils.NUMBER,
+                            sheet, this.csNumber );
+                    }
+                    else
+                    // FORMULA_EXCEL
+                    {
+                        ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils
+                            .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, this.csFormula );
+                    }
+
+                    run++;
+                    rowBegin++;
+                    serial++;
+                }
+
+                if ( !organisationUnits.isEmpty() )
+                {
+                    String formula = "";
+
+                    if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+                    {
+                        String columnName = ExcelUtils.convertColumnNumberToName( reportItem.getColumn() );
+                        formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")";
+
+                        ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet,
+                            this.csFormula );
+
+                        totalFormula += columnName + beginChapter + ",";
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
+                    {
+                        formula = ExcelUtils.generateExcelFormula( reportItem.getExtraExpression(), next + 1, 0 );
+
+                        ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet,
+                            this.csFormula );
+                    }
+                }
+
+                next = run;
+            }
+
+            if ( (reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ))
+                && !totalFormula.equals( PREFIX_FORMULA_SUM ) )
+            {
+                totalFormula = totalFormula.substring( 0, totalFormula.length() - 1 ) + ")";
+
+                ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula );
+            }
+            else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
+            {
+                totalFormula = ExcelUtils.generateExcelFormula( reportItem.getExtraExpression(), 0, 0 );
+
+                ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula );
+            }
+        }
+    }
+
+    private void generatePeriodListing( Set<PeriodColumn> periodColumns, Collection<ExportItem> exportItems,
+        OrganisationUnit organisationUnit, Sheet sheet )
+    {
+        for ( ExportItem reportItem : exportItems )
+        {
+            for ( PeriodColumn p : periodColumns )
+            {
+                if ( p.getPeriodType().equals( reportItem.getPeriodType() ) )
+                {
+                    double value = 0.0;
+
+                    if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+                    {
+                        value = this.getDataValue( reportItem, organisationUnit );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_VALUETYPE_TEXT ) )
+                    {
+                        String result = this.getTextValue( reportItem, organisationUnit );
+
+                        ExcelUtils.writeValueByPOI( reportItem.getRow(), reportItem.getColumn(), result,
+                            ExcelUtils.TEXT, sheet, this.csText );
+                    }
+                    else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
+                    {
+                        value = this.getIndicatorValue( reportItem, organisationUnit );
+                    }
+
+                    ExcelUtils.writeValueByPOI( reportItem.getRow(), p.getColumn(), String.valueOf( value ),
+                        ExcelUtils.NUMBER, sheet, this.csNumber );
+                }
+            }
+        }
+    }
+}

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java	2012-04-29 09:57:26 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java	2012-05-03 10:04:29 +0000
@@ -86,7 +86,7 @@
     // Supportive method
     // -------------------------------------------------------------------------
 
-    private void generateOutPutFile( DataElementCategoryOptionCombo optionCombo, ExportReportAttribute exportReport,
+    public void generateOutPutFile( DataElementCategoryOptionCombo optionCombo, ExportReportAttribute exportReport,
         Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
     {
         boolean flag = false;

=== 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-04-29 09:57:26 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.java	2012-05-03 10:04:29 +0000
@@ -80,7 +80,7 @@
     // Supportive method
     // -------------------------------------------------------------------------
 
-    private void generateVerticalOutPutFile( ExportReportCategory exportReport,
+    public void generateVerticalOutPutFile( ExportReportCategory exportReport,
         Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
     {
         for ( ExportItem reportItem : exportReportItems )
@@ -162,7 +162,7 @@
         }
     }
 
-    private void generateHorizontalOutPutFile( ExportReportCategory exportReport,
+    public void generateHorizontalOutPutFile( ExportReportCategory exportReport,
         Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
     {
         for ( ExportItem reportItem : exportReportItems )
@@ -197,7 +197,7 @@
         }
     }
 
-    private boolean isVerticalCategory( Collection<ExportItem> items )
+    public boolean isVerticalCategory( Collection<ExportItem> items )
     {
         Integer previousRow = null;
 

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java	2012-04-27 10:13:06 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java	2012-05-03 10:04:29 +0000
@@ -71,7 +71,7 @@
     // Supportive method
     // -------------------------------------------------------------------------
 
-    private void generateOutPutFile( Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit,
+    public void generateOutPutFile( Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit,
         Sheet sheet )
     {
         for ( ExportItem reportItem : exportReportItems )

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java	2012-04-16 03:00:30 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java	2012-05-03 10:04:29 +0000
@@ -97,7 +97,7 @@
     // Supportive method
     // -------------------------------------------------------------------------
 
-    private void generateOutPutFile( ExportReportOrganizationGroupListing exportReport,
+    public void generateOutPutFile( ExportReportOrganizationGroupListing exportReport,
         Map<OrganisationUnitGroup, OrganisationUnitLevel> orgUniGroupAtLevels,
         Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
     {

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java	2012-04-27 10:13:06 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java	2012-05-03 10:04:29 +0000
@@ -74,7 +74,7 @@
     // Supportive method
     // -------------------------------------------------------------------------
 
-    private void generateOutPutFile( Set<PeriodColumn> periodColumns, Collection<ExportItem> exportReportItems,
+    public void generateOutPutFile( Set<PeriodColumn> periodColumns, Collection<ExportItem> exportReportItems,
         OrganisationUnit organisationUnit, Sheet sheet )
     {
         for ( ExportItem reportItem : exportReportItems )

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java	2012-04-29 09:57:26 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java	2012-05-03 10:04:29 +0000
@@ -75,7 +75,7 @@
     // Supportive method
     // -------------------------------------------------------------------------
 
-    private void generateVerticalOutPutFile( ExportReportVerticalCategory exportReport,
+    public void generateVerticalOutPutFile( ExportReportVerticalCategory exportReport,
         Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
     {
         DataElement de = null;

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java	2011-11-18 04:24:39 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java	2012-05-03 10:04:29 +0000
@@ -71,11 +71,11 @@
     // Input & Output
     // -------------------------------------------------------------------------
 
-    private String exportReportId;
+    private String[] exportReportIds;
 
-    public void setExportReportId( String exportReportId )
+    public void setExportReportIds( String[] exportReportIds )
     {
-        this.exportReportId = exportReportId;
+        this.exportReportIds = exportReportIds;
     }
 
     private String periodIndex;
@@ -92,21 +92,10 @@
     public String execute()
         throws Exception
     {
-        Integer reportId = Integer.parseInt( exportReportId.split( "_" )[0] );
-
-        ExportReport exportReport = exportReportService.getExportReport( reportId );
-
-        if ( exportReport == null )
-        {
-            message = i18n.getString( "the_specified_report_is_not_exist" );
-
-            return ERROR;
-        }
-
-        message = exportReportService.validateEmportItems( exportReport, i18n );
-
-        if ( message != null )
-        {
+        if ( exportReportIds == null || exportReportIds.length == 0 )
+        {
+            message = i18n.getString( "specify_export_report" );
+
             return ERROR;
         }
 
@@ -119,18 +108,46 @@
             return ERROR;
         }
 
-        File templateFile = new File( templateDirectory, exportReport.getExcelTemplateFile() );
-
-        if ( templateFile == null || !templateFile.exists() )
+        for ( String exportReportId : exportReportIds )
         {
-            message = i18n.getString( "template_file_is_not_exist" );
-
-            return ERROR;
+            Integer reportId = Integer.parseInt( exportReportId.split( "_" )[0] );
+
+            ExportReport exportReport = exportReportService.getExportReport( reportId );
+
+            if ( exportReport == null )
+            {
+                message = i18n.getString( "the_specified_report_is_not_exist" );
+
+                return ERROR;
+            }
+
+            message = exportReportService.validateEmportItems( exportReport, i18n );
+
+            if ( message != null )
+            {
+                return ERROR;
+            }
+
+            File templateFile = new File( templateDirectory, exportReport.getExcelTemplateFile() );
+
+            if ( templateFile == null || !templateFile.exists() )
+            {
+                message = i18n.getString( "template_file_is_not_exist" );
+
+                return ERROR;
+            }
         }
 
         selectionManager.setSelectedPeriodIndex( periodIndex );
 
-        selectionManager.setSelectedReportId( reportId );
+        if ( exportReportIds.length == 1 )
+        {
+            selectionManager.setSelectedReportId( Integer.parseInt( exportReportIds[0] ) );
+        }
+        else
+        {
+            selectionManager.setListObject( exportReportIds );
+        }
 
         return SUCCESS;
     }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/ExportXMLAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/ExportXMLAction.java	2011-08-04 08:39:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/ExportXMLAction.java	2012-05-03 10:04:29 +0000
@@ -1,7 +1,7 @@
 package org.hisp.dhis.reportsheet.preview.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
@@ -28,6 +28,8 @@
  */
 
 import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.hisp.dhis.reportsheet.ExportReportService;
 import org.hisp.dhis.reportsheet.state.SelectionManager;
@@ -87,15 +89,29 @@
     {
         try
         {
-            xmlStructureResponse = new XMLStructureResponse( selectionManager.getDownloadFilePath(),
-                exportReportService.getSheets( selectionManager.getSelectedReportId() ), false, false, true, false,
-                true ).getXml();
+            Set<Integer> sheets = new HashSet<Integer>();
+            Integer reportId = selectionManager.getSelectedReportId();
+
+            if ( reportId != null )
+            {
+                sheets = new HashSet<Integer>( exportReportService.getSheets( reportId ) );
+            }
+            else
+            {
+                for ( String id : selectionManager.getListObject() )
+                {
+                    sheets.addAll( exportReportService.getSheets( Integer.parseInt( id ) ) );
+                }
+            }
+
+            xmlStructureResponse = new XMLStructureResponse( selectionManager.getDownloadFilePath(), sheets, false,
+                false, true, false, true ).getXml();
 
             return SUCCESS;
         }
         catch ( Exception e )
         {
-            System.out.println( e.toString() );
+            System.out.println( "Error at previewing : " + e.getMessage() );
             return ERROR;
         }
     }

=== 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-04-06 06:21:25 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java	2012-05-03 10:04:29 +0000
@@ -1,7 +1,7 @@
 package org.hisp.dhis.reportsheet.preview.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
@@ -39,6 +39,7 @@
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Locale;
+import java.util.Set;
 
 import org.apache.poi.hssf.usermodel.HSSFPatternFormatting;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -120,7 +121,7 @@
      * @exception java.io.IOException
      */
 
-    public XMLStructureResponse( String pathFileName, Collection<Integer> collectSheets, boolean bWriteDTD,
+    public XMLStructureResponse( String pathFileName, Set<Integer> collectSheets, boolean bWriteDTD,
         boolean bWriteVersion, boolean bFormat, boolean bDetailed, boolean bWriteDescription )
         throws Exception
     {

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml	2012-04-26 19:11:23 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml	2012-05-03 10:04:29 +0000
@@ -578,6 +578,11 @@
 		class="org.hisp.dhis.reportsheet.exporting.action.GenerateReportPeriodColumnListingAction"
 		scope="prototype" />
 
+	<bean
+		id="org.hisp.dhis.reportsheet.exporting.action.GenerateMultiReportAction"
+		class="org.hisp.dhis.reportsheet.exporting.action.GenerateMultiReportAction"
+		scope="prototype" />
+
 	<!-- DATA ENTRY STATUS BEAN -->
 
 	<bean

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties	2012-04-29 09:57:26 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties	2012-05-03 10:04:29 +0000
@@ -325,4 +325,8 @@
 selected_list_should_not_empty = The selected list should not empty
 select_category				= Select category
 please_select_category		= Please select a category
-categoryoption_groups		= Category Option Groups
\ No newline at end of file
+categoryoption_groups		= Category Option Groups
+specify_export_report		= Please select report
+export_type					= Export type
+export_single				= Export a single report
+export_multi				= Export multi-reports
\ No newline at end of file

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties	2012-04-29 09:57:26 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties	2012-05-03 10:04:29 +0000
@@ -360,4 +360,8 @@
 attribute_with_id = Thu\u1ed9c t\u00ednh c\u00f3 m\u00e3
 select_category	= Ch\u1ecdn ph\u00e2n lo\u1ea1i
 please_select_category = H\u00e3y ch\u1ecdn ph\u00e2n lo\u1ea1i
-categoryoption_groups = Nh\u00f3m c\u00e1c Ph\u00e2n lo\u1ea1i 
\ No newline at end of file
+categoryoption_groups = Nh\u00f3m c\u00e1c Ph\u00e2n lo\u1ea1i
+specify_export_report = H\u00e3y ch\u1ecdn b\u00e1o c\u00e1o
+export_type	= Ki\u1ec3u xu\u1ea5t b\u00e1o c\u00e1o
+export_single = Xu\u1ea5t b\u00e1o c\u00e1o \u0111\u01a1n l\u1ebb
+export_multi = Xu\u1ea5t \u0111a b\u00e1o c\u00e1o
\ No newline at end of file

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml	2012-04-28 16:58:08 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml	2012-05-03 10:04:29 +0000
@@ -713,6 +713,8 @@
 				generateReportOrgGroupListing.action</result>
 			<result name="PERIOD_COLUMN_LISTING" type="redirect">
 				generateReportPeriodColumnListing.action</result>
+			<result name="MULTI" type="redirect">
+				generateMultiReport.action</result>
 		</action>
 
 		<action name="generateReportAttribute"
@@ -751,6 +753,12 @@
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 		</action>
 
+		<action name="generateMultiReport"
+			class="org.hisp.dhis.reportsheet.exporting.action.GenerateMultiReportAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+		</action>
+
 
 		<!-- DATA ENTRY STATUS ACTION -->
 
@@ -872,6 +880,8 @@
 				generatePreviewOrgGroupListing.action</result>
 			<result name="PERIOD_COLUMN_LISTING" type="redirect">
 				generatePreviewPeriodColumnListing.action</result>
+			<result name="MULTI" type="redirect">
+				generatePreviewMultiReport.action</result>
 		</action>
 
 		<action name="generatePreviewAttribute"
@@ -910,6 +920,12 @@
 			</result>
 		</action>
 
+		<action name="generatePreviewMultiReport"
+			class="org.hisp.dhis.reportsheet.exporting.action.GenerateMultiReportAction">
+			<result name="success" type="redirect">exportXML.action
+			</result>
+		</action>
+
 		<action name="exportXML"
 			class="org.hisp.dhis.reportsheet.preview.action.ExportXMLAction">
 			<result name="success" type="velocity-xml">

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm	2011-12-13 07:46:57 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm	2012-05-03 10:04:29 +0000
@@ -1,5 +1,5 @@
 <h3>$i18n.getString( "generate_export_report" ) #openHelp( "excelReportingExportReport" )</h3>
-<div class="inputCriteria" style="width:485px;height:93px;">
+<div id="exportReportDiv" class="inputCriteria" style="width:485px;height:120px;">
 <table>	
 	<tr>
 		<td><label>$i18n.getString('organisation')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
@@ -16,12 +16,30 @@
 		</td>
     </tr>
 	<tr>
+		<td><label>$i18n.getString('export_type')</label></td>
+		<td>
+			<select type="text" id="multiExport" name="multiExport" style="width:300px" onchange="changeExportType( this.value )">
+				<option value="0">$i18n.getString('export_single')</option>
+				<option value="1">$i18n.getString('export_multi')</option>
+			</select>
+		</td>
+    </tr>
+	<tr>
 		<td><label>$i18n.getString('export_reports')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
 			<select type="text" id="exportReport" name="exportReport" style="width:300px" onchange="reportSelected()"></select>
 		</td>
     </tr>
-	<tr>
+	<tr id="periodTypeRow">
+		<td><label>$i18n.getString('period_type')</label></td>
+		<td>
+			<select type="text" id="periodType" name="periodType" style="width:220px" onchange="reportSelected( this.value )">
+				<option value="Daily">$i18n.getString('Daily')</option>
+				<option value="Monthly">$i18n.getString('Monthly')</option>
+			</select>
+		</td>
+    </tr>
+	<tr id="periodRow">
 		<td><label>$i18n.getString('period')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
 			<select type="text" id="selectedPeriodId" name="selectedPeriodId" style="width:220px"></select>
@@ -48,10 +66,11 @@
 	var i18n_specify_export_report = '$encoder.jsEscape( $i18n.getString("specify_export_report"), "'" )';
 
 	#if ( $organisationUnit )
-		$(document).ready(function()
+		jQuery(document).ready(function()
 		{
 			currentOrgunitName = '$organisationUnit.name';
 			getExportReportsByGroup( currentOrgunitName );
+			changeExportType( 0 );
 		});
 	#end
 	

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js	2012-04-05 07:16:03 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js	2012-05-03 10:04:29 +0000
@@ -47,21 +47,51 @@
 	}
 }
 
-function reportSelected()
+function changeExportType( value )
 {
-	var value = getFieldValue( 'exportReport' );
+	if ( value == 0 )
+	{
+		byId( "exportReportDiv" ).style.height = "120px";
+		byId( "exportReport" ).multiple = false;
+		hideById( "periodTypeRow" );
+		reportSelected();
+	}
+	else
+	{
+		byId( "exportReportDiv" ).style.height = "200px";
+		byId( "exportReport" ).multiple = true;
+		showById( "periodTypeRow" );
+		reportSelected( getFieldValue( "periodType" ) );
+	}
 	
-	if ( value && value != null )
-	{
-		currentPeriodTypeName = (value.split( '_' )[1] == "true") ? 'Daily' : 'Monthly';
-		currentReportTypeName = value.split( '_' )[2];
-		
-		if ( currentReportTypeName == "P" ) { 
-			hideById( "periodRow" );
-		}else {
-			showById( "periodRow" );
+	displayPeriodsInternal();
+	showById( "periodRow" );
+}
+
+function reportSelected( _periodType )
+{
+	if ( _periodType )
+	{
+		currentPeriodTypeName = _periodType;
+	}
+	else if ( getFieldValue( "multiExport" ) == 0 )
+	{
+		var value = getFieldValue( 'exportReport' );
+
+		if ( value && value != null )
+		{
+			currentPeriodTypeName = (value.split( '_' )[1] == "true") ? 'Daily' : 'Monthly';
+			currentReportTypeName = value.split( '_' )[2];
+
+			if ( currentReportTypeName == "P" ) {
+				hideById( "periodRow" );
+			}else {
+				showById( "periodRow" );
+			}
 		}
 	}
+	
+	displayPeriodsInternal();
 }
 
 function displayPeriodsInternal()
@@ -97,34 +127,45 @@
 
 function validateGenerateReport( isAdvanced )
 {
-	var exportReport = getFieldValue('exportReport');
+	var exportReports = jQuery( 'select[id=exportReport]' ).children( 'option:selected' );
 
-	if ( exportReport.length == 0 )
+	if ( exportReports.length == 0 )
 	{
 		showErrorMessage( i18n_specify_export_report );
 		return;
 	}
 	
-	lockScreen();
+	var url = 'validateGenerateReport.action?';
+	
+	jQuery.each( exportReports, function ( i, item )
+	{
+		url += 'exportReportIds=' + item.value.split( "_" )[0] + '&';
+	} );
+	
+	url = url.substring( 0, url.length - 1 );
+	
+	if ( url && url != '' )
+	{
+		lockScreen();
 
-	jQuery.postJSON( 'validateGenerateReport.action',
-	{
-		'exportReportId': getFieldValue( 'exportReport' ),
-		'periodIndex': getFieldValue( 'selectedPeriodId' )
-	},
-	function( json )
-	{
-		if ( json.response == "success" ) {
-			if ( isAdvanced ) {
-				generateAdvancedExportReport();
-			}
-			else generateExportReport();
-		}
-		else {
-			unLockScreen();
-			showWarningMessage( json.message );
-		}
-	});
+		jQuery.postJSON( url,
+		{
+			'periodIndex': getFieldValue( 'selectedPeriodId' )
+		},
+		function( json )
+		{
+			if ( json.response == "success" ) {
+				if ( isAdvanced ) {
+					generateAdvancedExportReport();
+				}
+				else generateExportReport();
+			}
+			else {
+				unLockScreen();
+				showWarningMessage( json.message );
+			}
+		});
+	}
 }
 
 function generateExportReport() {

=== 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-04-26 06:08:03 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-05-03 10:04:29 +0000
@@ -20,34 +20,45 @@
 
 function validatePreviewReport( isAdvanced )
 {
-	var exportReport = getFieldValue('exportReport');
+	var exportReports = jQuery( 'select[id=exportReport]' ).children( 'option:selected' );
 
-	if ( exportReport.length == 0 )
+	if ( exportReports.length == 0 )
 	{
 		showErrorMessage( i18n_specify_export_report );
 		return;
 	}
 	
-	lockScreen();
+	var url = 'validateGenerateReport.action?';
+	
+	jQuery.each( exportReports, function ( i, item )
+	{
+		url += 'exportReportIds=' + item.value.split( "_" )[0] + '&';
+	} );
+	
+	url = url.substring( 0, url.length - 1 );
+	
+	if ( url && url != '' )
+	{
+		lockScreen();
 
-	jQuery.postJSON( 'validateGenerateReport.action',
-	{
-		'exportReportId': getFieldValue( 'exportReport' ),
-		'periodIndex': getFieldValue( 'selectedPeriodId' )
-	},
-	function( json )
-	{
-		if ( json.response == "success" ) {
-			if ( isAdvanced ) {
-				previewAdvandReport();
-			}
-			else previewExportReport();
-		}
-		else {
-			unLockScreen();
-			showWarningMessage( json.message );
-		}
-	});
+		jQuery.postJSON( url,
+		{
+			'periodIndex': getFieldValue( 'selectedPeriodId' )
+		},
+		function( json )
+		{
+			if ( json.response == "success" ) {
+				if ( isAdvanced ) {
+					previewAdvandReport();
+				}
+				else previewExportReport();
+			}
+			else {
+				unLockScreen();
+				showWarningMessage( json.message );
+			}
+		});
+	}
 }
 
 function previewExportReport()