[reportlab-users] Crash when creating vertical spans on split tables

Aaron Barlow aaron.barlow at gmail.com
Fri Nov 4 13:06:53 EDT 2011

I had that same problem. I fixed it by adjusting the source code in tables.py from:

t = sum([V[x]+M.get(x,0) for x in xrange(x0,x1)]) on line 205


for x in xrange(x0, x1):
if V[x] is None:
t += V[x]+M.get(x,0)

The error is because spanning in PDF tables creates a "super-cell" and a vertical split of a table cell isn't defined. I'm sure someone will correct me if I'm wrong about that. However, for my needs, changing the source code above removed the error.


On Nov 3, 2011, at 6:24 PM, Casey Banner wrote:

> Hi,


> I have a crash that I can reproduce by adding a vertical SPAN to my TableStyle which ends up either crossing over a split border, or begins at the first row of any split other than the first.


> Example: Table is split at row 5, and the SPAN is from 3 to 7.

> Example: Table is split at row 5, and the SPAN is from 5 to 7.


> I have made sure that the first cell in my SPAN is not an empty string.


> The trace:


> File "render.py", line 179, in <module>

> doc.build([t])

> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-macosx-10.6-x86_64.egg/reportlab/platypus/doctemplate.py", line 1117, in build

> BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)

> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-macosx-10.6-x86_64.egg/reportlab/platypus/doctemplate.py", line 880, in build

> self.handle_flowable(flowables)

> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-macosx-10.6-x86_64.egg/reportlab/platypus/doctemplate.py", line 763, in handle_flowable

> if frame.add(f, canv, trySplit=self.allowSplitting):

> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-macosx-10.6-x86_64.egg/reportlab/platypus/frames.py", line 159, in _add

> w, h = flowable.wrap(aW, h)

> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-macosx-10.6-x86_64.egg/reportlab/platypus/tables.py", line 1113, in wrap

> self._calc(availWidth, availHeight)

> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-macosx-10.6-x86_64.egg/reportlab/platypus/tables.py", line 587, in _calc

> self._calc_height(availHeight,availWidth,W=W)

> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-macosx-10.6-x86_64.egg/reportlab/platypus/tables.py", line 553, in _calc_height

> spanFixDim(H0,H,spanCons,lim=hmax)

> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-macosx-10.6-x86_64.egg/reportlab/platypus/tables.py", line 205, in spanFixDim

> t = sum([V[x]+M.get(x,0) for x in xrange(x0,x1)])

> TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'


> Any ideas on what would cause this?


> Thanks,

> Casey


> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20111104/e455f18b/attachment.html>

More information about the reportlab-users mailing list