当前位置: 首页>>代码示例>>Python>>正文


Python platypus.TableStyle类代码示例

本文整理汇总了Python中reportlab.platypus.TableStyle的典型用法代码示例。如果您正苦于以下问题:Python TableStyle类的具体用法?Python TableStyle怎么用?Python TableStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TableStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: table

def table(data):
	"""
	return list, so "extend" method should be used.
	"""
	"""
	para_style = STYLES["BodyText"]
	para_style.wordWrap = 'CJK'
	para_style.backColor = colors.red
	table_data = [[Paragraph(cell, para_style) for cell in row] for row in data]
	"""
	table_data = data
	table_style = TableStyle([
		('ALIGN',(0,0),(-1,0),'CENTER'),
		('ALIGN',(0,1),(0,-1),'LEFT'),
		('ALIGN',(1,1),(-1,-1),'RIGHT'),
		('VALIGN',(0,0),(-1,-1),'MIDDLE'),
		('BOX', (0,0), (-1,0), 2, colors.black),
		('LINEBELOW', (0,-1), (-1,-1), 2, colors.black),
		('TEXTCOLOR',(1,1),(-2,-2),colors.red),
		('BACKGROUND', (0,0), (-1,0), colors.black),
		('TEXTCOLOR',(0,0),(-1,0),colors.white),
		('TEXTCOLOR',(0,1),(-1,-1),colors.black),
		#('VALIGN',(0,0),(0,-1),'TOP'),
		#('TEXTCOLOR',(0,0),(0,-1),colors.blue),
		])
	for i in range(1, len(table_data)):
		if i%2 == 0:
			table_style.add('BACKGROUND', (0,i), (-1,i), 
					colors.Color(.835,.91,.976))

	t = Table(table_data)
	t.setStyle(table_style)
	return [t]
开发者ID:graphy21,项目名称:pathogen,代码行数:33,代码来源:reportlabExam.py

示例2: buildTable

def buildTable(data):
  doc = SimpleDocTemplate("MOOSE_requirements_tracability.pdf", pagesize=A4, rightMargin=30,leftMargin=30, topMargin=30,bottomMargin=18)
  doc.pagesize = landscape(A4)
  elements = []

  #Configure style and word wrap
  s = getSampleStyleSheet()
  s = s["BodyText"]
  s.wordWrap = 'CJK'

  pdf_data = [["Requirement", "Description", "Test Case(s)"]]

  #TODO: Need a numerical sort here
  keys = sorted(data.keys())

  for key in keys:
    data[key][2] = '\n'.join(data[key][2])
    pdf_data.append([Paragraph(cell, s) for cell in data[key]])


  # Build the Table and Style Information
  tableThatSplitsOverPages = Table(pdf_data, 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),
                         ('INNERGRID', (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,-1),colors.lightblue)
  tblStyle.add('BACKGROUND',(0,1),(-1,-1),colors.white)
  tableThatSplitsOverPages.setStyle(tblStyle)
  elements.append(tableThatSplitsOverPages)

  doc.build(elements)
开发者ID:bggaston,项目名称:moose,代码行数:35,代码来源:tracability_matrix.py

示例3: make_table

def make_table(printable):
	style = TableStyle()
	style.add('VALIGN', (0,0), (-1,-1), 'TOP')
	style.add('GRID', (0,0), (-1,-1), 1, colors.black)
	table = Table(printable, [col_width*0.4,col_width*0.6])
	table.setStyle(style)
	return table
开发者ID:jsharkey,项目名称:chaptools,代码行数:7,代码来源:completeunique.py

