How to display the list data in row format by using xdocreport and velocity

2.6k views Asked by At
    Java code:
    ------------------------------------
    List dosData = new ArrayList();

    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);
    }

    If I print dosData variable:

    system.out.println(dosData);

    --------------------
    [1/3/2014, 3/4/2014,|(list contains lists)
    cd1, decs1]         |
    ------------------- |
    [1/3/2014, 3/4/2014,|
    cd2, decs2]         |
    ------------------- |
    [1/3/2014, 3/4/2014,|
    cd3, decs3]         |
    ------------------- |
    [1/3/2014, 3/4/2014,|
     cd4, decs4]         |
    ------------------- 

    I want to display above content in word document in the form row format, I have tried below code   to display

  ------------------------------------------
    «@before-cell#foreach($d in $dosData)»  |
    «@before-cell#foreach($f in $d)»        |
    «$f»                                    |
    «@after-cell#end»                       |
    «@after-cell#end»                       |
 --------------------------------------------
Its working,But it is not getting required format what we want,Below is the expected result what we want.

    Expected format:
    ---------------

    1/3/2014    3/4/2014 cd1 decs1
    1/3/2014    3/4/2014 cd2 decs2
    1/3/2014    3/4/2014 cd3 decs3
    1/3/2014    3/4/2014 cd4 decs4

Actual format I am getting when I run above code in word document(wrong format) : linearly we are getting response.

1/3/2014 3/4/2014 cd1 decs1 1/3/2014 3/4/2014 cd2 decs2 1/3/2014 3/4/2014 cd3 decs3 1/3/2014 3/4/2014 cd4 decs4 .....

    Please help me on this any one ...
1

There are 1 answers

4
Jitesh On

You need to put a new line character after inner loop.

«@before-cell#foreach($d in $dosData)»  |
«@before-cell#foreach($f in $d)»        |
«$f»                                    |
«@after-cell#end»    
new line character                   |
«@after-cell#end»  

New line character can be \n , \r or \n\r .