Python Forum
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

Possibly Related Threads…
Thread Author Replies Views Last Post
  cyrillic symbols in tables in reportlab. hiroz 5 2,699 Sep-10-2020, 04:57 AM
Last Post: bradmalcom
  Fetch Oracle DB rows & print it in HTML file with table's col headers in table format tssr_2001 1 497 Sep-04-2020, 01:39 PM
Last Post: ibreeden
  Using Reportlab to create a landscape pdf SmukasPlays 2 504 Aug-09-2020, 09:31 PM
Last Post: SmukasPlays
  Mysql CREATE TABLE IF NOT EXISTS dynamic table name nisusavi 0 402 Apr-29-2020, 06:45 PM
Last Post: nisusavi
  Help! - How to create a Title for a Reportlab Table crabbylou 0 1,020 Mar-29-2020, 09:14 PM
Last Post: crabbylou
  ReportLab Polypop77 0 345 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 855 Dec-26-2019, 05:57 AM
Last Post: buran
  Python Reportlab Wordwrap Table Mady 0 2,571 Dec-18-2018, 06:31 AM
Last Post: Mady
  Reportlab: Add xlabel, ylabel and grid to lineplot denissanga 2 3,143 Dec-19-2017, 04:48 PM
Last Post: denissanga
  ReportLab ek5442 2 2,224 Aug-24-2017, 01:29 PM
Last Post: ek5442

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020