[reportlab-users] How to Draw Hierarchical tables (1 to many)

jpywtora at calpoly.edu jpywtora at calpoly.edu
Wed Dec 8 17:33:49 EST 2004


On Tuesday 07 December 2004 07:15 am, Remy Pinsonnault wrote:
> Hi everyone,
>
> I am a newbie with Reportlab and I am trying to do a hierchical table like
> the following example. I have no problem getting the data (from Oracle
> queries) but in fact I don't know how to draw the table, which library to
> use, etc.
>
> All of my columns have fixed width. Is there anyone that can point me how
> to do it or better, provide me with a code example :)
>
> Thanks
>
> NAME         -- ID       -- DATE
> --------------------------------------
> KERRY, JOHN  -- ID 12345 -- 2004/12/12
>     ID -- TITLE
>     ---------------------------
>     1  -- HELLO AMERICA 1
>     2  -- HELLO AMERICA 2
>
> BUSH, GEORGE -- ID 12346 -- 2004/12/11
>     ---------------------------
>     1  -- MASSIVE DESTRUCTION 1
>     2  -- TERRORISM 2
>
> Etc.
>
While openreport is a very viable solution.  Here are my thoughts for whatever 
it is worth.

See my recent post to another Table issue.  However it is relevant I think.  
You need to use multiple tables in your case.  You could use spanning, but I 
think that is more complex for this case and is not needed.  So just append 
each table one after the other.

# BEGIN T1
NAME         -- ID       -- DATE
--------------------------------------
KERRY, JOHN  -- ID 12345 -- 2004/12/12 
# END T1
# BEGIN T2
   ID -- TITLE
    ---------------------------
    1  -- HELLO AMERICA 1
    2  -- HELLO AMERICA 2
# END T2
# Spacer flowable or other flowable
# REPEAT T1 with different data
BUSH, GEORGE -- ID 12346 -- 2004/12/11
# END REPEAT T1
# BEGIN REPEAT T2 with different data
    ---------------------------
    1  -- MASSIVE DESTRUCTION 1
    2  -- TERRORISM 2
# END REPEAT T2
# AND SO ON

so if story was our array to pass the build method.
story.append(T1)
story.append(T2)
story.append(T1-diff_data)
story.append(T2-diff_data)

-- 
Windows
Start Here
Frustrating Hanging Crashing
Blue Screen of Death
Reboot


More information about the reportlab-users mailing list