[reportlab-users] Problem with a table of tables

Tim Roberts timr at probo.com
Wed Feb 27 16:25:31 EST 2013


Holyoak, Shawn wrote:

>

> I’m really new to ReportLab, and I’m trying to layout a table of

> tables (i.e., each row of the table is a table). I’m doing this as I

> need to repeat a row at the top of each page, but the rows of the

> subtables have different column counts (attached, if attachments are

> accepted, is what the report looks like).

>


In my view, tables are just the wrong way to solve this problem. What
you have here is a very simple, traditional report-writer report with
detail lines and a group subtotals. Just track the Y coordinate and do
the drawing yourself. Define a function to draw your detail line where
you pass the four fields. Include a parameter to specify whether to
draw a line above or below. You can use that same function to draw your
page header and your group subtotal line.

def DrawDetailLine( self, Y, fields, line=false ):
self.canvas.drawText( 1*inch, Y, fields[0] )
self.canvas.drawText( 3*inch, Y, fields[1] )
self.canvas.drawText( 5*inch, Y, fields[2] )
self.canvas.drawRightText( 7*inch, Y, fields[3] )
if line:
self.canvas.line( 1*inch, Y-6, 7.5*inch, Y-6 )
return Y - self.canvas._leading

Now you just loop through your database records, watching for the date
to change. You then close and print your subtotal, skip a bit, and
print the new date.

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20130227/68855500/attachment.html>


More information about the reportlab-users mailing list