[reportlab-users] Alignment in table with flexible data(2)
Helga Peters
helga at full-control.nl
Thu May 21 05:08:12 EDT 2015
Hello,
I posted a question on the 12th, and have been trying things in the
meantime, but keep getting the same result.
As pointed out I'm working on a report. This report has a table in which
one or more reports will be summarized.
The table contains in the 1ste column of fixed text data, in the 2nd column
flexible text data and in the 3th column an Image can be displayed.
I used paragraphs for the cells with flexible text data and that seems to
works well.
The only thing I'm wrestling with is the alignments (ALIGN and VALIGN) of
the cells. When there is only 1 report it works well, however when there
are more reports, only in the 1ste report the alignments (ALIGN and
VALIGN) work and in the subsequent reports the alignments (ALIGN and
VALIGN) do not work.
The spanning work even when there are several reports.
Not sure what I'm missing here. Any suggestions ?
Below my code.
Thanks in advance,
Helga
-----------
story [ ]
t_data = [ ('Report(s):', '','') ]
t_style = [ ('FONT', (0, 0), (1, 0), 'Helvetica-Bold'),
('ALIGN', (2,1), (2,3), 'CENTER') ]
for rpt in report:
if rpt.image_url != None :
I = Image(rpt.image_url)
I.drawHeight = 3 * cm * I.drawHeight / I.drawWidth
I.drawWidth = 3 * cm
else:
I = ' '
ptext0 = '%s' % rpt.place
cell0 = [Paragraph(ptext0, styles['Normal']) ]
t_style += [ ('SPAN', (2, len(t_data)), (2, len(t_data)+2)),
('VALIGN',(0,1),(1,1),'TOP') ]
t_data.append(('Place:' , cell0 , I ))
ptext1 = '%s' % rpt.description
cell1 = [Paragraph(ptext1, styles['Normal']) ]
t_style += [ ('ALIGN', (0,2), (1,2), 'LEFT'),
('VALIGN',(0,2),(1,2),'TOP') ]
t_data.append(('Description:', cell1,''))
t2=Table(t_data, colWidths=[30*mm,90*mm,45*mm], style= t_style,
repeatRows = 1)
story.append(t2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20150521/09844a1d/attachment.html>
More information about the reportlab-users
mailing list