Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reportlab: setting colspan for td in rml

I can't find any option, that would allow to set colspan for td element in rml. Is that somehow possible?

like image 970
gruszczy Avatar asked Feb 15 '11 11:02

gruszczy


2 Answers

Gordon's suggestion of the blockSpan element worked for me. Here's an example of how to use it:

<?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>
like image 154
Don Kirkby Avatar answered Nov 02 '22 06:11

Don Kirkby


The normal ReportLab way to do this would be to instead use Platypus and the Table flowable. When you set the style of the Table, you can specify a 'SPAN' command that will bundle any rectangular area of cells into one. You'll find more information on this in the ReportLab User Guide, chapter 7, page 81.

If you must use RML, I'm inclined to think that colspan is simply not available. It's at least not in the ReportLab RML reference document. Instead I think you are supposed to use blockSpan elements. There's no example given, but you'll find it in the RML manual.

like image 35
G Gordon Worley III Avatar answered Nov 02 '22 08:11

G Gordon Worley III