dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03039
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1024: Fixed the violated bug at IllegalStateException in Preview Report Excel function ...
------------------------------------------------------------
revno: 1024
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2009-11-11 18:05:27 +0700
message:
Fixed the violated bug at IllegalStateException in Preview Report Excel function ...
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-10 09:20:36 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java 2009-11-11 11:05:27 +0000
@@ -40,10 +40,8 @@
import jxl.format.Colour;
import jxl.format.Pattern;
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.hisp.dhis.reportexcel.utils.ExcelUtils;
+import org.apache.poi.hssf.util.CellReference;
/**
* Simple demo class which uses the api to present the contents of an excel 97
@@ -220,7 +218,6 @@
if ( sheetId > 0 )
{
-
this.recalculatedValueForCellFormula( wb, (sheetId - 1) );
}
else
@@ -465,37 +462,40 @@
}
}
-
private void recalculatedValueForCellFormula( org.apache.poi.ss.usermodel.Workbook wb, int sheetNo )
+ throws Exception
{
org.apache.poi.ss.usermodel.Sheet sheet = wb.getSheetAt( sheetNo );
org.apache.poi.ss.usermodel.FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
String recalculatedValue = "";
-
- for (org.apache.poi.ss.usermodel.Row rowPOI : sheet) {
-
- for (org.apache.poi.ss.usermodel.Cell cellPOI : rowPOI) {
-
- if (cellPOI.getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA)
+
+ for ( org.apache.poi.ss.usermodel.Row rowPOI : sheet )
+ {
+ for ( org.apache.poi.ss.usermodel.Cell cellPOI : rowPOI )
+ {
+
+ CellReference cellReference = new CellReference( cellPOI.getRowIndex(), cellPOI.getColumnIndex() );
+ org.apache.poi.ss.usermodel.Row rowRef = sheet.getRow( cellReference.getRow() );
+ org.apache.poi.ss.usermodel.Cell cellRef = rowRef.getCell( cellReference.getCol() );
+
+ if ( (cellRef != null) && (cellRef.getCellType() == org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA) )
{
- switch ( evaluator.evaluateFormulaCell( cellPOI ) )
+ switch ( evaluator.evaluateInCell( cellRef ).getCellType() )
{
case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
- recalculatedValue = String.valueOf( cellPOI.getNumericCellValue() );
-
+ recalculatedValue = String.valueOf( cellRef.getNumericCellValue() );
+
if ( new Double( recalculatedValue.split( "\\." )[1] ) == 0.0d )
{
recalculatedValue = recalculatedValue.split( "\\." )[0];
}
-
- ExcelUtils.writeValueByPOI( cellPOI.getRowIndex(), cellPOI.getColumnIndex(), recalculatedValue, ExcelUtils.NUMBER, (HSSFSheet) sheet,
- (HSSFCellStyle) wb.createCellStyle() );
break;
// CELL_TYPE_FORMULA will never occur
case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
+ System.out.println("Place of cell :: [" + cellRef.getRowIndex()+"]["+cellRef.getColumnIndex() +"]");
break;
}
}
@@ -503,4 +503,18 @@
}
}
+ /**/
+ public static void main( String[] args )
+ throws Exception
+ {
+ // System.out.println(new
+ // XMLStructureResponse("c:/phammemthongke/reporttemplate/admin11.11.2009.3.43.28.PMbaocaoquy.xls",
+ // "UTF8", 1, true, false, true, false,
+ // false).getSTRUCTURE_DATA_RESPONSE());
+ System.out.println( new XMLStructureResponse(
+ "c:/phammemthongke/reporttemplate/admin11.11.2009.3.56.21.PMBieuMau_08.xls", "UTF8", 1, true, false, true,
+ false, false ).getSTRUCTURE_DATA_RESPONSE() );
+ }
+ /**/
+
}