xinyongshu / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

How to display multiple dynamic tables in PDF using xdocreport and velocity.. #457

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
windows 7 and 64 bit

My requirement is like : 

Every time I get URL from Another application like below

URL : http://localhost:8080/CCH/render/......startlist....endlist.....

URL(simple view):
Actual Input :
------------
var location = window.location.hostname;
document.getElementById("cookTest").href="http://"+location+":8080/CCH/render?te
mplate=Cook test1.dotx&format=pdf&MCTYAPI=BRONX%26&MNAMAPI=MADISON S 
SMITH&MSTAAPI=NY&MZIPAPI=10462&TCDT=04/16/2013&"+
                                             "startlist=xyzzy&heading=DOSstart&heading=DOSend&heading=CodeType&heading=CodeDesc&element=1/3/2014&element=3/14/2014&element=cd1&element=decs1&element=2/3/2014&"+
                                             "element=3/24/2014&element=cd2&element=decs2&element=3/3/2014&element=3/8/2014&element=cd3&element=decs3&element=4/3/2014&element=3/4/2014&element=cd4&element=decs4&element=1/3/2014&element=3/4/2014&element=cd5&element=decs5&endlist=xyzzy" ;
Above Input I formatted simply below:   
-------------------------------------                                                                                    
Startlist=XYZZ&
Heading=DOSstart  & heading=DOSend    & heading=CodeType  &       
heading=CodeDesc &…………………
Element =1/3/2014 & Element =1/20/2014 & Element=CG1      &       Element=DESC1 
&…………………………
.
.
.
.

&Endlist=XYZZ
--------------------------------------------------------------------------------
-----------------------------
Expected output : 
-----------------
DOSstart DOSend CodeType CodeDesc
1/3/2014 3/14/2014 cd1 decs1
2/3/2014 3/24/2014 cd2 decs2
3/3/2014 3/8/2014 cd3 decs3
4/3/2014 3/4/2014 cd4 decs4
1/3/2014 3/4/2014 cd5 decs5

Using data(URL) I have written the java code successfully and displayed in the 
word document using xdocreport and velocity.

Below is the code I have written in java :
-----------------------------------------
Below is the code I have written in servlet to retrieve the url data:

queryString = request.getQueryString();
TableInterpreter ti = new TableInterpreter(queryString);
List<String> headings = ti.getHeadings();
map.put("heading", headings) ;

List<List<String>> dosData = new ArrayList<List<String>>();
for (int x = 0; x < ti.getRowCount(); x++){
String[] rowContent = ti.getRow(x);
List<String> listData = new ArrayList<String>();
for(int i = 0;i<rowContent.length;i++){
listData.add(rowContent[i]);
}
dosData.add(listData);
}
map.put("dataDos", dosData);

--------------------------------------------

IContext context = report.createContext();
context.put("content", ct);

List<DosData> dosData = (List<DosData>)ct.get("dataDos");
context.put("dosData", dosData);

List<String> heading = (List<String>)ct.get("heading");
context.put("heading", heading) ;
--------------------------------------------------
Template Code :
--------------------------------------
«@before-cell#foreach($d in $heading)»|
«$d» «@after-cell#end»                |
                                      |
«@before-row#foreach($d in $dosData)» |
«before-cell#foreach($f in $d)»«$f»   |
«@after-cell#end»                     |
«@after-row#end»                      |
--------------------------------------

----------------------------------------------------------------------

Using above data I have displayed in word document successfully, I added all 
the documents related this.

I got one more requirement like no of lists will come in URL like below : 

URL : 
http://localhost:8080/CCH/render/......startlist....endlist&...&startlist....end
list&....&startlist....endlist;

Above Input I formatted simply below:   
-------------------------------------                                                                                    
Startlist=XYZZ&
Heading=DOSstart  & heading=DOSend    & heading=CodeType  &       
heading=CodeDesc &…………………
Element =1/3/2014 & Element =1/20/2014 & Element=CG1      &       Element=DESC1 
&…………………………
.
.
.
.

&Endlist=XYZZ
..
&Startlist=XY&
Heading=DOSstart  & heading=DOSend    & heading=CodeType  &       
heading=CodeDesc &…………………
Element =1/3/2014 & Element =1/20/2014 & Element=CG1      &       Element=DESC1 
&…………………………
.
.
.
.

&Endlist=XY

&Startlist=XZ&
Heading=DOSstart  & heading=DOSend    & heading=CodeType  &       
heading=CodeDesc &…………………
Element =1/3/2014 & Element =1/20/2014 & Element=CG1      &       Element=DESC1 
&…………………………
.
.
.
.

&Endlist=XZ

Expected output :

DOSstart DOSend CodeType CodeDesc
1/3/2014 3/14/2014 cd1 decs1
2/3/2014 3/24/2014 cd2 decs2
3/3/2014 3/8/2014 cd3 decs3
4/3/2014 3/4/2014 cd4 decs4
1/3/2014 3/4/2014 cd5 decs5

DOSstart DOSend CodeType CodeDesc
1/3/2014 3/14/2014 cd1 decs1
2/3/2014 3/24/2014 cd2 decs2
3/3/2014 3/8/2014 cd3 decs3
4/3/2014 3/4/2014 cd4 decs4
1/3/2014 3/4/2014 cd5 decs5

DOSstart DOSend CodeType CodeDesc
1/3/2014 3/14/2014 cd1 decs1
2/3/2014 3/24/2014 cd2 decs2
3/3/2014 3/8/2014 cd3 decs3
4/3/2014 3/4/2014 cd4 decs4
1/3/2014 3/4/2014 cd5 decs5

I have displayed same tables in expected data , but in my request I get 
different data(unique).

Please give me suggestions how to parse URL data like in individual lists and 
display separate table for each list.
Please suggest me after split the data how to display in the form of dynamic 
tables in word document.

What modifications I need to change in "TableInterpreter" class file(attached 
file).Please help me on this.

Plese go through this link also : 
https://code.google.com/p/xdocreport/issues/detail?id=456&start=100

Please find attached documents : it contains only the code which is first 
scenario above.

Original issue reported on code.google.com by arun.har...@gmail.com on 29 Nov 2014 at 9:37

Attachments:

GoogleCodeExporter commented 9 years ago
One more file i forgot to include.

Original comment by arun.har...@gmail.com on 29 Nov 2014 at 10:38

Attachments:

GoogleCodeExporter commented 9 years ago
I'm little lost. 

Is your report works with a simple Java main?

Original comment by angelo.z...@gmail.com on 29 Nov 2014 at 10:47

GoogleCodeExporter commented 9 years ago
To be honnest with you, I have no time to try to execute your case. If you have 
problem, please explain your problem with a very simple sample which works in a 
Java main. Thank's

Original comment by angelo.z...@gmail.com on 29 Nov 2014 at 10:49

GoogleCodeExporter commented 9 years ago
Sorry Angelo, Can you please give us any sample app which works like dynamic 
table  generation,like above, I will try with that.

Thanks for supporting me.

Original comment by arun.har...@gmail.com on 29 Nov 2014 at 10:57