[reportlab-users] reportlab question

Lionel Roubeyrie reportlab-users@reportlab.com
Thu, 9 Sep 2004 14:07:22 +0200


Hello all,
I try to plot a table on a canvas with the Table module, but it cries for an 
unexisting method :-(
My code :
####################################
from reportlab.pdfgen import canvas
from reportlab.platypus import Table, TableStyle
from reportlab.lib.pagesizes import A4
from reportlab.lib.colors import green, orange, red, black

def box(c, h, a, d):
 ''' Presentation des valeurs de hier, aujourdhui et demain'''
 data =  [["hier", "aujourd'hui", " demain"],
    [str(h), str(a), str(d)]]
 t = Table(data)
 t.setStyle(TableStyle([('ALIGN', (0,0), (-1,-1), 'CENTER'),
      ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
      ('FONT',(0,0), (-1,-1), ('helvetica', 12)),
      ('INNERGRID', (0,0), (-1,-1), 1, black),
      ('BOX', (0,0), (-1,-1), 2, black)]))
 t.drawOn(c, 100,100)

c=canvas.Canvas("test.pdf", pagesize=A4)
box(c,5,6,7)
c.showPage()
c.save()
##################################
gives :

Traceback (most recent call last):
  File "tableau.py", line 62, in ?
    box(c,5,6,7)
  File "tableau.py", line 20, in box
    t.drawOn(c, 100,100)
  File "/usr/lib/python2.3/site-packages/reportlab/platypus/flowables.py", 
line 98, in drawOn
    self._drawOn(canvas)
  File "/usr/lib/python2.3/site-packages/reportlab/platypus/flowables.py", 
line 83, in _drawOn
    self.draw()#this is the bit you overload
  File "/usr/lib/python2.3/site-packages/reportlab/platypus/tables.py", line 
872, in draw
    self._drawLines()
  File "/usr/lib/python2.3/site-packages/reportlab/platypus/tables.py", line 
658, in _drawLines
    getattr(self,_LineOpMap.get(op, '_drawUnknown' ))( (sc, sr), (ec, er), 
weight, color)
  File "/usr/lib/python2.3/site-packages/reportlab/platypus/tables.py", line 
676, in _drawInnerGrid
    self._drawHLines((sc, sr+1), (ec, er), weight, color)
  File "/usr/lib/python2.3/site-packages/reportlab/platypus/tables.py", line 
688, in _drawHLines
    ecp = self._colpositions[sc:ec+2]
AttributeError: Table instance has no attribute '_colpositions'

Argggggggggg!

-- 
Lionel Roubeyrie - lroubeyrie@limair.asso.fr
LIMAIR
http://www.limair.asso.fr