示例4: gather_elements

    def gather_elements(self, client, node, style):
        if node.children and isinstance(node.children[0], docutils.nodes.title):
            title=[]
        else:
            title= [Paragraph(client.text_for_label(node.tagname, style),
                style=client.styles['%s-heading'%node.tagname])]
        rows=title + client.gather_elements(node, style=style)
        st=client.styles[node.tagname]
        if 'commands' in dir(st):
            t_style = TableStyle(st.commands)
        else:
            t_style = TableStyle()
        t_style.add("ROWBACKGROUNDS", [0, 0], [-1, -1],[st.backColor])
        t_style.add("BOX", [ 0, 0 ], [ -1, -1 ], st.borderWidth , st.borderColor)

        if client.splittables:
            node.elements = [MySpacer(0,st.spaceBefore),
                                SplitTable([['',rows]],
                                style=t_style,
                                colWidths=[0,None],
                                padding=st.borderPadding),
                                MySpacer(0,st.spaceAfter)]
        else:
            padding, p1, p2, p3, p4=tablepadding(padding=st.borderPadding)
            t_style.add(*p1)
            t_style.add(*p2)
            t_style.add(*p3)
            t_style.add(*p4)
            node.elements = [MySpacer(0,st.spaceBefore),
                                DelayedTable([['',rows]],
                                style=t_style,
                                colWidths=[0,None]),
                                MySpacer(0,st.spaceAfter)]
        return node.elements
开发者ID:Mrt134,项目名称:Experimental,代码行数:34,代码来源:genelements.py

示例5: second_paragraph

 def second_paragraph(self):    
     self.story.append(myParagraph(u"Nom du bénéficiaire : <b>" + self.facture_view.nom_prenom() + u"</b>", 'style1', spaceAfter=10))
     self.story.append(myParagraph(u"Montant de la prestation", 'style1'))
     self.story.append(myParagraph(u"<b>(" + self.facture_view.jours_prestation_string() + u")</b> Jours....................................<b>%.2f " % (self.facture_view.montant_presta()) + u"</b>€uros", 'style1', spaceAfter=25))
     self.story.append(myParagraph(u"Arrêtée et certifiée conforme la présente facture à la somme de :", 'style1', spaceAfter=25))
     
     table_style = TableStyle([('BOX', (0,0), (-1,-1), 0.25, black),
                               ('BOX', (0,0), (-1,-1), 0.25, black),])
     table_style.spaceAfter=25
     table_data = [[myParagraph(u"<b>" + self.facture_view.montant_presta_word().upper() + u"</b>", 'style1', alignment=TA_CENTER),],]               
     self.story.append(Table(data=table_data, style=table_style))
开发者ID:cazino,项目名称:Formation,代码行数:11,代码来源:facture.py

示例6: print_entries

 def print_entries(self, eh, ehds):
     buffer = self.buffer
     styles = getSampleStyleSheet()
     data = []
     ts = TableStyle()
     d = []
     hs = styles['Heading1']
     hs.alignment = TA_CENTER
     d.append(Paragraph('<b>Producto</b>', hs))
     d.append(Paragraph('<b>Descripci&oacute;n</b>', hs))
     d.append(Paragraph('<b>Cantidad</b>', hs))
     if eh.printed:
         if(eh.action == 'altas'):
             title = Paragraph('<b> Entrada de Mercanc&iacute;a - REIMPRESI&Oacute;N</b>', hs)
         else:
             title = Paragraph('<b> Salida de Mercanc&iacute;a - REIMPRESI&Oacute;N</b>', hs)
     else:   
         if(eh.action == 'altas'):
             title = Paragraph('<b> Entrada de Mercanc&iacute;a </b>', hs)
         else:
             title = Paragraph('<b> Salida de Mercanc&iacute;a </b>', hs)
     data.append(d)
     total_qty = 0
     sp = styles['BodyText']
     sp.alignment = TA_CENTER
     sq = styles['BodyText']
     sq.alignment = TA_RIGHT
     spb = styles['Heading3']
     spb.alignment = TA_RIGHT
     sl = styles['Normal']
     sl.alignment = TA_CENTER
     for ehd in ehds:
         d = []
         d.append(ehd.product.name)
         p = Paragraph(ehd.product.description.encode('utf-8'), sp)
         d.append(p)
         pq = Paragraph(str(ehd.quantity), sq)
         d.append(pq)
         data.append(d)
         total_qty += ehd.quantity
     t = Table(data, colWidths = [(letter[0] * .20), (letter[0] * .50), (letter[0] * .20)])
     ts.add('LINEBELOW', (0,1), (-1,-1), 0.25, colors.black)
     t.setStyle(ts)
     elements = []
     elements.append(title)
     elements.append(t)
     elements.append(Paragraph('<br /><p> <b>Cantidad total de art&iacute;culos:</b> ' + str(total_qty) + '</p>', spb))
     if(eh.action == 'altas'):
         elements.append(Paragraph('<br /><p> Al firmar este documento acepto que estoy recibiendo la mercanc&iacute;a listada y me responsabilizo por la mercanc&iacute;a. <br /><br /><br/> Nombre:_____________________ Firma: _____________________________</p>',sl))
     else:
         elements.append(Paragraph('<br /><p> Al firmar este documento acepto la salida de esta mercanc&iacute;a. <br /><br /><br/> Nombre:_____________________ Firma: _____________________________</p>',sl))
     doc = SimpleDocTemplate(buffer, pagesize=letter)
     doc.build(elements, onFirstPage=self._header_footer, onLaterPages=self._header_footer, canvasmaker = NumberedCanvas)
     return buffer
