0
    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

当我在 word 文档中运行上述代码时得到的实际格式(错误格式):线性地,我们得到了响应。

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 ...
4

1 回答 1

0

您需要在内循环之后放置一个换行符。

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

换行符可以是 \n 、 \r 或 \n\r 。

于 2014-11-28T05:58:32.267 回答