Jasper reports 列和表标题与数据本身位于同一数据源中(json数据源)

Jasper reports 列和表标题与数据本身位于同一数据源中(json数据源),jasper-reports,Jasper Reports,我的报表中有一个表元素的json数据源。我的json是- [{ "line_num": { "oldVal": "1", "newVal": "5" }, "product1": { "oldVal": "product1old", "newVal": "product1new" } }, { "line_num": {

我的报表中有一个表元素的json数据源。我的json是-

[{
        "line_num": {
            "oldVal": "1",
            "newVal": "5"
        },
        "product1": {
            "oldVal": "product1old",
            "newVal": "product1new"
        }
}, {
    "line_num": {
        "oldVal": "4",
        "newVal": "7"
    },
    "product2": {
        "oldVal": "product2old",
        "newVal": "product2new"
    }
}
]
这对我的报告有效,但是我需要从数据源添加列和表头

因此,我尝试将其作为自己的对象添加到上面的json数组中,如下所示:

[{
        "tableH": "My Table Header"  ,         
        "col1H": "Line No."  ,     
        "col2H": "My Product"  
    }, {
        "line_num": {
            "oldVal": "1",
            "newVal": "5"
        },
        "product1": {
            "oldVal": "product1old",
            "newVal": "product1new"
        }

    }, {
        "line_num": {
            "oldVal": "4",
            "newVal": "7"
        },
        "product2": {
            "oldVal": "product2old",
            "newVal": "product2new"
        }
    }
]
[{
        "tableH": "My Table Header"  ,        
        "col1H": "Line No."  ,        
        "col2H": "My Product"  ,
        "Lines": [{
                "line_num": {
                    "oldVal": "1",
                    "newVal": "5"
                },
                "product1": {
                    "oldVal": "product1old",
                    "newVal": "product1new"
                }

            }, {
                "line_num": {
                    "oldVal": "4",
                    "newVal": "7"
                },
                "product2": {
                    "oldVal": "product2old",
                    "newVal": "product2new"
                }
            }
        ]
    }
]        
但问题是,当有很多行大于页面高度时,第二页上的标题为空,这是有意义的,因为第一个obj(标题obj)从第二行开始是未知的

但我不知道如何以另一种方式从服务器传递头

唯一有效的方法是将所有头添加到数组中的每个obj,但我不能这样做,因为这显然是错误的

我还尝试将这些线作为一个数组,如下所示:

[{
        "tableH": "My Table Header"  ,         
        "col1H": "Line No."  ,     
        "col2H": "My Product"  
    }, {
        "line_num": {
            "oldVal": "1",
            "newVal": "5"
        },
        "product1": {
            "oldVal": "product1old",
            "newVal": "product1new"
        }

    }, {
        "line_num": {
            "oldVal": "4",
            "newVal": "7"
        },
        "product2": {
            "oldVal": "product2old",
            "newVal": "product2new"
        }
    }
]
[{
        "tableH": "My Table Header"  ,        
        "col1H": "Line No."  ,        
        "col2H": "My Product"  ,
        "Lines": [{
                "line_num": {
                    "oldVal": "1",
                    "newVal": "5"
                },
                "product1": {
                    "oldVal": "product1old",
                    "newVal": "product1new"
                }

            }, {
                "line_num": {
                    "oldVal": "4",
                    "newVal": "7"
                },
                "product2": {
                    "oldVal": "product2old",
                    "newVal": "product2new"
                }
            }
        ]
    }
]        
但随后字段没有正确传递,例如传递了-lines.line_num.newVal,字段是:[“5”,“7”]


我真的需要这方面的帮助,如果有任何有用的回复,我将不胜感激。

将数据集与静态数据混合似乎是个坏主意。我的第一次尝试是通过scriptlet获取静态数据

否则,您可以在组标题组件中添加列名,并利用组的
isReprinReaderOneachPage
属性提供的功能


将数据集与静态数据混合似乎是个坏主意。我的第一次尝试是通过scriptlet获取静态数据

否则,您可以在组标题组件中添加列名,并利用组的
isReprinReaderOneachPage
属性提供的功能


我们可以使用一些sample.jrxml文件来了解您想要的输出。你真的需要用桌子吗?您使用的是什么版本的JasperReports?我们可以使用一些示例.jrxml文件来了解您想要的输出。你真的需要用桌子吗?您使用的是什么版本的JasperReports?