Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Reportlab Dynamic Table Q
Hi, I am struggling with using a parsed JSON list as the data for a dynamic table in reportlab.

Can anyone help me out here -- below is a generic reportlab script for a table. What I need help with is using the same principle but with a list, which will always be changing, instead of the static data that is used in the example below.. Thanks for any help!

from reportlab.lib import colors
from reportlab.lib.pagesizes import A4, inch, landscape
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
doc = SimpleDocTemplate("test_report_lab.pdf", pagesize=A4, rightMargin=30,leftMargin=30, topMargin=30,bottomMargin=18)
doc.pagesize = landscape(A4)
elements = []
data = [
["Letter", "Number", "Stuff", "Long stuff that should be wrapped"],
#TODO: Get this line right instead of just copying it from the docs
style = TableStyle([('ALIGN',(1,1),(-2,-2),'RIGHT'),
                       ('INNERGRID', (0,0), (-1,-1), 0.25,,
                       ('BOX', (0,0), (-1,-1), 0.25,,
#Configure style and word wrap
s = getSampleStyleSheet()
s = s["BodyText"]
s.wordWrap = 'CJK'
data2 = [[Paragraph(cell, s) for cell in row] for row in data]
#Send the data and build the file
I think I need to do a list of lists... but am relatively new to python so looking for a little bump in the right direction

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Help! - How to create a Title for a Reportlab Table crabbylou 0 57 Mar-29-2020, 09:14 PM
Last Post: crabbylou
  ReportLab Polypop77 0 66 Mar-20-2020, 01:17 PM
Last Post: Polypop77
  MYSQL how to assign a table for each user in my username table database? YoshikageKira 1 338 Dec-26-2019, 05:57 AM
Last Post: buran
  cyrillic symbols in tables in reportlab. hiroz 4 1,334 Mar-20-2019, 07:42 PM
Last Post: nilamo
  Python Reportlab Wordwrap Table Mady 0 1,675 Dec-18-2018, 06:31 AM
Last Post: Mady
  Reportlab: Add xlabel, ylabel and grid to lineplot denissanga 2 2,287 Dec-19-2017, 04:48 PM
Last Post: denissanga
  ReportLab ek5442 2 1,692 Aug-24-2017, 01:29 PM
Last Post: ek5442
  Method for pulling in dynamic table data brocq_18 1 1,279 Apr-03-2017, 04:07 PM
Last Post: snippsat
  Python ReportLab ek5442 6 3,623 Mar-15-2017, 07:47 PM
Last Post: ek5442

Forum Jump:

Users browsing this thread: 1 Guest(s)