开发者ID:xirdneh,项目名称:oposum,代码行数:54,代码来源:reporter.py

示例7: generate_monthly_summary_table

def generate_monthly_summary_table(huc12):
    """Make a table of monthly summary stats."""
    data = []
    data.append(['Year', 'Month', 'Precip', "Runoff", "Loss", "Delivery",
                '2+" Precip', 'Events'])
    data.append(['', '', '[inch]', "[inch]", "[tons/acre]", "[tons/acre]",
                 "[days]", "[days]"])
    pgconn = get_dbconn('idep')
    huc12col = "huc_12"
    if len(huc12) == 8:
        huc12col = "substr(huc_12, 1, 8)"
    df = read_sql("""
    WITH data as (
        SELECT extract(year from valid)::int as year,
        extract(month from valid)::int as month, huc_12,
        (sum(qc_precip) / 25.4)::numeric as sum_qc_precip,
        (sum(avg_runoff) / 25.4)::numeric as sum_avg_runoff,
        (sum(avg_loss) * 4.463)::numeric as sum_avg_loss,
        (sum(avg_delivery) * 4.463)::numeric as sum_avg_delivery,
        sum(case when qc_precip >= 50.8 then 1 else 0 end) as pdays,
        sum(case when avg_loss > 0 then 1 else 0 end) as events
        from results_by_huc12 WHERE scenario = 0 and
        """ + huc12col + """ = %s
        and valid >= '2016-01-01'
        GROUP by year, month, huc_12)
    SELECT year, month,
    round(avg(sum_qc_precip), 2),
    round(avg(sum_avg_runoff), 2),
    round(avg(sum_avg_loss), 2),
    round(avg(sum_avg_delivery), 2),
    round(avg(pdays)::numeric, 1),
    round(avg(events)::numeric, 1)
    from data GROUP by year, month ORDER by year, month
    """, pgconn, params=(huc12, ), index_col=None)
    for _, row in df.iterrows():
        vals = [int(row['year']), calendar.month_abbr[int(row['month'])]]
        vals.extend(["%.2f" % (f, ) for f in list(row)[2:-2]])
        vals.extend(["%.0f" % (f, ) for f in list(row)[-2:]])
        data.append(vals)
    data[-1][1] = "%s*" % (data[-1][1], )
    totals = df.iloc[:-1].mean()
    vals = ['', 'Average']
    vals.extend(["%.2f" % (f, ) for f in list(totals[2:])])
    data.append(vals)

    style = TableStyle(
        [('LINEBELOW', (2, 1), (-1, 1), 0.5, '#000000'),
         ('LINEAFTER', (1, 2), (1, -2), 0.5, '#000000'),
         ('LINEABOVE', (2, -1), (-1, -1), 0.5, '#000000'),
         ('ALIGN', (0, 0), (-1, -1), 'RIGHT')]
    )
    for rownum in range(3, len(data)+1, 2):
        style.add('LINEBELOW', (0, rownum), (-1, rownum), 0.25, '#EEEEEE')
    return Table(data, style=style, repeatRows=2)
