How can I make simple TABLE in ReportLab? I need to make simple table 2x20 and put i avery table some data. Can someone point me on example?
+1
A:
The simplest table function:
table = Table(data, colWidths=270, rowHeights=79)
How much lollums end rows depend from tuple of data... All function looks like:
def print_pdf(modeladmin, request, queryset):
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'
elements = []
doc = SimpleDocTemplate(response, rightMargin=0, leftMargin=6.5 * cm, topMargin=0.3 * cm, bottomMargin=0)
data=[(1,2),(3,4)]
table = Table(data, colWidths=270, rowHeights=79)
elements.append(table)
doc.build(elements)
return response
This will make table 2X2, and fill it with numbers 1,2,3,4. Then you can make file document. In my case i made HttpResponse what is pretty the same like file.
Pol
2010-08-03 13:24:19