Skip to content

Issues with Sub report. #184

@Shurmaster

Description

@Shurmaster

This happens whenever I try to process a report that requires a subreport.

Error fill report: Erro fill internal: net.sf.jasperreports.engine.JRException: Resource not found at: null*.jasper.
Where * is the name of the report file.

Obviously this reports needs a subreport, but I can't figure out how to insert it. I've tried reading other solutions users have submitted and the Python Doc but still couldn't figure out how to insert my .Jasper subreports.
Any help would be appreciated! This is what I currently got. Thanks for your attention!

def advanced_example_using_database():
    try:        
        varname='*'
        REPORTS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'reports')
        OUTPUT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'final_report')
        input_file = os.path.join(REPORTS_DIR, f'{varname}.jasper')
        output_file = os.path.join(OUTPUT_DIR, 'hello_world')
        conn = {
		... #Assume this is correct. I can create reports that require no subreports.
        }
        pyreportjasper = PyReportJasper()
        pyreportjasper.config(
            input_file,
            output_file,
            db_connection=conn,
            output_formats=["pdf", "rtf"],
            parameters={'python_version': python_version()},
            locale='en_US',
        )
        pyreportjasper.process_report()
        output_file = output_file + '.pdf'
        return FileResponse(open(output_file, 'rb'), as_attachment=True)
    except Exception as E:
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        logger.error(f'{exc_type}, {fname}, {exc_tb.tb_lineno}, {exc_obj}')

        raise E

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions