2011-02-15 84 views

回答

3

正常的ReportLab方法可以做到這一點,而不是使用鴨嘴獸和Table流動。當您設置Table的樣式時,您可以指定一個'SPAN'命令,將任何矩形區域的單元格合併爲一個。您可以在ReportLab User Guide的第7章第81頁找到更多信息。

如果您必須使用RML,我傾向於認爲colspan根本不可用。至少不在ReportLab RML reference document。相反,我認爲你應該使用blockSpan元素。沒有給出的例子,但你會發現它在the RML manual

+0

不是那麼完美方針破解的解決方案爲唐柯比提到 – 2017-05-18 08:52:02

8

戈登對元素的建議爲我工作。這裏有一個如何使用它的一個例子:

<?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> 
+0

最有用的解決方案,需要了解合併前兩列,合併上一個原始的第一和第二列。 – 2017-05-18 08:53:25