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

Marc Stober reportlab-users@reportlab.com
Thu, 16 Oct 2003 12:56:42 -0400


> 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

--
Marc Stober
mstober@dalbar.com