dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03502
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1175: Fixed out of range bug - Finished
------------------------------------------------------------
revno: 1175
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2009-12-07 16:03:49 +0700
message:
Fixed out of range bug - Finished
modified:
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/webapp/dhis-web-excel-reporting/javascript/preview.js
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm
--
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-12-03 07:32:07 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/preview/action/XMLStructureResponse.java 2009-12-07 09:03:49 +0000
@@ -32,6 +32,8 @@
import java.io.IOException;
import java.util.Collection;
+import org.hisp.dhis.reportexcel.utils.StringUtils;
+
import jxl.Cell;
import jxl.CellType;
import jxl.Range;
@@ -41,8 +43,6 @@
import jxl.format.Colour;
import jxl.format.Pattern;
-import org.hisp.dhis.reportexcel.utils.StringUtils;
-
/**
* Simple demo class which uses the api to present the contents of an excel 97
* spreadsheet as an XML document, using a workbook and output stream of your
@@ -57,7 +57,7 @@
/**
* The encoding to write
*/
- private StringBuffer STRUCTURE_DATA_RESPONSE;
+ private StringBuffer STRUCTURE_DATA_RESPONSE = new StringBuffer( 200000 );
/**
* The encoding to write
@@ -99,6 +99,11 @@
return STRUCTURE_DATA_RESPONSE.toString();
}
+ private void cleanUpForResponse()
+ {
+ System.gc();
+ }
+
/**
* Constructor
*
@@ -119,12 +124,13 @@
throws Exception
{
+ this.cleanUpForResponse();
+
this.ENCODING = enc;
this.bWRITE_DTD = bWriteDTD;
this.bWRITE_VERSION = bWriteVersion;
this.PATH_FILE_NAME = pathFileName;
this.WORKBOOK = Workbook.getWorkbook( new File( pathFileName ) );
- this.STRUCTURE_DATA_RESPONSE = new StringBuffer();
if ( this.ENCODING == null || !this.ENCODING.equals( "UnicodeBig" ) )
{
@@ -137,14 +143,14 @@
}
else
{
- writeXML(collectSheets);
+ writeXML( collectSheets );
}
}
/**
* Writes out the WORKBOOK data as XML, without formatting information
*/
- private void writeXML(Collection<Integer> collectSheets)
+ private void writeXML( Collection<Integer> collectSheets )
throws IOException
{
if ( this.bWRITE_VERSION )
@@ -165,9 +171,9 @@
for ( Integer sheet : collectSheets )
{
- Sheet s = WORKBOOK.getSheet( sheet-1 );
+ Sheet s = WORKBOOK.getSheet( sheet - 1 );
- STRUCTURE_DATA_RESPONSE.append( " <sheet>" );
+ STRUCTURE_DATA_RESPONSE.append( " <sheet id=\"" + sheet + "\">" );
STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
STRUCTURE_DATA_RESPONSE.append( " <name><![CDATA[" + s.getName() + "]]></name>" );
STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
@@ -212,7 +218,7 @@
throws Exception
{
FileInputStream fis = new FileInputStream( this.PATH_FILE_NAME );
- org.apache.poi.ss.usermodel.Workbook hssfwb = new org.apache.poi.hssf.usermodel.HSSFWorkbook ( fis );
+ org.apache.poi.ss.usermodel.Workbook hssfwb = new org.apache.poi.hssf.usermodel.HSSFWorkbook( fis );
if ( bWriteDescription )
{
@@ -237,7 +243,7 @@
for ( Integer sheet : collectSheets )
{
- writeBySheetNo( hssfwb, (sheet-1), bDetailed );
+ writeBySheetNo( hssfwb, (sheet - 1), bDetailed );
}
STRUCTURE_DATA_RESPONSE.append( WORKBOOK_CLOSETAG );
@@ -252,7 +258,7 @@
{
Sheet s = WORKBOOK.getSheet( sheetNo );
- STRUCTURE_DATA_RESPONSE.append( " <sheet>" );
+ STRUCTURE_DATA_RESPONSE.append( " <sheet id=\"" + (sheetNo + 1) + "\">" );
STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
STRUCTURE_DATA_RESPONSE.append( " <name><![CDATA[" + s.getName() + "]]></name>" );
STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
@@ -280,7 +286,8 @@
{
bFormula = false;
- org.apache.poi.hssf.util.CellReference cellReference = new org.apache.poi.hssf.util.CellReference( i, j );
+ org.apache.poi.hssf.util.CellReference cellReference = new org.apache.poi.hssf.util.CellReference(
+ i, j );
org.apache.poi.ss.usermodel.Row rowRef = sheet.getRow( cellReference.getRow() );
org.apache.poi.ss.usermodel.Cell cellRef = rowRef.getCell( cellReference.getCol() );
@@ -425,7 +432,7 @@
for ( Integer sheet : collectSheets )
{
- writeBySheetNo( sheet-1 );
+ writeBySheetNo( sheet - 1 );
}
// Close the main Tag //
@@ -450,7 +457,7 @@
if ( iColTopLeft != iColBottomRight )
{
- STRUCTURE_DATA_RESPONSE.append( " <cell" + " iKey=\"" + sheetNo + "#" + iRowTopLeft + "#"
+ STRUCTURE_DATA_RESPONSE.append( " <cell" + " iKey=\"" + (sheetNo + 1) + "#" + iRowTopLeft + "#"
+ iColTopLeft + "\">" + (iColBottomRight - iColTopLeft + 1) + "</cell>" );
STRUCTURE_DATA_RESPONSE.append( PRINT_END_LINE );
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js 2009-12-04 09:37:23 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/preview.js 2009-12-07 09:03:49 +0000
@@ -46,10 +46,10 @@
aKey = new Array();
aMerged = new Array();
- var cells = parentElement.getElementsByTagName( 'cell' );
+ var cells = parentElement.getElementsByTagName( 'cell' );
- for (var i = 0 ; i < cells.length ; i ++) {
-
+ for (var i = 0 ; i < cells.length ; i ++)
+ {
aKey[i] = cells[i].getAttribute( 'iKey' );
aMerged[i] = cells[i].firstChild.nodeValue;
}
@@ -57,10 +57,10 @@
function getMergedNumberForEachCell( sKey ) {
- for (var i = 0 ; i < aKey.length ; i ++) {
-
- if ( sKey == aKey[i] ) {
-
+ for (var i = 0 ; i < aKey.length ; i ++)
+ {
+ if ( sKey == aKey[i] )
+ {
return Number(aMerged[i]);
}
}
@@ -70,16 +70,17 @@
function exportFromXMLtoHTML( parentElement ) {
var _index = 0;
+ var _orderSheet = 0;
var _sHTML = "";
var _sPattern = "";
var _rows = "";
var _cols = "";
var _sheets = parentElement.getElementsByTagName( 'sheet' );
- var _title = getElementValue(parentElement, 'name');
for (var s = 0 ; s < _sheets.length ; s ++)
{
- _rows = _sheets[s].getElementsByTagName( 'row' );
+ _rows = _sheets[s].getElementsByTagName( 'row' );
+ _orderSheet = getRootElementAttribute( _sheets[s], "id" );
_sHTML = "<table class='formatTablePreview'>";
@@ -92,7 +93,7 @@
for (var j = 0 ; j < _cols.length ; )
{
- var _number = _cols[j].getAttribute( 'no' );
+ var _number = getRootElementAttribute( _cols[j], 'no' );
// Printing out the unformatted cells
for (; _index < _number ; _index ++)
@@ -107,13 +108,13 @@
var _align = getElementAttribute( _cols[j], 'format', 'align' );
// If this cell is merged - Key's form: Sheet#Row#Col
- _sPattern = s + "#" + i + "#" + _number;
+ _sPattern = _orderSheet + "#" + i + "#" + _number;
_colspan = getMergedNumberForEachCell( _sPattern );
// Jumping for <For Loop> AND <Empty Cells>
j = Number(j) + Number(_colspan);
_index = Number(_index) + Number(_colspan);
-
+
_sHTML += "<td align='" + _align + "' colspan='" + _colspan;
if ( isNaN(_sData) == false )
@@ -131,15 +132,15 @@
}
_sHTML += "</table><br/>";
- if ( byId("fragment-" + eval(s+1)) != null ) {
-
- byId("fragment-" + eval(s+1)).innerHTML = _sHTML;
+ if ( byId( "fragment-" + _orderSheet ) != null )
+ {
+ byId( "fragment-" + _orderSheet ).innerHTML = _sHTML;
}
}
showById("tabs");
- window.status= "DATAWARE HOUSE - " + _title;
+ window.status = "DATAWARE HOUSE";
window.stop();
}
// END OF Previewed Report Excel //
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm 2009-12-04 09:54:43 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportparams.vm 2009-12-07 09:03:49 +0000
@@ -7,7 +7,6 @@
$("#tabs").tabs({collapsible : true});
});
</script>
-
<h2>$i18n.getString( "generate_report" )</h2>
<table>