-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreports.py
26 lines (23 loc) · 1.17 KB
/
reports.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
from reportlab.platypus import SimpleDocTemplate
from reportlab.platypus import Paragraph, Spacer, Table, Image
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colors
def generate(filename, title, additional_info, table_data):
styles = getSampleStyleSheet()
report = SimpleDocTemplate(filename)
report_title = Paragraph(title, styles["h1"])
report_info = Paragraph(additional_info, styles["BodyText"])
table_style = [('GRID', (0,0), (-1,-1), 1, color.black),
('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
('ALIGN', (0,0), (-1,-1), 'CENTER')]
report_table = Table(data=table_data, style=table_style, hAlign='LEFT')
empty_line = Spacer(1,20)
report.build([report_title, empty_line, report_info, empty_line, report_table])
def generate_report(filename, title, additional_info):
styles = getSampleStyleSheet()
report = SimpleDocTemplate(filename)
report_title = Paragraph(title, styles["h1"])
report_info = Paragraph(additional_info, styles["BodyText"])
empty_line = Spacer(1,20)
report.build([report_title, empty_line, report_info, empty_line])