[reportlab-users] simple tables example

Timothy Smith timothy at open-networks.net
Thu Dec 23 05:26:12 EST 2004


it takes a list or a tuple...

Shayan Raghavjee wrote:

> I may be wrong, haven't used ReportLab much in a few months, but....
>
> Timothy Smith wrote:
>
>>
>> ok an update
>>
>> i found a small example but now i get this
>>
>> File "/usr/home/timothy/Projects/PubWare/python/WeeklyReportPDF.py", 
>> line 29, in MakeReport
>>    t = Table(WeeklyReport, rowheight, colwidth)
>>  File 
>> "/usr/local/lib/python2.3/site-packages/reportlab/platypus/tables.py", 
>> line 149, in __init__
>>    elif len(colWidths) != ncols:
>> TypeError: len() of unsized object
>>
>> here is my code
>>
>> doc = SimpleDocTemplate('tmp.pdf')
>>      WeeklyReport = ('test','test','test')
>
>
> Shouldn't this be a list of lists, the tabledata should normally 
> resemble a grid I think?
> WeeklyReport = [['test', 'test', 'test']]
> or
> WeeklyReport = [['test', 'test', 'test'],
>                            ['test', 'test', 'test']]
>
>>  
>>    rowheight=(10)
>>    colwidth = (16,16,16)
>
>
> These should be lists too,
> rowheight = [10]
> colwidth = [10, 10, 10]
>
>>    t = Table(WeeklyReport, rowheight, colwidth)
>>    doc.build(t)
>>
>>
>
> That should work, shouldn't it?
>
>



More information about the reportlab-users mailing list