Table of Contents |
---|
Create folder
Folder name will be used as report script name
...
This file consists of the following parts:
name - name of the script, should be the same as folder name
description - default description for report
rootClass - name of the class of objects used as subtree roots
classes - list of the classes used in report script
relations - definitions of relations between classes
'classes' part structure
name - name of the class
fields - array of fields used in report
Code Block | ||
---|---|---|
| ||
"classes":[ { "name":"report_class_name_1", "fields":[ "field1name", "Custom 1" ] }, { "name":"report_class_name_2", "fields":[] } ] |
...
Prepare python script (report_script.py)
in this file create class ReportGenerator(ReportGeneratorInterface) - please remember to add following import:
Code Block |
---|
from reporting_service.ReportGeneratorInterface import ReportGeneratorInterface |
ReportGeneratorInterface has following abstract methods which should be implemented (details for these methods below):
Code Block |
---|
def prepare_data_frames(self, data_frames) - main method with all data preparations def get_pdf_template(self) - creates template object for pdf generation def get_pdf_css_file(self) - get path of css file for pdf generation def get_template_vars(self, data_frames) - prepare template variables based on data frames returned by prepare_data_frames method def get_excel_template(self) - get path of file with excel template def get_float_format(self) - get float format in python style, e.g. '%.3f' def get_excel_data_row_styles(self) - get row styles for excel report (not required) def get_excel_columns_width(self) - get columns width for excel report (not required) |
...
In this method one can set styles for each data set.
Style sections:
columns - set style for selected columns (by name)
rows - set style of each row
evenRow - set style of each even row
lastRow - set style of selected columns in the last row in data set
Available style properties:
bgColor - cell background color
bold - if True, font in cell will be bold
italic - if True, font in cell will be italic
Example:
Code Block |
---|
def get_excel_data_row_styles(self): return { 'floors': { 'columns': { }, 'rows': { 'bgColor': 'EBEFF2' }, 'evenRow': { 'bgColor': 'D4DCE6' }, 'lastRow': { 'B': { 'bgColor': 'FFFF00', 'bold': True }, 'C': { 'bgColor': 'FFFF00', 'bold': True } } }, 'floors_tenants': { 'columns': { 'A': {} }, 'rows': { 'bgColor': 'EBEFF2' }, 'evenRow': { 'bgColor': 'D4DCE6' }, 'lastRow': { 'E': { 'bgColor': 'FFFF00', 'italic': True } } }, 'rooms': { 'columns': { 'A': {} }, 'rows': { 'bgColor': 'EBEFF2' }, 'evenRow': { 'bgColor': 'D4DCE6' }, 'lastRow': { 'E': { 'bgColor': 'FFFF00', 'italic': True } } } } |
...
Macro is specified by double curly braces. ( {{ macro_name }} )
...
Create PDF template
HTML template
...