reportlab:在rml中为td设置colspan

gru*_*czy 5 python reportlab rml

我找不到任何选项,这将允许设置colspantd在元素rml.这有可能吗?

Don*_*kby 8

戈登对这个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>
Run Code Online (Sandbox Code Playgroud)


G G*_*III 4

执行此操作的正常 ReportLab 方法是使用 Platypus 和 flowable Table。当您设置 的样式时Table,您可以指定一个'SPAN'命令,将单元格的任意矩形区域捆绑为一个。您可以在《ReportLab 用户指南》第 7 章第 81 页中找到更多相关信息。

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