=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportCategoryAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportCategoryAction.java 2009-12-07 03:47:03 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportCategoryAction.java 2009-12-09 05:55:32 +0000 @@ -94,16 +94,15 @@ if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( dataElementGroup - .getName() ), ExcelUtils.TEXT, sheet, this.csTextChapterLeft ); + .getName() ), ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT_CODE ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( dataElementGroup - .getCode() ), ExcelUtils.TEXT, sheet, this.csTextChapterLeft ); + .getCode() ), ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); } rowBegin++; - int serial = 1; for ( DataElement dataElement : dataElementGroup.getDataElements() ) @@ -112,7 +111,7 @@ if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( dataElement - .getName() ), ExcelUtils.TEXT, sheet, this.csTextChapterLeft ); + .getName() ), ExcelUtils.TEXT, sheet, this.csText10Bold ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT_CODE ) ) { @@ -122,7 +121,7 @@ else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.SERIAL ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ), - ExcelUtils.NUMBER, sheet, this.csNumber ); + ExcelUtils.NUMBER, sheet, this.csTextSerial ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.FORMULA_EXCEL ) ) { === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportOrganizationGroupListingAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportOrganizationGroupListingAction.java 2009-12-07 03:47:03 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportOrganizationGroupListingAction.java 2009-12-09 05:55:32 +0000 @@ -92,28 +92,29 @@ for ( OrganisationUnitGroup organisationUnitGroup : reportExcel.getOrganisationUnitGroups() ) { - List childrenOrganisationUnits = new ArrayList( organisationUnit .getChildren() ); - List organisationUnits = new ArrayList(organisationUnitGroup.getMembers()); + List organisationUnits = new ArrayList( organisationUnitGroup + .getMembers() ); organisationUnits.retainAll( childrenOrganisationUnits ); - + Collections.sort( organisationUnits, new OrganisationUnitNameComparator() ); int beginChapter = rowBegin; + if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.ORGANISATION ) && (!organisationUnits.isEmpty()) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( organisationUnitGroup - .getName() ), ExcelUtils.TEXT, sheet, this.csTextOrgUnitName ); + .getName() ), ExcelUtils.TEXT, sheet, this.csText12BoldCenter); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.SERIAL ) && (!organisationUnits.isEmpty()) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo], ExcelUtils.TEXT, - sheet, this.csTextChapterLeft ); + sheet, this.csText12BoldCenter); } chapperNo++; rowBegin++; @@ -124,26 +125,26 @@ if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), o.getName(), ExcelUtils.TEXT, - sheet, this.csTextOrgUnitName ); + sheet, this.csText10Bold ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.SERIAL ) ) { - ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ), ExcelUtils.NUMBER, - sheet, this.csNumber ); + ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ), + ExcelUtils.NUMBER, sheet, this.csTextSerial ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT ) ) { double value = this.getDataValue( reportItem, o ); - - ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( value ), ExcelUtils.NUMBER, - sheet, this.csNumber ); + + ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( value ), + ExcelUtils.NUMBER, sheet, this.csNumber ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.INDICATOR ) ) { double value = this.getIndicatorValue( reportItem, o ); - ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( value ), ExcelUtils.NUMBER, - sheet, this.csNumber ); + ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( value ), + ExcelUtils.NUMBER, sheet, this.csNumber ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.FORMULA_EXCEL ) ) { @@ -160,8 +161,7 @@ { String columnName = ExcelUtils.convertColNumberToColName( reportItem.getColumn() ); String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")"; - ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, - sheet, this.csFormula ); + ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, this.csFormula ); } } === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java 2009-12-07 03:47:03 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java 2009-12-09 05:55:32 +0000 @@ -274,34 +274,35 @@ // ------------------------------------------ // Excel format // ------------------------------------------ - protected HSSFFont csFont; - - protected HSSFFont csFontBold; - - protected HSSFFont csFontChapterBold; protected HSSFHeader header; protected HSSFDataFormat dFormat; + protected HSSFFont csFont; + + protected HSSFFont csFont11Bold; + + protected HSSFFont csFont10Bold; + + protected HSSFFont csFont12BoldCenter; + protected HSSFCellStyle csHeader; + protected HSSFCellStyle csNumber; + + protected HSSFCellStyle csFormula; + protected HSSFCellStyle csText; - protected HSSFCellStyle csTextLeft; + protected HSSFCellStyle csText10Bold; - protected HSSFCellStyle csTextRight; + protected HSSFCellStyle csTextSerial; protected HSSFCellStyle csTextICDJustify; - protected HSSFCellStyle csTextChapterLeft; - - protected HSSFCellStyle csTextOrgUnitName; - - protected HSSFCellStyle csNumber; - - protected HSSFCellStyle csFormula; - + protected HSSFCellStyle csText12BoldCenter; + SimpleDateFormat dateformatter = new SimpleDateFormat( "dd.MM.yyyy.h.mm.ss.a" ); protected void initExcelFormat() @@ -310,18 +311,17 @@ hssfSheet = templateWorkbook.getSheetAt( 0 ); header = hssfSheet.getHeader(); csFont = templateWorkbook.createFont(); - csFontBold = templateWorkbook.createFont(); - csFontChapterBold = templateWorkbook.createFont(); + csFont11Bold = templateWorkbook.createFont(); + csFont12BoldCenter = templateWorkbook.createFont(); dFormat = templateWorkbook.createDataFormat(); csHeader = templateWorkbook.createCellStyle(); + csNumber = templateWorkbook.createCellStyle(); + csFormula = templateWorkbook.createCellStyle(); csText = templateWorkbook.createCellStyle(); - csTextLeft = templateWorkbook.createCellStyle(); - csTextRight = templateWorkbook.createCellStyle(); + csText10Bold = templateWorkbook.createCellStyle(); + csTextSerial = templateWorkbook.createCellStyle(); csTextICDJustify = templateWorkbook.createCellStyle(); - csTextChapterLeft = templateWorkbook.createCellStyle(); - csTextOrgUnitName = templateWorkbook.createCellStyle(); - csNumber = templateWorkbook.createCellStyle(); - csFormula = templateWorkbook.createCellStyle(); + csText12BoldCenter = templateWorkbook.createCellStyle(); } @@ -337,31 +337,32 @@ initPOIStylesManager.initDefaultHeader( header ); initPOIStylesManager.initDefaultFont( csFont ); initPOIStylesManager.initDefaultCellStyle( csText, csFont ); - initPOIStylesManager.initFont( csFontBold, "Tahoma", (short) 11, HSSFFont.BOLDWEIGHT_BOLD, + + initPOIStylesManager.initFont( csFont10Bold, "Tahoma", (short) 10, HSSFFont.BOLDWEIGHT_BOLD, + HSSFColor.BLACK.index ); + initPOIStylesManager.initFont( csFont11Bold, "Tahoma", (short) 11, HSSFFont.BOLDWEIGHT_BOLD, HSSFColor.DARK_BLUE.index ); - initPOIStylesManager.initFont( csFontChapterBold, "Tahoma", (short) 12, HSSFFont.BOLDWEIGHT_BOLD, - HSSFColor.BROWN.index ); - initPOIStylesManager.initCellStyle( csTextLeft, csFont, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, - this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, - this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_LEFT ); - initPOIStylesManager.initCellStyle( csTextRight, csFont, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, + initPOIStylesManager.initFont( csFont12BoldCenter, "Tahoma", (short) 12, HSSFFont.BOLDWEIGHT_BOLD, + HSSFColor.BLUE.index ); + + initPOIStylesManager.initCellStyle( csNumber, csFont, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_RIGHT ); + initPOIStylesManager.initCellStyle( csFormula, csFont11Bold, this.CELLSTYLE_BORDER, + this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, + this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, + this.CELLSTYLE_ALIGN_RIGHT ); + initPOIStylesManager.initCellStyle( csText10Bold, csFont10Bold, this.CELLSTYLE_BORDER, + this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, + this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_LEFT ); + initPOIStylesManager.initCellStyle( csTextSerial, csFont, this.CELLSTYLE_BORDER, + this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, + this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_CENTER ); initPOIStylesManager.initCellStyle( csTextICDJustify, csFont, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_JUSTIFY ); - initPOIStylesManager.initCellStyle( csNumber, csFont, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, - this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, - this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_CENTER ); - initPOIStylesManager.initCellStyle( csFormula, csFontBold, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, - this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, - this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_CENTER ); - initPOIStylesManager.initCellStyle( csTextOrgUnitName, csFontBold, this.CELLSTYLE_BORDER, - this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, - this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, - this.CELLSTYLE_ALIGN_CENTER ); - initPOIStylesManager.initCellStyle( csTextChapterLeft, csFontChapterBold, this.CELLSTYLE_BORDER, + initPOIStylesManager.initCellStyle( csText12BoldCenter, csFont12BoldCenter, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, this.CELLSTYLE_ALIGN_LEFT ); === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportCategoryAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportCategoryAction.java 2009-12-07 03:47:03 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportCategoryAction.java 2009-12-09 05:55:32 +0000 @@ -56,7 +56,7 @@ // Dependency // --------------------------------------------------------------------- - private OrganisationUnitGroupService organisationUnitGroupService; + private OrganisationUnitGroupService organisationUnitGroupService; // --------------------------------------------------------------------- // Input && Output @@ -71,7 +71,7 @@ public void setOrganisationGroupId( Integer organisationGroupId ) { this.organisationGroupId = organisationGroupId; - } + } public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) { @@ -89,8 +89,7 @@ OrganisationUnitGroup organisationUnitGroup = organisationUnitGroupService .getOrganisationUnitGroup( organisationGroupId ); - - + Period period = periodDatabaseService.getSelectedPeriod(); this.installPeriod( period ); @@ -113,7 +112,7 @@ statementManager.destroy(); - return SUCCESS; + return SUCCESS; } @@ -130,27 +129,28 @@ { int beginChapter = rowBegin; - + if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( dataElementGroup - .getName() ), ExcelUtils.TEXT, sheet, this.csTextChapterLeft ); + .getName() ), ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT_CODE ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( dataElementGroup - .getCode() ), ExcelUtils.TEXT, sheet, this.csTextChapterLeft ); + .getCode() ), ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); } rowBegin++; int serial = 1; + for ( DataElement dataElement : dataElementGroup.getDataElements() ) { if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( dataElement - .getName() ), ExcelUtils.TEXT, sheet, this.csTextChapterLeft ); + .getName() ), ExcelUtils.TEXT, sheet, this.csText10Bold ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT_CODE ) ) { @@ -160,12 +160,12 @@ else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.SERIAL ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ), - ExcelUtils.NUMBER, sheet, this.csNumber ); + ExcelUtils.NUMBER, sheet, this.csTextSerial ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), reportItem.getExpression(), - sheet, this.csFormula ); + sheet, this.csFormula ); } else { @@ -197,8 +197,7 @@ { String columnName = ExcelUtils.convertColNumberToColName( reportItem.getColumn() ); String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")"; - ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, - sheet, this.csFormula ); + ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, this.csFormula ); } } } === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportOrgGroupListingAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportOrgGroupListingAction.java 2009-12-07 03:47:03 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/advance/action/GenerateAdvancedReportOrgGroupListingAction.java 2009-12-09 05:55:32 +0000 @@ -47,7 +47,7 @@ /** * @author Chau Thu Tran * @author Tran Thanh Tri - * @version $Id$ + * @since 2009-09-18 */ public class GenerateAdvancedReportOrgGroupListingAction extends GenerateReportSupport @@ -104,12 +104,13 @@ HSSFSheet sheet = this.templateWorkbook.getSheetAt( sheetNo - 1 ); Collection reportExcelItems = reportExcel.getReportItemBySheet( sheetNo ); - - List organisationUnits = new ArrayList(organisationUnitGroup.getMembers()); - + + List organisationUnits = new ArrayList( organisationUnitGroup + .getMembers() ); + Collections.sort( organisationUnits, new OrganisationUnitNameComparator() ); - this.generateOutPutFile( reportExcel, reportExcelItems, organisationUnits , sheet ); + this.generateOutPutFile( reportExcel, reportExcelItems, organisationUnits, sheet ); } @@ -121,7 +122,7 @@ } private void generateOutPutFile( ReportExcel reportExcel, Collection reportExcelItems, - List organisationUnits, HSSFSheet sheet ) + List organisationUnits, HSSFSheet sheet ) { for ( ReportExcelItem reportItem : reportExcelItems ) { @@ -139,12 +140,12 @@ if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), o.getName(), ExcelUtils.TEXT, sheet, - this.csTextOrgUnitName ); + this.csText10Bold ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.SERIAL ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ), - ExcelUtils.NUMBER, sheet, this.csNumber ); + ExcelUtils.NUMBER, sheet, this.csTextSerial ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.DATAELEMENT ) ) {