如何汇总 XSL-FO 表格中每页的一些值?

发布于 2024-12-12 04:49:04 字数 2216 浏览 0 评论 0原文

我正在使用 XSL-FO 生成帐户报表打印输出。 PDF 实际上只是一个简单的表格,每页上都有一个简单的页眉。困难在于我必须显示每页的交易量,例如

第 1 页

+------------------------------+-----------+-----------+---------------------+
| Text                         | Credit    | Debit     | Balance             |
+------------------------------+-----------+-----------+---------------------+
| Previous month               |           |           |           (*1) 1000 |
| abc                          |      1000 |           |                2000 |
| abc                          |           |       500 |                1500 |
| abc                          |           |       200 |                1300 |
| ...                          |           |           |                     |
| Carry over                   | (*2) 1000 |  (*3) 700 |           (*4) 1300 |
+------------------------------+-----------+-----------+---------------------+

第 2 页

+------------------------------+-----------+-----------+---------------------+
| Text                         | Credit    | Debit     | Balance             |
+------------------------------+-----------+-----------+---------------------+
| Previous page                | (*2) 1000 |  (*3) 700 |           (*4) 1300 |
| abc                          |      1000 |           |                2300 |
| abc                          |           |       500 |                1800 |
| abc                          |           |       200 |                1600 |
| ...                          |           |           |                     |
| Carry over                   | (*2) 2000 | (*3) 1400 |           (*4) 1600 |
+------------------------------+-----------+-----------+---------------------+

这里有一些解释:

  1. 这是上个月的余额。它是预先计算的并且被称为 XSL 变量。没问题,这是一个常规标题(仅在第一页上)
  2. 该值是按页计算的。它汇总了同一页面上的所有信用金额。我自己无法计算,因为我不知道 XSL-FO 何时会进行分页。所以我想 XSL-FO 必须为我进行计算。页面底部的总和与下一页顶部的值相同。
  3. 该值与 2 相同,仅适用于借方金额。
  4. 该值只是页面底部最后一笔交易的余额。该值将在下一页的顶部重复。

如何使用 XSL-FO 进行这些计算?

另请参阅此相关问题:如何根据XSL-FO中的页码显示一项或多项信息?

I'm using XSL-FO to generate an account statement print out. The PDF is actually just a simple table with a simple header on every page. The difficulty is that I have to display transaction volumes per page, e.g.

Page 1

+------------------------------+-----------+-----------+---------------------+
| Text                         | Credit    | Debit     | Balance             |
+------------------------------+-----------+-----------+---------------------+
| Previous month               |           |           |           (*1) 1000 |
| abc                          |      1000 |           |                2000 |
| abc                          |           |       500 |                1500 |
| abc                          |           |       200 |                1300 |
| ...                          |           |           |                     |
| Carry over                   | (*2) 1000 |  (*3) 700 |           (*4) 1300 |
+------------------------------+-----------+-----------+---------------------+

Page 2

+------------------------------+-----------+-----------+---------------------+
| Text                         | Credit    | Debit     | Balance             |
+------------------------------+-----------+-----------+---------------------+
| Previous page                | (*2) 1000 |  (*3) 700 |           (*4) 1300 |
| abc                          |      1000 |           |                2300 |
| abc                          |           |       500 |                1800 |
| abc                          |           |       200 |                1600 |
| ...                          |           |           |                     |
| Carry over                   | (*2) 2000 | (*3) 1400 |           (*4) 1600 |
+------------------------------+-----------+-----------+---------------------+

Here are some explanations:

  1. This is the previous month's balance. It's pre-calculated and well-known as an XSL variable. No problem with that, that's a regular header (only on the first page)
  2. This value is calculated on a per-page basis. It sums up all credit amounts on the same page. I can't calculate that myself, as I don't know when XSL-FO will do the page break. So I imagine XSL-FO must do the calculation for me. The sum at the bottom of a page is the same as the value at the top of the subsequent page.
  3. This value is the same as 2, only for debit amounts.
  4. This value is just the last transaction's balance at the bottom of a page. That value is repeated at the top of the next page.

How can I do these calculations with XSL-FO?

See also this related question: How to display one or the other information depending on the page number in XSL-FO?

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

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

发布评论

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

评论(2

扭转时空 2024-12-19 04:49:04

尝试“表格标记”: http://www.w3.org/TR/ xsl/#fo_retrieve-table-marker

在 XSLT 中,为每一行注入一个带有总和的标记。然后让引擎选择一个标记来替换表头或表尾中的 fo:retrieve-table-marker。这个想法是,在渲染时将根据标记在页面上的位置以及 fo:retrieve-table-marker 上的 @retrieve-position 和 @retrieve-boundary 选择适当的标记。

Try "table markers": http://www.w3.org/TR/xsl/#fo_retrieve-table-marker.

In XSLT for each row inject a marker with the sum. Then let the engine select a marker to substitute for the fo:retrieve-table-marker in table header or footer. The idea is that proper marker will be selected at rendering time depending on the marker's position on the page and @retrieve-position and @retrieve-boundary on the fo:retrieve-table-marker.

江湖彼岸 2024-12-19 04:49:04

不幸的是,(在我回答这个问题时,它不再正确)fop没有实现< ;fo:retrieve-table-marker/> 根据我的发现。相反,这里的解决方案对我有用:

如何根据 XSL-FO 中的页码显示一个或另一个信息?

它涉及在 XSL-FO 之外创建一个单独的表 使用 元素显示表头。

Unfortunately, (at the time when I answered this question, it's no longer true) fop doesn't implement <fo:retrieve-table-marker/> from what I have found out. Instead, this solution here worked for me:

How to display one or the other information depending on the page number in XSL-FO?

It involves creating a separate table outside of the <fo:flow/> that displays the table header using <fo:retrieve-marker/> elements.

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