[reportlab-users] Problem with row&column spanning code not calculating table heights

Robin Becker reportlab-users@reportlab.com
Thu, 16 Oct 2003 18:02:29 +0100


In article <3F8EBEC5.5090602@gmx.net>, Oliver Bleutgen <myzope@gmx.net>
writes
>Robin Becker wrote:
>
.......
>
>I don't think column spanning cells change the problem, you just 
>virtually split them when setting up the dicts. So if you have
>(c0010,c01,c11), where c0010 spans the first row, you'll get
>[{0:c0010.height,1:c01.height},{0:c0010.height,1:c11.height}].
>
....... well I'm thinking about that, but I think it fairly hard to do
both rows & columns simultaneously.

To do what you suggest seems to require more of a grid like data set; if
we're given a set of

   cells(row,rowspan,col,colspan,width,height)

then we can certainly do the dict in column order find row heights, do
the conversion into row order and get col widths. There is a problem
with overlap.

>
>> My version of the code is slightly more efficient 
>
>Because of this snippet?
No actually I think it's the inner loop that's the tiniest bit faster

        for r in xrange(nr):
                mrh = 0
                for c in xrange(nc):
                        rha[c] += crh[c].get(r,0)
                        mrh = max(mrh,rha[c])
                mre.append(mrh)

instead of


for row in range(0,nr):
  for col in range(0,ncols):
      col_heights_accumulator[col] = cell_row_heights[col].get(row,0)+co
l_heights_accumulator[col]
      max_row_heights[row] = max(max_row_heights.get(row,0),col_heights_
accumulator[col])

I think the += and the elimination of the dict lookups on
max_row_heights probably make a difference.
>
>>         nr = -1                 # find the number of rows
>>         for c in crh:
>>                 nr = max(nr, max(c.keys()))
>>         nr += 1
>
>
>
>cheers,
>oliver
......
-- 
Robin Becker