Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Help! - How to create a Title for a Reportlab Table
#1
Hi, I am trying to create a title for my reportlab table.

from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Frame, Spacer
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.lib.pagesizes import A3, A4, landscape, portrait
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
from reportlab.pdfgen import canvas

try:
    #
    #   Define report name
    #
    strPDFParameterReportFile = "test.pdf"
    doc = SimpleDocTemplate(strPDFParameterReportFile, pagesize=A4)
    #
    #   Container for flowable objects
    #
    elements = []
    styles=getSampleStyleSheet()
    styleN = styles["Normal"]
    #
    #   Column headings
    #
    column1Heading = "First Name"
    column2Heading = "Last Name"
    #
    # Assemble data
    #
    data = [[column1Heading,column2Heading]]
    #
    data.append(["Moe", "Howard"])
    data.append(["Larry", "Fine"])
    data.append(["Curly", "Howard"])
    data.append(["Shemp", "Howard"])
    #
    #   Define styles
    #
    tableThatSplitsOverPages = Table(data, [6 * cm, 6 * cm], repeatRows=1)
    tableThatSplitsOverPages.hAlign = 'LEFT'
    tblStyle = TableStyle([('TEXTCOLOR',(0,0),(-1,-1),colors.black),
                           ('VALIGN',(0,0),(-1,-1),'TOP'),
                           ('LINEBELOW',(0,0),(-1,-1),1,colors.black),
                           ('BOX',(0,0),(-1,-1),1,colors.black),
                           ('BOX',(0,0),(0,-1),1,colors.black)])
    tblStyle.add('BACKGROUND',(0,0),(1,0),colors.lightblue)
    tblStyle.add('BACKGROUND',(0,1),(-1,-1),colors.white)
    tableThatSplitsOverPages.setStyle(tblStyle)
    elements.append(tableThatSplitsOverPages)
    doc.build(elements)
except:
    blnAnErrorHasOccurred = True
Any help is appreciated.

Lou
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Mysql CREATE TABLE IF NOT EXISTS dynamic table name nisusavi 0 122 Apr-29-2020, 06:45 PM
Last Post: nisusavi
  ReportLab Polypop77 0 115 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 435 Dec-26-2019, 05:57 AM
Last Post: buran
  Create table with psycopg2 on postgreSQL DB yhecohen 2 509 Aug-23-2019, 05:56 AM
Last Post: massimo_m
  cyrillic symbols in tables in reportlab. hiroz 4 1,627 Mar-20-2019, 07:42 PM
Last Post: nilamo
  Python Reportlab Wordwrap Table Mady 0 1,870 Dec-18-2018, 06:31 AM
Last Post: Mady
  Reportlab Dynamic Table Q Gutt 0 2,226 Jun-13-2018, 10:18 PM
Last Post: Gutt
  How to change font size of chart title and axis title ? thrupass 5 6,389 Mar-30-2018, 04:02 PM
Last Post: DrFunn1
  Reportlab: Add xlabel, ylabel and grid to lineplot denissanga 2 2,472 Dec-19-2017, 04:48 PM
Last Post: denissanga
  ReportLab ek5442 2 1,785 Aug-24-2017, 01:29 PM
Last Post: ek5442

Forum Jump:


Users browsing this thread: 1 Guest(s)