jsreport如何向表格填充数据

发布于 2025-01-13 11:26:35 字数 1183 浏览 2 评论 0原文

我试图用数据填充表格以使用 jsreport 将其导出为 pdf 但我没能做到。 这是 html 文件:

<h1>test{{test}}</h1>
<table class='table striped'>
        <thead>
            <tr>
                <th>OrderID</th>
                <th>ShipAddress</th>
                <th>ShipCity</th>
                <th>ShipCountry</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>{{items.order}}</td>
                <td>{{items.addr}}</td>
                <td>{{items.city}}</td>
                <td>{{items.country}}</td>
            </tr>
        </tbody>
    </table>

这是数据:

{
"items": [
    {
        "order": "65854",
        "addr": "test 1",
        "city": "2fc2",
        "country": "2fc2"
    },
    {
        "order": "75757",
        "addr": "azerty",
        "city": "2fc2",
        "country": "2fc2"
    },
    {
        "order": "65575784",
        "addr": "tst",
        "city": "2fc2",
        "country": "2fc2"
    }
]
}

我已经尝试了很多东西,但我无法做到。

im trying to to fill a table with data to export it in pdf using jsreport
but i couldnt manage to do it .
This is the html file :

<h1>test{{test}}</h1>
<table class='table striped'>
        <thead>
            <tr>
                <th>OrderID</th>
                <th>ShipAddress</th>
                <th>ShipCity</th>
                <th>ShipCountry</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>{{items.order}}</td>
                <td>{{items.addr}}</td>
                <td>{{items.city}}</td>
                <td>{{items.country}}</td>
            </tr>
        </tbody>
    </table>

And this is the data :

{
"items": [
    {
        "order": "65854",
        "addr": "test 1",
        "city": "2fc2",
        "country": "2fc2"
    },
    {
        "order": "75757",
        "addr": "azerty",
        "city": "2fc2",
        "country": "2fc2"
    },
    {
        "order": "65575784",
        "addr": "tst",
        "city": "2fc2",
        "country": "2fc2"
    }
]
}

I've tried a lot of things but i couldnt manage to do it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最单纯的乌龟 2025-01-20 11:26:35

您必须使用

<h1>test{{test}}</h1>
<table class='table striped'>
    <thead>
        <tr>
            <th>OrderID</th>
            <th>ShipAddress</th>
            <th>ShipCity</th>
            <th>ShipCountry</th>
        </tr>
    </thead>
    <tbody>
       {{#each items}}
        <tr>
            <td>{{order}}</td>
            <td>{{addr}}</td>
            <td>{{city}}</td>
            <td>{{country}}</td>
        </tr>
       {{/each}}
    </tbody>
</table>

https://jsreport.net/learn/handlebars

you must use

<h1>test{{test}}</h1>
<table class='table striped'>
    <thead>
        <tr>
            <th>OrderID</th>
            <th>ShipAddress</th>
            <th>ShipCity</th>
            <th>ShipCountry</th>
        </tr>
    </thead>
    <tbody>
       {{#each items}}
        <tr>
            <td>{{order}}</td>
            <td>{{addr}}</td>
            <td>{{city}}</td>
            <td>{{country}}</td>
        </tr>
       {{/each}}
    </tbody>
</table>

https://jsreport.net/learn/handlebars

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文