开发者ID:akrherz,项目名称:idep,代码行数:54,代码来源:huc12report.py

示例8: frein_type_result

 def frein_type_result(self, frein_type, resultat_list):
     en_tete = ((StatParagraph("<b><i>" + frein_type + "</i></b>", 'style3'),
                 StatParagraph("<b><i>" + u"Frein le plus important" + "</i></b>", 'style3'),
                 StatParagraph("<b><i>" + u"Frein présent" + "</i></b>", 'style3')),)
     data = tuple([(StatParagraph(categorie, 'style3'),
                    StatParagraph(str(nb_plus_imp), 'style3'),
                    StatParagraph(str(nb_all), 'style3'))
                    for (categorie, nb_plus_imp, nb_all) in resultat_list])
     table_data = en_tete + data
     table_style = TableStyle([('GRID', (0,0), (-1,-1), 0.25, black),])
     table_style.spaceAfter=25
     table_style.spaceBefore=25
     self.story.append(Table(data=table_data, style=table_style))
开发者ID:cazino,项目名称:Formation,代码行数:13,代码来源:sortie.py

示例9: get_underline

    def get_underline():
        data = [[None], [None]]

        line = Table(
            data,
            colWidths=[6.2 * inch],
            rowHeights=[0.03 * inch, 0.14 * inch])

        table_style = TableStyle()
        table_style.add('LINEBELOW', (0, 0), (0, 0), 1, colors.black)
        line.setStyle(table_style)

        return line
开发者ID:bigbag,项目名称:archive_term-flask,代码行数:13,代码来源:payment_account.py

示例10: getTableStyle

def getTableStyle():
    ts = TableStyle([('TEXTCOLOR', (0, 0), (-1, -1), colors.black),
                     ('VALIGN', (0, 0), (-1, -1), 'TOP'),
                     ('LINEBELOW', (0, 0), (-1, -1), 0.8, colors.black),
                     ('BOX', (0, 0), (-1, -1), 0.75, colors.black),
                     ('BOX', (0, 0), (0, -1), 0.75, colors.black),
                     ('BOX', (1, 0), (1, -1), 0.75, colors.black),
                     ('ALIGN', (0, 0), (-1, -1), 'RIGHT'),
                     ('FONTNAME', (0, 0), (-1, -1), 'Arabic'),
                     ('FONTSIZE', (0, 0), (-1, -1), TABLE_FONT_SIZE),
                     ])
    ts.add('BACKGROUND', (0, 0), (-1, 1), colors.lightgrey)  # header lightgrey
    ts.add('BACKGROUND', (0, 1), (-1, -1), colors.white)  # rest of table
    return ts
开发者ID:chaabni,项目名称:SmartElect,代码行数:14,代码来源:pdf_canvas.py

示例11: _new_style

    def _new_style(self, header_line_idx=None, header_line_width=1, header_line_color="black", debug_grid=False):

        ts = TableStyle()
        if debug_grid:
            ts.add("GRID", (0, 0), (-1, -1), 1, colors.red)

        if isinstance(header_line_color, str):
            try:
                header_line_color = getattr(colors, header_line_color)
            except AttributeError:
                header_line_color = colors.black

        if header_line_idx is not None:
            ts.add("LINEBELOW", (0, header_line_idx), (-1, header_line_idx), header_line_width, header_line_color)

        return ts
开发者ID:jirhiker,项目名称:pychron,代码行数:16,代码来源:base_table_pdf_writer.py

示例12: getTableStyleThreeCol

