dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02457
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 818: Fixed bug while writing a null pointer of cell ...
------------------------------------------------------------
revno: 818
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2009-10-05 10:03:05 +0700
message:
Fixed bug while writing a null pointer of cell ...
modified:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelUtils.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/utils/ExcelUtils.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelUtils.java 2009-09-17 07:12:56 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/ExcelUtils.java 2009-10-05 03:03:05 +0000
@@ -69,7 +69,7 @@
{
if ( type.equalsIgnoreCase( TEXT ) )
{
- sheet.addCell( new Label( column - 1, row - 1, value==null?"":value , format ) );
+ sheet.addCell( new Label( column - 1, row - 1, value == null ? "" : value, format ) );
}
if ( type.equalsIgnoreCase( NUMBER ) )
{
@@ -129,15 +129,20 @@
return cell.getContents();
}
- /* POI methods */
+ /* POI methods */
public static void writeValueByPOI( int row, int column, String value, String type, HSSFSheet sheet,
HSSFCellStyle cellStyle )
{
if ( row > 0 && column > 0 )
{
HSSFRow rowPOI = sheet.getRow( row - 1 );
+
+ if ( rowPOI == null )
+ {
+ rowPOI = sheet.createRow( row - 1 );
+ }
+
HSSFCell cellPOI = rowPOI.createCell( column - 1 );
-
cellPOI.setCellStyle( cellStyle );
if ( type.equalsIgnoreCase( ExcelUtils.TEXT ) )
@@ -151,7 +156,6 @@
if ( v != 0 )
{
cellPOI.setCellValue( new HSSFRichTextString( value ) );
-
}
else
{
@@ -171,13 +175,17 @@
if ( row > 0 && column > 0 )
{
HSSFRow rowPOI = sheet.getRow( row - 1 );
+
+ if ( rowPOI == null )
+ {
+ rowPOI = sheet.createRow( row - 1 );
+ }
+
HSSFCell cellPOI = rowPOI.createCell( column - 1 );
-
cellPOI.setCellStyle( cellStyle );
cellPOI.setCellFormula( formula );
}
}
-
public static int convertExcelColumnNameToNumber( String columnName )
{