dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03008
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1006: Minor fixed
------------------------------------------------------------
revno: 1006
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2009-11-09 15:02:08 +0700
message:
Minor fixed
modified:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java 2009-11-09 06:59:22 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java 2009-11-09 08:02:08 +0000
@@ -218,17 +218,19 @@
FileInputStream fis = new FileInputStream( this.PATH_FILE_NAME );
org.apache.poi.ss.usermodel.Workbook wb = new HSSFWorkbook( fis );
- if ( sheetId > 0 ) {
-
- this.recalculatedValueForCellFormula( wb, sheetId );
+ if ( sheetId > 0 )
+ {
+
+ this.recalculatedValueForCellFormula( wb, (sheetId - 1) );
}
- else {
+ else
+ {
for ( int sheet = 0; sheet < WORKBOOK.getNumberOfSheets(); sheet++ )
{
- this.recalculatedValueForCellFormula( wb, sheetId -1);
+ this.recalculatedValueForCellFormula( wb, sheet );
}
}
-
+
if ( bWriteDescription )
{
this.writeXMLDescription( sheetId );
@@ -269,7 +271,7 @@
// -------------------------------------------------------------------------
// Sub-methods
// -------------------------------------------------------------------------
-
+
private void writeBySheetNo( org.apache.poi.ss.usermodel.Workbook wb, int sheetNo, boolean bDetailed )
{
Sheet s = WORKBOOK.getSheet( sheetNo );
@@ -295,7 +297,7 @@
// information
if ( (cell[j].getType() != CellType.EMPTY) || (cell[j].getCellFormat() != null) )
{
-
+
// end of checking the cell formula
STRUCTURE_DATA_RESPONSE.append( " <col no=\"" + j + "\">" );
STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
@@ -463,6 +465,7 @@
}
}
+
private void recalculatedValueForCellFormula( org.apache.poi.ss.usermodel.Workbook wb, int sheetNo )
{
@@ -471,7 +474,7 @@
org.apache.poi.ss.usermodel.Sheet sheet = wb.getSheetAt( sheetNo );
org.apache.poi.ss.usermodel.FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
-
+
String recalculatedValue = "0";
for ( int i = 0; i < s.getRows(); i++ )
@@ -494,21 +497,23 @@
cell[j].getRow(), cell[j].getColumn() );
org.apache.poi.ss.usermodel.Row rowPOI = sheet.getRow( cellReference.getRow() );
org.apache.poi.ss.usermodel.Cell cellPOI = rowPOI.getCell( cellReference.getCol() );
-
+
if ( cellPOI != null )
{
switch ( evaluator.evaluateFormulaCell( cellPOI ) )
{
case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
-
+
recalculatedValue = String.valueOf( cellPOI.getNumericCellValue() );
-
- if ( new Integer(recalculatedValue.split( "\\." )[1]) == 0 ) {
-
+
+ if ( new Integer( recalculatedValue.split( "\\." )[1] ) == 0 )
+ {
+
recalculatedValue = recalculatedValue.split( "\\." )[0];
}
-
- ExcelUtils.writeValueByPOI( i, j, recalculatedValue, ExcelUtils.NUMBER, (HSSFSheet)sheet, (HSSFCellStyle)wb.createCellStyle() );
+
+ ExcelUtils.writeValueByPOI( i, j, recalculatedValue, ExcelUtils.NUMBER, (HSSFSheet) sheet,
+ (HSSFCellStyle) wb.createCellStyle() );
break;
// CELL_TYPE_FORMULA will never occur