[reportlab-users] Re: Problem with row&column spanning

David Fraser reportlab-users@reportlab.com
Thu, 16 Oct 2003 20:26:21 +0200


Marc Stober wrote:

>>Any hints or code on how the FancyTable layout algorithm works? Is it 
>>that you can use a simple algorithm because you know how you want it 
>>laid out, or does it have more advanced layout algorithms built in?
>>    
>>
>
>It's a pretty simple algorithm. Here it is:
>            colWidth = availWidth / (colCount + FIRST_COL_RATIO - 1)
>            self.colWidths = [FIRST_COL_RATIO * colWidth]
>            self.colWidths.extend([colWidth - .001] * (colCount - 1))
>
>It makes evenly spaced columns to fill the frame, and works with any number
>of columns. The first column is wider to accomodate labels. 
>
>It may be simple but it sure looks nice. The exception to this is when some
>columns contain wide values, and others contain just a single character; in
>these cases I've hacked things up to provide a list of ratios (but then I
>need to know the number of columns in advance). The goal, in any case, is to
>get the columns to *appear* evenly spaced on the page without a lot of
>manual aligning, rather than a strictly mathematical optimization as I'd
>expect from linear programming.
>
>- Marc
>  
>
Cool, thanks for explaining. The difficulty seems to be when you have to 
deal with row spanning and column spanning...
but perhaps the idea of having different selectable algorithms would 
work well, using something like this when you know the column widths

David