[reportlab-users] Splitting a nested table over multiple pages

Mike Driscoll mdriscoll at co.marshall.ia.us
Wed Jul 22 10:57:12 EDT 2009


Hi,

I am working on a program that accepts large datasets and transforms
them into nested tables that need to be split across multiple pages in
ReportLab. Here's the basic setup:

1) My top level table has four columns and an unknown number of rows
2) In each column is a nested table
3) The nested table has 3 column and an unknown number of rows

When I try to feed my table the data, I end up getting the following
traceback:

IndexError: list index out of range
File "V:\PythonPackages\Development\pyRetention\pyRetention\pyreGUI.py",
line 143, in <module>
app.MainLoop()
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 7967, in MainLoop
wx.PyApp.MainLoop(self)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 7292, in MainLoop
return _core_.PyApp_MainLoop(*args, **kwargs)
File "V:\PythonPackages\Development\pyRetention\pyRetention\pyreGUI.py",
line 113, in onRun
pdfGenerator.createPDF(userData)
File
"V:\PythonPackages\Development\pyRetention\pyRetention\pdfGenerator.py",
line 87, in createPDF
doc.build(story, onFirstPage=onPageHeader)
File "c:\Python25\Lib\site-packages\reportlab\platypus\doctemplate.py",
line 1010, in build
BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
File "c:\Python25\Lib\site-packages\reportlab\platypus\doctemplate.py",
line 777, in build
self.handle_flowable(flowables)
File "c:\Python25\Lib\site-packages\reportlab\platypus\doctemplate.py",
line 665, in handle_flowable
if frame.add(f, canv, trySplit=self.allowSplitting):
File "c:\Python25\Lib\site-packages\reportlab\platypus\frames.py", line
159, in _add
w, h = flowable.wrap(aW, h)
File "c:\Python25\Lib\site-packages\reportlab\platypus\tables.py", line
1092, in wrap
self._calc(availWidth, availHeight)
File "c:\Python25\Lib\site-packages\reportlab\platypus\tables.py", line
571, in _calc
W = self._calcPreliminaryWidths(availWidth) #widths
File "c:\Python25\Lib\site-packages\reportlab\platypus\tables.py", line
665, in _calcPreliminaryWidths
value = self._cellvalues[rowNo][colNo]

My outer table is set up like this:

mainTbl = Table(data, splitByRow=1)

And here's some example data that goes into it:

data = [[tblOne, tblTwo, tblThree, tblFour], [ddTblOne, ddTblTwo,
ddTblThree, ddTblFour]]

I am doing my development on Windows with ReportLab 2.3 and Python 2.5.
Suggestions are most welcome.

Mike


More information about the reportlab-users mailing list