def getTableStyleThreeCol():
    ts = TableStyle([('TEXTCOLOR', (0, 0), (-1, -1), colors.black),
                     ('VALIGN', (0, 0), (-1, -1), 'TOP'),
                     ('LINEBELOW', (0, 0), (-1, -1), 0.8, colors.black),
                     ('BOX', (0, 0), (-1, -1), 0.75, colors.black),
                     ('BOX', (0, 0), (0, -1), 0.75, colors.black),
                     ('BOX', (1, 0), (1, -1), 0.75, colors.black),
                     ('ALIGN', (0, 0), (0, -1), 'CENTER'),  # center number column
                     ('ALIGN', (1, 0), (1, -1), 'RIGHT'),   # right align name column
                     ('ALIGN', (2, 0), (2, -1), 'CENTER'),  # center number column
                     ('FONTNAME', (0, 0), (-1, -1), 'Arabic'),
                     ('FONTSIZE', (0, 0), (-1, -1), TABLE_FONT_SIZE),
                     ])
    ts.add('BACKGROUND', (0, 0), (-1, 1), colors.lightgrey)  # header lightgrey
    ts.add('BACKGROUND', (0, 1), (-1, -1), colors.white)  # rest of table
    return ts
开发者ID:chaabni,项目名称:SmartElect,代码行数:16,代码来源:pdf_canvas.py

示例13: tableau_intro

 def tableau_intro(self):
     style_tableau = TableStyle([('BOX', (0,0), (0,-1), 0.25, black),
                                 ('BOX', (1,0), (1,-1), 0.25, black),
                                 ('BOX', (2,0), (2,-1), 0.25, black),
                                 ('BOX', (0,0), (-1,0), 0.25, black),
                                 ('VALIGN',(0,0),(-1,-1),'TOP'),
                                 ])
     style_tableau.spaceAfter = 10
     tableau_data = [[MyParagraph(style='style3', text=u"<b>Bénéficiaire</b>"), MyParagraph(style='style3', text=u"<b>Référent</b>"), MyParagraph(style='style3', text=u"<b>Correspondant ALE</b>")],    
                     [MyParagraph(style='style3', text=u"<b>Nom Prénom : <font color=black>"+self.bilanView.nomprenom()+"</font></b>"), MyParagraph(style='style3', text=u"<b>Nom Prénom : <font color=black>"+self.bilanView.CInomprenom()+"</font></b>"), MyParagraph(style='style3', text=u"<b>Nom Prénom : <font color=black>"+self.bilanView.ALEnomprenom()+"</font></b>")],
                     [MyParagraph(style='style3', text=u"<b>Identifiant n° : <font color=black>"+self.bilanView.idALE()+"</font></b>"), MyParagraph(style='style3', text=u"<b>Organisme : <font color=black>"+self.bilanView.organismeReferent()+"</font></b>"), MyParagraph(style='style3', text=u"<b>ALE : <font color=black>"+self.bilanView.ALEnom()+"</font></b>")],
                     [MyParagraph(style='style3', text=u"<b>Inscrit à ALE de: <font color=black>"+self.bilanView.incritALE()+"</font></b>"), MyParagraph(style='style3', text=u"<b>Tél : <font color=black>"+self.bilanView.refTel()+"</font></b>"), MyParagraph(style='style3', text=u"<b>Tél : <font color=black>"+self.bilanView.ALEtel()+"</font></b>")],
                     [MyParagraph(style='style3', text=u"<b>Tél : <font color=black>"+self.bilanView.LCtel()+"</font></b>"), MyParagraph(style='style3', text=u"<b>Mel : <font color=black>"+self.bilanView.refMail()+"</font></b>"), MyParagraph(style='style3', text=u"<b>Mel : <font color=black>"+self.bilanView.ALEmail()+"</font></b>")],
                     [MyParagraph(style='style3', text=u"<b>Mel : <font color=black>"+self.bilanView.LCmail()+"</font></b>"), None, None],                        
                     ]
     tableau = Table(data=tableau_data, style=style_tableau)
     self.story.append(tableau)
开发者ID:cazino,项目名称:Formation,代码行数:17,代码来源:bilanPdf.py

