[reportlab-users] Problem with a table of tables
Holyoak, Shawn
shawn.holyoak at dallascityhall.com
Wed Feb 27 17:13:22 EST 2013
I thought that would end up being the case. That's how the report is
written in our desktop software - I was hoping for something more
elegant as we move it to the web.
Shawn Holyoak
From: reportlab-users-bounces at lists2.reportlab.com
[mailto:reportlab-users-bounces at lists2.reportlab.com] On Behalf Of Tim
Roberts
Sent: Wednesday, February 27, 2013 3:26 PM
To: reportlab-users
Subject: Re: [reportlab-users] Problem with a table of tables
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/73971104/attachment.htm>
More information about the reportlab-users
mailing list