[reportlab-users] Splitting a nested table over multiple pages
Mike Driscoll
mdriscoll at co.marshall.ia.us
Thu Jul 23 17:32:29 EDT 2009
Robin Becker wrote:
> Mike Driscoll wrote:
>> 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]]
>
> not sure what's going on here, but you should be aware that the inner
> tables will never be split as we always split on row boundaries. From
> the error it looks like one of the tables has something wrong with it.
>
> Why not try just outputting the inner tables one by one; if there's an
> issue there then the traceback might indicate which table is wrong.
> Could one of the inner tables actually be 0 x 0?
> .............
>
Okay...I went through all the tables in this query and I'm not seeing
it. Maybe a fresh pair of eyes is in order. I've pasted my output here:
http://paste.pocoo.org/show/130422/
These are the nested tables, which I stick into the mainTbl like this:
<code>
innerTableData = [["Earnings", "Earnings", "Earnings", "Earnings"],
earningTables,
["Deductions", "Deductions", "Deductions", "Deductions"],
deductionTables
]
mainTbl = Table(innerTableData, splitByRow=1)
story.append(mainTbl)
</code>
I'm sure all I need is a drubbing from the clue stick. Hopefully someone
has one handy.
- Mike
More information about the reportlab-users
mailing list