[reportlab-users] Re: platypus table header
JP Glutting
jpglutting at oqua.udl.es
Tue Jun 6 06:39:17 EDT 2006
Hi Zlaty!
I don't know exactly where I posted a comment (and I don't remember if I
posted code or not, but this is the hack I put together. It does not put
a header on each page, but in fact creates a new table for each page. it
could adjust for different sized pages and different sized fonts, but it
does not, because I needed to get this done fast, and I never went back
to fix it. I figure that this issue will go away. For me, it resolved
the issue of a complex header (with vertical and horizontal spans)
losing format when the table went off the end of the page. The problem
with this "solution" is that you have to adjust the number of lines that
will fit on a page by trial and error (set as ilen). It depends on your
margins, and your font, and the paper size.
This is not a good solution, but it works for what I need to do.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
# Adjust for size of page
#
# First row is index 0
istart = 0
# A page can hold 40 single-spaced rows, Times 7
ilen = 38
# tdlen is the number of rows that need to be printed
tdlen = len(tdata)
# Set the cut index to 0
icut = 0
# Calculate list of cut indices, cutting every ilen (initially
40) rows
icuts = range(ilen, tdlen, ilen)
# This is a slow loop ... check each cut index
for ix, icut in enumerate(icuts):
# Adjust minus 3 for the header (specific to this table)
if ix > 0: icut -= 3
r.table(tdata[istart:icut], thead, title=ttitle, tstyle=rts,
halign='CENTER')
r.pb()
#print '\t', icut - istart
istart = icut
# No cuts needed - table fits all on one page
if not icuts and tdlen <= ilen:
icut = ilen
r.table(tdata[:icut], thead, title=ttitle, tstyle=rts,
halign='CENTER')
r.pb()
istart = icut
# Generate last table when trhee is remainin data after last cut.
if tdata[istart:]:
r.table(tdata[istart:], thead, title=ttitle, tstyle=rts,
halign='CENTER')
Zlati wrote:
> Greetings
> Dont know if you received my previous mail
> I'm using platypus table and want to have header on every page, but i
> cant find your previous mail, so some help will be appriciated, either
> by pointing me to the right place to look or reply with example code
> Thanks in advance
> Python/reportlab newbie
--
____________________________________________________
Oficina de Qualitat Tel: 973 703 103
Universitat de Lleida Fax: 973 702 036
Pl. Víctor Siurana, 1
25003 Lleida
____________________________________________________
More information about the reportlab-users
mailing list