Help with wordwrap in Table
Lea Kaminski <[email protected]>
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <AM0PR09MB24845F6280FB313B92F0FF38DEBD0@AM0PR09MB2484.eurprd09.prod.outlook.com> |
Hi,
i hope subcribing to the list worked. PLease let me know if not.
I need some help with setting a wordwrap in a generated list. The list always is with different content. I need to have a wordwrap for every single cell/item of the list. Also i would like to set the total width of the table to alway be the same. I would be really gald for help. I hope its right that i post my code now.
from reportlab.lib.pagesizes import A4
from reportlab.lib.pagesizes import letter, cm
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import LongTable, TableStyle, BaseDocTemplate, Frame, PageTemplatefrom reportlab.lib import colors
from reportlab.platypus import Paragraph, Table, TableStyle########################################################################def test():
doc = BaseDocTemplate(
"question.pdf",
pagesize=A4,
rightMargin=72,
leftMargin=72,
topMargin=50,
bottomMargin=80,
showBoundary=False)
elements = []
data = [['A', 'B', 'C', 'dddddddddddd', 'D'],
['00', '0dddddddddddddddddddddddddddddddddddd1', '02', 'fff', '04'],
['10', '11', '12', 'dfg', '14'],
['20', '21', '22', 'ddddddddddddddddddddddddddddddddddddddddddddddddddddddd23', '24'],
]
t = LongTable(data)
tableStyle = [
('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
('BOX', (0, 0), (-1, -1), 0.25, colors.black),]
t.setStyle(TableStyle(tableStyle))
elements.append(t)
styles = getSampleStyleSheet()
styleN = styles['Normal']
frame = Frame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height - 2 * cm, id='normal')
template = PageTemplate(id='longtable', frames=frame)
doc.addPageTemplates([template])
doc.build(elements)if __name__ == '__main__':
test()`
Thank you a million times for any kind of help.
Best regarts,
Amy