def _table(self, node):
length = 0
colwidths = None
rowheights = None
data = []
for tr in _child_get(node,'tr'):
data2 = []
for td in _child_get(tr, 'td'):
flow = []
for n in td.childNodes:
if n.nodeType==node.ELEMENT_NODE:
flow.append( self._flowable(n) )
if not len(flow):
flow = self._textual(td)
data2.append( flow )
if len(data2)>length:
length=len(data2)
for ab in data:
while len(ab)<length:
ab.append('')
while len(data2)<length:
data2.append('')
data.append( data2 )
if node.hasAttribute('colWidths'):
assert length == len(node.getAttribute('colWidths').split(','))
colwidths = [utils.unit_get(f.strip()) for f in node.getAttribute('colWidths').split(',')]
if node.hasAttribute('rowHeights'):
rowheights = [utils.unit_get(f.strip()) for f in node.getAttribute('rowHeights').split(',')]
table = platypus.Table(data = data, colWidths=colwidths, rowHeights=rowheights, **(utils.attr_get(node, ['splitByRow'] ,{'repeatRows':'int','repeatCols':'int'})))
if node.hasAttribute('style'):
table.setStyle(self.styles.table_styles[node.getAttribute('style')])
return table
评论列表
文章目录