=== 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-07-12 10:18:47 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java 2012-10-29 10:31:16 +0000 @@ -213,15 +213,13 @@ protected Font csFont; + protected Font csFont8Normal; + + protected Font csFont10Normal; + protected Font csFont11Bold; - protected Font csFont10Bold; - - protected Font csFont9Bold; - - protected Font csFont8Bold; - - protected Font csFont12BoldCenter; + protected Font csFont12NormalCenter; protected CellStyle csNumber; @@ -231,17 +229,17 @@ protected CellStyle csTextWithoutBorder; - protected CellStyle csText10Bold; + protected CellStyle csText10Normal; protected CellStyle csText9Bold; - protected CellStyle csText8Bold; + protected CellStyle csText8Normal; protected CellStyle csTextSerial; protected CellStyle csTextICDJustify; - protected CellStyle csText12BoldCenter; + protected CellStyle csText12NormalCenter; protected FormulaEvaluator evaluatorFormula; @@ -294,21 +292,19 @@ { sheetPOI = templateWorkbook.getSheetAt( 0 ); csFont = templateWorkbook.createFont(); - csFont8Bold = templateWorkbook.createFont(); - csFont9Bold = templateWorkbook.createFont(); - csFont10Bold = templateWorkbook.createFont(); + csFont8Normal = templateWorkbook.createFont(); + csFont10Normal = templateWorkbook.createFont(); csFont11Bold = templateWorkbook.createFont(); - csFont12BoldCenter = templateWorkbook.createFont(); + csFont12NormalCenter = templateWorkbook.createFont(); csNumber = templateWorkbook.createCellStyle(); csFormula = templateWorkbook.createCellStyle(); csText = templateWorkbook.createCellStyle(); csTextWithoutBorder = templateWorkbook.createCellStyle(); - csText8Bold = templateWorkbook.createCellStyle(); - csText9Bold = templateWorkbook.createCellStyle(); - csText10Bold = templateWorkbook.createCellStyle(); + csText8Normal = templateWorkbook.createCellStyle(); + csText10Normal = templateWorkbook.createCellStyle(); csTextSerial = templateWorkbook.createCellStyle(); csTextICDJustify = templateWorkbook.createCellStyle(); - csText12BoldCenter = templateWorkbook.createCellStyle(); + csText12NormalCenter = templateWorkbook.createCellStyle(); } @SuppressWarnings( "static-access" ) @@ -320,15 +316,13 @@ csTextWithoutBorder.setFont( csFont ); - initPOIStylesManager.initFont( csFont8Bold, "Tahoma", (short) 8, Font.BOLDWEIGHT_BOLD, IndexedColors.BLACK - .getIndex() ); - initPOIStylesManager.initFont( csFont9Bold, "Tahoma", (short) 9, Font.BOLDWEIGHT_BOLD, IndexedColors.BLACK - .getIndex() ); - initPOIStylesManager.initFont( csFont10Bold, "Tahoma", (short) 10, Font.BOLDWEIGHT_BOLD, IndexedColors.BLACK - .getIndex() ); + initPOIStylesManager.initFont( csFont8Normal, "Tahoma", (short) 8, Font.BOLDWEIGHT_NORMAL, IndexedColors.BLACK + .getIndex() ); + initPOIStylesManager.initFont( csFont10Normal, "Tahoma", (short) 10, Font.BOLDWEIGHT_NORMAL, + IndexedColors.BLACK.getIndex() ); initPOIStylesManager.initFont( csFont11Bold, "Tahoma", (short) 11, Font.BOLDWEIGHT_BOLD, IndexedColors.DARK_BLUE.getIndex() ); - initPOIStylesManager.initFont( csFont12BoldCenter, "Tahoma", (short) 12, Font.BOLDWEIGHT_BOLD, + initPOIStylesManager.initFont( csFont12NormalCenter, "Tahoma", (short) 12, Font.BOLDWEIGHT_NORMAL, IndexedColors.BLUE.getIndex() ); initPOIStylesManager.initCellStyle( csNumber, csFont, this.CELLSTYLE_BORDER, this.CELLSTYLE_BORDER_COLOR, @@ -338,15 +332,11 @@ 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, true ); - initPOIStylesManager.initCellStyle( csText8Bold, csFont8Bold, 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, - true ); - initPOIStylesManager.initCellStyle( csText9Bold, csFont9Bold, 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, - true ); - initPOIStylesManager.initCellStyle( csText10Bold, csFont10Bold, this.CELLSTYLE_BORDER, + initPOIStylesManager.initCellStyle( csText8Normal, csFont8Normal, 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, + true ); + initPOIStylesManager.initCellStyle( csText10Normal, csFont10Normal, 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, true ); @@ -357,7 +347,7 @@ 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, true ); - initPOIStylesManager.initCellStyle( csText12BoldCenter, csFont12BoldCenter, this.CELLSTYLE_BORDER, + initPOIStylesManager.initCellStyle( csText12NormalCenter, csFont12NormalCenter, 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, true ); @@ -409,13 +399,9 @@ protected void installReadTemplateFile( ExportReport exportReport, Period period, Object object ) throws Exception { - this.outputReportFile = new File - ( - reportLocationManager.getExportReportTemporaryDirectory(), - currentUserService.getCurrentUsername() - + this.dateformatter.format( Calendar.getInstance().getTime() ) - + exportReport.getExcelTemplateFile() - ); + this.outputReportFile = new File( reportLocationManager.getExportReportTemporaryDirectory(), currentUserService + .getCurrentUsername() + + this.dateformatter.format( Calendar.getInstance().getTime() ) + exportReport.getExcelTemplateFile() ); this.outputStreamExcelTemplate = new FileOutputStream( outputReportFile ); @@ -424,6 +410,8 @@ this.initExcelFormat(); this.installDefaultExcelFormat(); + + this.initFormulaEvaluating(); if ( exportReport.getOrganisationRow() != null && exportReport.getOrganisationColumn() != null ) { === modified 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 2012-05-04 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateMultiReportAction.java 2012-10-29 10:31:16 +0000 @@ -78,11 +78,11 @@ OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo(); Collection 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 ); @@ -130,8 +130,11 @@ { ExportReportPeriodColumnListing reportInstance = (ExportReportPeriodColumnListing) report; - this.generatePeriodListing( reportInstance.getPeriodColumns(), exportItems, organisationUnit, sheet ); + this + .generatePeriodListing( reportInstance.getPeriodColumns(), exportItems, organisationUnit, sheet ); } + + this.recalculatingFormula( sheet ); } } } @@ -140,10 +143,9 @@ // Supportive method // ------------------------------------------------------------------------- - /** * NORMAL - * */ + */ private void generateNormal( Collection exportItems, OrganisationUnit organisationUnit, Sheet sheet ) { for ( ExportItem reportItem : exportItems ) @@ -173,14 +175,14 @@ // EXCEL FORMULA { ExcelUtils.writeFormulaByPOI( reportItem.getRow(), reportItem.getColumn(), reportItem.getExpression(), - sheet, this.csFormula ); + sheet, this.csFormula, evaluatorFormula ); } } } /** * ATTRIBUTE - * */ + */ private void generateAttribute( DataElementCategoryOptionCombo optionCombo, ExportReportAttribute exportReport, Collection exportItems, OrganisationUnit organisationUnit, Sheet sheet ) { @@ -210,7 +212,7 @@ if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avgOrder.getName(), - ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } rowBegin++; @@ -219,7 +221,7 @@ if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avalue, ExcelUtils.TEXT, sheet, - this.csText10Bold ); + this.csText10Normal ); } else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { @@ -260,7 +262,7 @@ /** * CATEGORY - * */ + */ private void generateVerticalOutPutFile( ExportReportCategory exportReport, Collection exportItems, OrganisationUnit organisationUnit, Sheet sheet ) { @@ -276,12 +278,12 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), dataElementGroup.getName(), - ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_CODE ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), dataElementGroup.getCode(), - ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } run++; @@ -293,7 +295,7 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), dataElement.getName(), - ExcelUtils.TEXT, sheet, this.csText10Bold ); + ExcelUtils.TEXT, sheet, this.csText10Normal ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_CODE ) ) { @@ -308,7 +310,8 @@ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils - .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula ); + .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula, + evaluatorFormula ); } else { @@ -337,7 +340,8 @@ String columnName = ExcelUtils.convertColumnNumberToName( 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, + evaluatorFormula ); } } } @@ -397,7 +401,7 @@ /** * CATEGORY-VERTICAL - * */ + */ private void generateCategoryVertical( ExportReportVerticalCategory exportReport, Collection exportReportItems, OrganisationUnit organisationUnit, Sheet sheet ) { @@ -426,7 +430,7 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), group.getName(), ExcelUtils.TEXT, - sheet, this.csText12BoldCenter ); + sheet, this.csText12NormalCenter ); } run++; @@ -440,7 +444,7 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), categoryOption.getName(), - ExcelUtils.TEXT, sheet, this.csText10Bold ); + ExcelUtils.TEXT, sheet, this.csText10Normal ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { @@ -450,7 +454,8 @@ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils - .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula ); + .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula, + evaluatorFormula ); } else { @@ -487,7 +492,7 @@ + (rowBegin - 1) + ")"; ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, - this.csFormula ); + this.csFormula, evaluatorFormula ); } } } @@ -497,7 +502,7 @@ /** * ORGUNIT-LISTING - * */ + */ private void generateOrgUnitListing( ExportReportOrganizationGroupListing exportReport, Map orgUniGroupAtLevels, Collection exportItems, OrganisationUnit organisationUnit, Sheet sheet ) @@ -542,13 +547,13 @@ && (!organisationUnits.isEmpty()) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), organisationUnitGroup.getName(), - ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) && (!organisationUnits.isEmpty()) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo++], - ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } run++; @@ -560,7 +565,7 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), o.getName(), ExcelUtils.TEXT, - sheet, this.csText10Bold ); + sheet, this.csText10Normal ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { @@ -585,7 +590,8 @@ // FORMULA_EXCEL { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils - .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, this.csFormula ); + .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, this.csFormula, + evaluatorFormula ); } run++; @@ -603,7 +609,7 @@ formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")"; ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, - this.csFormula ); + this.csFormula, evaluatorFormula ); totalFormula += columnName + beginChapter + ","; } @@ -612,7 +618,7 @@ formula = ExcelUtils.generateExcelFormula( reportItem.getExtraExpression(), next + 1, 0 ); ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, - this.csFormula ); + this.csFormula, evaluatorFormula ); } } @@ -624,20 +630,22 @@ { totalFormula = totalFormula.substring( 0, totalFormula.length() - 1 ) + ")"; - ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula ); + ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula, + evaluatorFormula ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) ) { totalFormula = ExcelUtils.generateExcelFormula( reportItem.getExtraExpression(), 0, 0 ); - ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula ); + ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula, + evaluatorFormula ); } } } /** * PERIOD-LISTING - * */ + */ private void generatePeriodListing( Set periodColumns, Collection exportItems, OrganisationUnit organisationUnit, Sheet sheet ) { === 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-07-11 08:56:27 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java 2012-10-29 10:31:16 +0000 @@ -81,6 +81,8 @@ this.generateOutPutFile( defaultOptionCombo, exportReportInstance, exportReportItems, organisationUnit, sheet ); + + this.recalculatingFormula( sheet ); } /** @@ -123,7 +125,7 @@ if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avgOrder.getName(), - ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } rowBegin++; @@ -132,7 +134,7 @@ if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avalue, ExcelUtils.TEXT, sheet, - this.csText10Bold ); + this.csText10Normal ); } else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { === 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-09-19 02:22:55 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportCategoryAction.java 2012-10-29 10:31:16 +0000 @@ -93,6 +93,8 @@ { this.generateHorizontalOutPutFile( exportReportInstance, exportReportItems, organisationUnit, sheet ); } + + this.recalculatingFormula( sheet ); } /** @@ -121,12 +123,12 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), group.getName(), ExcelUtils.TEXT, - sheet, this.csText12BoldCenter ); + sheet, this.csText12NormalCenter ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_CODE ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), group.getCode(), ExcelUtils.TEXT, - sheet, this.csText12BoldCenter ); + sheet, this.csText12NormalCenter ); } run++; @@ -138,7 +140,7 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), dataElement.getName(), - ExcelUtils.TEXT, sheet, this.csText10Bold ); + ExcelUtils.TEXT, sheet, this.csText10Normal ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_CODE ) ) { @@ -153,7 +155,8 @@ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils - .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula ); + .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula, + evaluatorFormula ); } else { @@ -182,7 +185,8 @@ String columnName = ExcelUtils.convertColumnNumberToName( 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, + evaluatorFormula ); } } } === 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-07-11 08:56:27 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java 2012-10-29 10:31:16 +0000 @@ -66,6 +66,8 @@ exportReportItems = exportReportInstance.getExportItemBySheet( sheetNo ); this.generateOutPutFile( exportReportItems, organisationUnit, sheet ); + + this.recalculatingFormula( sheet ); } /** @@ -108,7 +110,7 @@ // EXCEL FORMULA { ExcelUtils.writeFormulaByPOI( reportItem.getRow(), reportItem.getColumn(), reportItem.getExpression(), - sheet, this.csFormula ); + sheet, this.csFormula, evaluatorFormula ); } } } === 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-09 07:49:13 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2012-10-29 10:31:16 +0000 @@ -1,7 +1,7 @@ package org.hisp.dhis.reportsheet.exporting.action; /* - * Copyright (c) 2004-2011, University of Oslo + * Copyright (c) 2004-2012, University of Oslo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -114,6 +114,8 @@ { generateOutPutFile2( exportReportInstance, exportReportItems, sheet ); } + + this.recalculatingFormula( sheet ); } /** @@ -199,12 +201,17 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), unitGroup.getName(), ExcelUtils.TEXT, - sheet, this.csText12BoldCenter ); + sheet, this.csText12NormalCenter ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo++], - ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); + } + else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) + { + ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils.generateExcelFormula( + reportItem.getExpression(), run, run ), sheet, this.csFormula, evaluatorFormula ); } run++; @@ -216,7 +223,7 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), o.getName(), ExcelUtils.TEXT, - sheet, this.csText10Bold ); + sheet, this.csText10Normal ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { @@ -241,7 +248,8 @@ // FORMULA_EXCEL { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils - .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, this.csFormula ); + .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, this.csFormula, + evaluatorFormula ); } run++; @@ -259,7 +267,7 @@ formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")"; ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, - this.csFormula ); + this.csFormula, evaluatorFormula ); totalFormula += columnName + beginChapter + ","; } @@ -268,7 +276,7 @@ formula = ExcelUtils.generateExcelFormula( reportItem.getExtraExpression(), next + 1, 0 ); ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, - this.csFormula ); + this.csFormula, evaluatorFormula ); } } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) @@ -276,7 +284,7 @@ || reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeValueByPOI( rowBegin - 1, reportItem.getColumn(), null, ExcelUtils.NUMBER, sheet, - this.csText10Bold ); + this.csText10Normal ); } next = run; @@ -287,13 +295,15 @@ { totalFormula = totalFormula.substring( 0, totalFormula.length() - 1 ) + ")"; - ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula ); + ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula, + evaluatorFormula ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) ) { totalFormula = ExcelUtils.generateExcelFormula( reportItem.getExtraExpression(), 0, 0 ); - ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula ); + ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula, + evaluatorFormula ); } } @@ -320,12 +330,12 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), unitGroup.getName(), ExcelUtils.TEXT, - sheet, this.csText12BoldCenter ); + sheet, this.csText12NormalCenter ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo++], - ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) ) { @@ -351,7 +361,7 @@ // FORMULA_EXCEL { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils.generateExcelFormula( - reportItem.getExpression(), rowBegin, rowBegin ), sheet, this.csFormula ); + reportItem.getExpression(), rowBegin, rowBegin ), sheet, this.csFormula, evaluatorFormula ); } rowBegin++; === 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-07-11 08:56:27 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java 2012-10-29 10:31:16 +0000 @@ -71,6 +71,8 @@ this.generateOutPutFile( exportReportInstance.getPeriodColumns(), exportReportItems, organisationUnit, sheet ); + + this.recalculatingFormula( sheet ); } /** === 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-07-11 08:56:27 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java 2012-10-29 10:31:16 +0000 @@ -65,7 +65,7 @@ this.installReadTemplateFile( exportReportInstance, period, unit ); Collection exportReportItems = null; - + for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) ) { Sheet sheet = this.templateWorkbook.getSheetAt( sheetNo - 1 ); @@ -73,8 +73,10 @@ exportReportItems = exportReportInstance.getExportItemBySheet( sheetNo ); this.generateVerticalOutPutFile( exportReportInstance, exportReportItems, unit, sheet ); + + this.recalculatingFormula( sheet ); } - + /** * Garbage */ @@ -104,12 +106,12 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), group.getName(), ExcelUtils.TEXT, - sheet, this.csText10Bold ); + sheet, this.csText10Normal ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo++], - ExcelUtils.TEXT, sheet, this.csText10Bold ); + ExcelUtils.TEXT, sheet, this.csText10Normal ); } run++; @@ -125,7 +127,7 @@ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), categoryOption.getName(), - ExcelUtils.TEXT, sheet, this.csText8Bold ); + ExcelUtils.TEXT, sheet, this.csText8Normal ); } else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { @@ -135,7 +137,8 @@ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils - .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula ); + .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula, + evaluatorFormula ); } else { @@ -164,7 +167,7 @@ + (rowBegin - 1) + ")"; ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, - this.csFormula ); + this.csFormula, evaluatorFormula ); } break; === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportCategoryAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportCategoryAction.java 2011-12-07 06:50:10 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportCategoryAction.java 2012-10-29 10:31:16 +0000 @@ -125,12 +125,12 @@ if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), String.valueOf( dataElementGroup - .getName() ), ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + .getName() ), ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_CODE ) ) { ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), String.valueOf( dataElementGroup - .getCode() ), ExcelUtils.TEXT, sheet, this.csText12BoldCenter ); + .getCode() ), ExcelUtils.TEXT, sheet, this.csText12NormalCenter ); } rowBegin++; @@ -141,7 +141,7 @@ if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) ) { ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), String.valueOf( dataElement - .getName() ), ExcelUtils.TEXT, sheet, this.csText10Bold ); + .getName() ), ExcelUtils.TEXT, sheet, this.csText10Normal ); } else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_CODE ) ) { @@ -156,7 +156,8 @@ else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeFormulaByPOI( rowBegin, exportItem.getColumn(), ExcelUtils - .generateExcelFormula( exportItem.getExpression(), iRow, iCol ), sheet, this.csFormula ); + .generateExcelFormula( exportItem.getExpression(), iRow, iCol ), sheet, this.csFormula, + evaluatorFormula ); } else { @@ -189,7 +190,8 @@ { String columnName = ExcelUtils.convertColumnNumberToName( exportItem.getColumn() ); String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")"; - ExcelUtils.writeFormulaByPOI( beginChapter, exportItem.getColumn(), formula, sheet, this.csFormula ); + ExcelUtils.writeFormulaByPOI( beginChapter, exportItem.getColumn(), formula, sheet, this.csFormula, + evaluatorFormula ); } } } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportOrgGroupListingAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportOrgGroupListingAction.java 2012-04-16 03:00:30 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/advance/action/GenerateAdvancedReportOrgGroupListingAction.java 2012-10-29 10:31:16 +0000 @@ -133,7 +133,7 @@ if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) ) { ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), o.getName(), ExcelUtils.TEXT, sheet, - this.csText10Bold ); + this.csText10Normal ); } else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) ) { @@ -157,7 +157,7 @@ else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) ) { ExcelUtils.writeFormulaByPOI( rowBegin, exportItem.getColumn(), ExcelUtils.generateExcelFormula( - exportItem.getExpression(), iRow, iCol ), sheet, this.csFormula ); + exportItem.getExpression(), iRow, iCol ), sheet, this.csFormula, evaluatorFormula ); } rowBegin++; @@ -170,7 +170,8 @@ { String columnName = ExcelUtils.convertColumnNumberToName( exportItem.getColumn() ); String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")"; - ExcelUtils.writeFormulaByPOI( beginChapter, exportItem.getColumn(), formula, sheet, this.csFormula ); + ExcelUtils.writeFormulaByPOI( beginChapter, exportItem.getColumn(), formula, sheet, this.csFormula, + evaluatorFormula ); } } } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java 2012-06-07 06:25:18 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java 2012-10-29 10:31:16 +0000 @@ -392,7 +392,7 @@ /* POI - Write formula without CellStyle */ public static void writeFormulaByPOI( int row, int column, String formula, - org.apache.poi.ss.usermodel.Sheet sheetPOI ) + org.apache.poi.ss.usermodel.Sheet sheetPOI, FormulaEvaluator evaluator ) { if ( row > 0 && column > 0 ) { @@ -417,12 +417,15 @@ cellPOI.setCellStyle( cellStylePOI ); cellPOI.setCellFormula( formula ); + + evaluator.evaluateFormulaCell( cellPOI ); } } /* POI - Write formula with customize CellStyle */ public static void writeFormulaByPOI( int row, int column, String formula, - org.apache.poi.ss.usermodel.Sheet sheetPOI, org.apache.poi.ss.usermodel.CellStyle cellStyle ) + org.apache.poi.ss.usermodel.Sheet sheetPOI, org.apache.poi.ss.usermodel.CellStyle cellStyle, + FormulaEvaluator evaluator ) { if ( row > 0 && column > 0 ) { @@ -436,6 +439,8 @@ org.apache.poi.ss.usermodel.Cell cellPOI = rowPOI.createCell( column - 1 ); cellPOI.setCellStyle( cellStyle ); cellPOI.setCellFormula( formula ); + + evaluator.evaluateFormulaCell( cellPOI ); } } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/listDataElementGroupOrder.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/listDataElementGroupOrder.vm 2012-03-29 10:05:35 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/listDataElementGroupOrder.vm 2012-10-29 10:31:16 +0000 @@ -68,7 +68,7 @@ $i18n.getString('code') - +