示例14: print_inventory_surplus

 def print_inventory_surplus(self, entries, title):
     buffer = self.buffer
     styles = getSampleStyleSheet()
     data = []
     ts = TableStyle()
     d = []
     hs = styles['Heading1']
     hs.alignment = TA_CENTER
     d.append(Paragraph('<b>C&oacute;digo</b>', styles['Normal']))
     d.append(Paragraph('<b>Descripci&oacute;n</b>', styles['Normal']))
     d.append(Paragraph('<b>Existencia</b>', styles['Normal']))
     d.append(Paragraph('<b>Sistema</b>', styles['Normal']))
     d.append(Paragraph('<b>Sobrante</b>', styles['Normal']))
     title = Paragraph('<b> ' + title + '</b>', hs)
     data.append(d)
     total_qty = 0
     sp = styles['BodyText']
     sp.alignment = TA_CENTER
     sq = styles['BodyText']
     sq.alignment = TA_RIGHT
     spb = styles['Heading3']
     spb.alignment = TA_RIGHT
     sl = styles['Normal']
     sl.alignment = TA_CENTER
     for e in entries:
         if e['entry'].product is None:
             continue
         d = []
         d.append(e['entry'].product.name)
         p = Paragraph(e['entry'].product.description.encode('utf-8'), sp)
         d.append(p)
         pq = Paragraph(str(e['entry'].quantity), sq)
         d.append(pq)
         d.append(Paragraph(str(e['tcount']), sq))
         d.append(Paragraph(str(e['diff'] * -1), sq))
         data.append(d)
     t = Table(data, colWidths = [(letter[0] * .15), (letter[0] * .45), (letter[0] * .12), (letter[0] * .12), (letter[0] * .12)])
     ts.add('LINEBELOW', (0,1), (-1, -1), 0.25, colors.black)
     t.setStyle(ts)
     elements = []
     elements.append(title)
     elements.append(t)
     doc = SimpleDocTemplate(buffer, pagesize=letter)
     doc.build(elements, onFirstPage=self._header_footer_inventory, onLaterPages=self._header_footer_inventory, canvasmaker = NumberedCanvas)
     return buffer
开发者ID:xirdneh,项目名称:oposum,代码行数:45,代码来源:reporter.py

示例15: print_inventory_existence

 def print_inventory_existence(self, entries, title):
     buffer = self.buffer
     styles = getSampleStyleSheet()
     data = []
     ts = TableStyle()
     d = []
     hs = styles['Heading1']
     hsc = styles['Heading3']
     hs.alignment = TA_CENTER
     d.append(Paragraph('<b>C&oacute;digo</b>', styles['Normal']))
     d.append(Paragraph('<b>Descripci&oacute;n</b>', styles['Normal']))
     d.append(Paragraph('<b>Cantidad</b>', styles['Normal']))
     title = Paragraph('<b> ' + title + '</b>', styles['Normal'])
     data.append(d)
     total_qty = 0
     sp = styles['BodyText']
     sp.alignment = TA_CENTER
     sq = styles['BodyText']
     sq.alignment = TA_RIGHT
     spb = styles['Heading3']
     spb.alignment = TA_RIGHT
     sl = styles['Normal']
     sl.alignment = TA_CENTER
     for e in entries:
         if e.quantity == 0:
             continue
         d = []
         d.append(e.product.name)
         p = Paragraph(e.product.description.encode('utf-8'), sp)
         d.append(p)
         pq = Paragraph(str(e.quantity), sq)
         d.append(pq)
         data.append(d)
         total_qty += e.quantity
     t = Table(data, colWidths = [(letter[0] * .20), (letter[0] * .50), (letter[0] * .20)])
     ts.add('LINEBELOW', (0,1), (-1, -1), 0.25, colors.black)
     t.setStyle(ts)
     elements = []
     elements.append(title)
     elements.append(t)
     elements.append(Paragraph('<br /><p> <b>Cantidad total de art&iacute;culos:</b> ' + str(total_qty) + '</p>', spb))
     doc = SimpleDocTemplate(buffer, pagesize=letter)
     doc.build(elements, onFirstPage=self._header_footer_inventory, onLaterPages=self._header_footer_inventory, canvasmaker = NumberedCanvas)
     return buffer
开发者ID:xirdneh,项目名称:oposum,代码行数:44,代码来源:reporter.py


注:本文中的reportlab.platypus.TableStyle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。