【问题标题】:reportlab: setting colspan for td in rmlreportlab:在 rml 中为 td 设置 colspan
【发布时间】:2011-02-15 11:18:25
【问题描述】:

我找不到任何选项,它允许在rml 中为td 元素设置colspan。这有可能吗?

【问题讨论】:

    标签: python reportlab rml


    【解决方案1】:

    Gordon 对blockSpan 元素的建议对我有用。这是一个如何使用它的示例:

    <?xml version="1.0"?>
    <document filename="test.pdf">
      <template pageSize="(612,792)" title="Test" author="Don Kirkby">
        <pageTemplate id="first">
          <frame id="first" x1="10.0" y1="10.0" width="592" height="772"/>
        </pageTemplate>
      </template>
      <stylesheet>
        <blockTableStyle id="main">
          <blockSpan start="0,1" stop="1,1"/>
        </blockTableStyle>
      </stylesheet>
      <images/>
      <story>
        <blockTable colWidths="100.0,287.5,187.5" style="main">
          <tr>
            <td><para>Cell 0,0</para></td>
            <td><para>Cell 1,0</para></td>
            <td><para>Cell 2,0</para></td>
          </tr>
          <tr>
            <td><para>Cell 0,1 will flow into its neighbour</para></td>
            <td><para>Cell 1,1 will not appear, but must be present</para></td>
            <td><para>Cell 2,1</para></td>
          </tr>
          <tr>
            <td><para>Cell 0,2</para></td>
            <td><para>Cell 1,2</para></td>
            <td><para>Cell 2,2</para></td>
          </tr>
        </blockTable>
      </story>
    </document>
    

    【讨论】:

    • 最有用的解决方案,需要了解 合并前两列, 将最后一个 raw 与第一列和第二列合并。
    【解决方案2】:

    通常的 ReportLab 方法是使用 Platypus 和 Table flowable。当您设置Table 的样式时,您可以指定一个'SPAN' 命令将任何矩形单元格区域捆绑为一个。您可以在ReportLab User Guide,第 7 章,第 81 页找到更多信息。

    如果您必须使用 RML,我倾向于认为 colspan 根本不可用。至少不在ReportLab RML reference document 中。相反,我认为您应该使用 blockSpan 元素。没有给出示例,但您可以在 the RML manual 中找到它。

    【讨论】:

    • Don Kirkby 提到的破解解决方案的指南并不完美
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 2017-01-30
    • 1970-01-01
    • 2013-07-26
    • 1970-01-01
    相关资源
    最近更新 更多