pyreportjasper
pyreportjasper copied to clipboard
sent parameters list int to report
Hello, I am trying to send a list int type parameter to my Jasper report with a postgresql connection but it gives me an error Is there any way to do it?
parameters= { 'fechaIni': '24-02-2024', 'fechaFin': '24-02-2024', 'UserCreate': 'User1', 'companyId':1, 'cobradores_id': [148,150], 'partner_id':2, 'python_version' : python_version()
}
pyreportjasper = PyReportJasper()
in postgresql where $X{IN, partner.cobrador_id , cobradores_id} in jasperreport <parameter name="cobradores_id" class="java.util.List" nestedType="java.lang.Integer"/>
error: Error fill report: No matching overloads found for java.util.HashMap.put(str,list), options are:\n\tpublic java.lang.Object java.util.HashMap.put(java.lang.Object,java.lang.Object)\n'
We have released version 2.1.4, which implements data typing for parameters sent to the reports. Please try using the new version and let us know about your experience.
Here's the link to the example: link
To find out the supported types up to this moment, access: Link
How to use:
import os
from pyreportjasper import PyReportJasper
def report_with_params():
try:
RESOURCES_DIR = os.path.abspath(os.path.dirname(__file__))
REPORTS_DIR = os.path.abspath(os.path.dirname(__file__))
input_file = os.path.join(REPORTS_DIR, "myteste2", "params.jrxml")
output_file = os.path.join(REPORTS_DIR, "myteste2", "output_file")
pyreportjasper = PyReportJasper()
pyreportjasper.config(
input_file,
output_file,
output_formats=["pdf"],
parameters={
'myString': {
'value': 'TESTE STRING VALUE',
'type': pyreportjasper.TypeJava.String
},
'myInt': {
'value': 1,
'type': pyreportjasper.TypeJava.Integer
},
'myDate': {
'value': '24-02-2024',
'type': pyreportjasper.TypeJava.Date,
'format_input': 'dd-MM-yyyy'
},
}
)
pyreportjasper.process_report()
print("Result is the file below.")
print(output_file + ".pdf")
except Exception as e:
print(f"Error occurred: {e}")
report_with_params()