=== 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-10-29 10:31:16 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2012-11-01 02:12:05 +0000 @@ -59,6 +59,8 @@ { private static final String PREFIX_FORMULA_SUM = "SUM("; + private static final int SHIFT_NUMBER_OF_ROWS = 5; + private Map> childrenGroupMap = new HashMap>(); // ------------------------------------------------------------------------- @@ -182,6 +184,9 @@ { List organisationUnits = null; + boolean isFirst = true; + boolean isTitleSetup = isTitleSetup( exportReportItems ); + for ( ExportItem reportItem : exportReportItems ) { int run = 0; @@ -198,6 +203,13 @@ organisationUnits = childrenGroupMap.get( unitGroup.getId() ); + // Shift the number of rows - From start-row To end-row + + if ( isTitleSetup && isFirst ) + { + sheet.shiftRows( rowBegin, rowBegin + SHIFT_NUMBER_OF_ROWS, organisationUnits.size() + 1 ); + } + if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), unitGroup.getName(), ExcelUtils.TEXT, @@ -211,7 +223,7 @@ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils.generateExcelFormula( - reportItem.getExpression(), run, run ), sheet, this.csFormula, evaluatorFormula ); + reportItem.getExpression(), run + 1, run + 1 ), sheet, this.csFormula, evaluatorFormula ); } run++; @@ -305,6 +317,8 @@ ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula, evaluatorFormula ); } + + isFirst = false; } organisationUnits = null; @@ -315,6 +329,9 @@ { List organisationUnits = null; + boolean isFirst = true; + boolean isTitleSetup = isTitleSetup( exportReportItems ); + for ( ExportItem reportItem : exportReportItems ) { int chapperNo = 0; @@ -327,6 +344,13 @@ { organisationUnits = childrenGroupMap.get( unitGroup.getId() ); + // Shift the number of rows - From start-row To end-row + + if ( isTitleSetup && isFirst ) + { + sheet.shiftRows( rowBegin, rowBegin + SHIFT_NUMBER_OF_ROWS, organisationUnits.size() + 1 ); + } + if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), unitGroup.getName(), ExcelUtils.TEXT, @@ -374,9 +398,24 @@ ExcelUtils.writeValueByPOI( firstRow, reportItem.getColumn(), totalValue + "", ExcelUtils.NUMBER, sheet, this.csNumber ); } + + isFirst = false; } organisationUnits = null; } + private boolean isTitleSetup( Collection exportReportItems ) + { + for ( ExportItem item : exportReportItems ) + { + if ( item.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) ) + { + return true; + } + } + + return false; + } + } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js 2012-04-28 16:58:08 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js 2012-11-01 02:12:05 +0000 @@ -75,7 +75,11 @@ disable( 'expression-button' ); setFieldValue( 'exportItem input[id=expression]', value ); removeValidatorRulesById( 'exportItem input[id=expression]' ); - removeValidatorRulesById( 'dataelement textarea[id=formula]' ); + + if ( !attribute && !categoryVertical ) + { + removeValidatorRulesById( 'dataelement textarea[id=formula]' ); + } } } @@ -98,15 +102,15 @@ setFieldValue( 'attributevalue [id=formula]', getFieldValue( 'attributevalue [id=formula]' ) + expression ); } else if ( category ) { - expression = "[*." + getFieldValue( "dataelement [id=elementSelect]" ) + "]"; + expression = "[*." + getFieldValue( "dataelement-elementSelect" ) + "]"; setFieldValue( 'dataelement [id=formula]', getFieldValue( 'dataelement [id=formula]' ) + expression ); } else if ( categoryVertical ) { - expression = "[" + getFieldValue( "categoryoption [id=elementSelect]" ) + ".*]"; + expression = "[" + getFieldValue( "categoryoption-elementSelect" ) + ".*]"; setFieldValue( 'categoryoption [id=formula]', getFieldValue( 'categoryoption [id=formula]' ) + expression ); } else { - expression = getFieldValue('dataelement [id=elementSelect]'); + expression = getFieldValue( 'dataelement-elementSelect' ); setFieldValue( 'dataelement [id=formula]', getFieldValue( 'dataelement [id=formula]' ) + expression ); } === 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-10-02 04:32:52 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js 2012-11-01 02:12:05 +0000 @@ -141,7 +141,7 @@ var _sData = getElementValue( _cols[j], 'data' ); var _align = getElementAttribute( _cols[j], 'format', 'align' ); var _border = getElementAttribute( _cols[j], 'format', 'border' ); - var _width = getElementAttribute( _cols[j], 'format', 'width' ); + //var _width = getElementAttribute( _cols[j], 'format', 'width' ); // If this cell is merged - Key's form: Sheet#Row#Col _sPattern = _orderSheet + "#" + i + "#" + _number; @@ -151,7 +151,8 @@ j = Number(j) + Number(_colspan); _index = Number(_index) + Number(_colspan); - _sHTML.push( "