Answer the question
In order to leave comments, you need to log in
Why is jasper reports not generated?
Hello, there is a report made in jasper studio.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.3.final using JasperReports Library version 6.4.3 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="appointmentResult" pageWidth="595" pageHeight="420" orientation="Landscape" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="413a8c36-a1ab-4c45-9077-60957e0657f9">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<parameter name="MedicalFacility" class="java.lang.String"/>
<parameter name="FIOpatience" class="java.lang.String"/>
<parameter name="Conclusion" class="java.lang.String"/>
<parameter name="DoctorFIO" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="16" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="555" height="16" backcolor="#006699" uuid="502c5e88-ea60-4799-983f-2f5d2ba8b0f9"/>
<text><![CDATA[]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="52" splitType="Stretch">
<staticText>
<reportElement key="" mode="Opaque" x="0" y="0" width="555" height="52" forecolor="#FFFFFF" backcolor="#006699" uuid="c6e02ade-f6a2-4837-8e1c-bee4d677691e"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="20" isBold="true"/>
</textElement>
<text><![CDATA[Результат обследования]]></text>
</staticText>
<textField isStretchWithOverflow="true" evaluationTime="Report" isBlankWhenNull="true">
<reportElement x="10" y="0" width="150" height="30" forecolor="#FFFFFF" backcolor="#006699" uuid="b74b9bac-c683-43f3-b45e-14afbba1ea01"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$P{MedicalFacility}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<staticText>
<reportElement x="10" y="0" width="50" height="30" uuid="f05b59b5-41f8-4df4-abcd-b5ad949d3842"/>
<textElement>
<font size="12"/>
</textElement>
<text><![CDATA[Ф.И.О.]]></text>
</staticText>
<staticText>
<reportElement positionType="FixRelativeToBottom" x="10" y="31" width="120" height="30" uuid="6ef9347c-94a4-4d49-8083-6fc4a194819e"/>
<textElement>
<font size="12"/>
</textElement>
<text><![CDATA[Заключение врача]]></text>
</staticText>
<textField isStretchWithOverflow="true" evaluationTime="Report" isBlankWhenNull="true">
<reportElement x="60" y="0" width="494" height="30" isPrintWhenDetailOverflows="true" uuid="d18ad839-d17e-4257-838f-6a0ccdc8dbcc"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$P{FIOpatience}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" evaluationTime="Report" isBlankWhenNull="true">
<reportElement x="130" y="30" width="424" height="30" uuid="25cc440f-f3eb-47f8-849b-486250a5d969"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$P{Conclusion}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="52" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="552" height="49" backcolor="#E6E6E6" uuid="1b987a1a-4f33-41ad-8a03-1dfd0da18bfe"/>
<text><![CDATA[]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="443" y="0" width="30" height="30" uuid="6a5a0ed8-e68a-451a-8f6d-1fa174333142"/>
<textElement textAlignment="Right" verticalAlignment="Top"/>
<text><![CDATA[Врач: ]]></text>
</staticText>
<staticText>
<reportElement positionType="FixRelativeToBottom" x="390" y="30" width="155" height="20" uuid="4238141a-42c3-4e42-9c87-47b24a96459a"/>
<textElement textAlignment="Right"/>
<text><![CDATA[_______________________]]></text>
</staticText>
<textField pattern="dd MMMMM yyyy">
<reportElement x="10" y="30" width="250" height="21" uuid="dfcedf2c-848c-413e-9d78-ed0d0c5aa45d"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField evaluationTime="Report" isBlankWhenNull="true">
<reportElement x="473" y="0" width="72" height="30" uuid="490efffd-36f2-4409-b9ee-48b47cea0e3c"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$P{DoctorFIO}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
public class ReportGenerator
{
private String REPORT_pdf = "src/main/resources/report.pdf";
private String REPORT_pattern = "src/main/resources/jrxml/medicalFacility.jrxml";
private Map<String, Object> parameters =new HashMap<>();
private JasperDesign jasperDesign;
private JasperReport jasperReport;
private JasperPrint jasperPrint ;
public void create() throws JRException
{
jasperReport = JasperCompileManager.compileReport(REPORT_pattern);
Session sesssion = Main.getOurSessionFactory().openSession();
Transaction transaction = sesssion.beginTransaction();
sesssion.doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
try {
jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,connection);
JasperExportManager.exportReportToPdfFile(jasperPrint,REPORT_pdf);
} catch (JRException e) {
e.printStackTrace();
}
}
});
transaction.commit();
}
public void setREPORT_pattern(String pattern){
REPORT_pattern = pattern;
}
public void addParam(String key, String value){
parameters.put(key, value);
}
public void clearParames() {
parameters.clear();
}
}
ReportGenerator rg = new ReportGenerator();
rg.setREPORT_pattern("src/main/resources/jrxml/appointmentResult.jrxml");
rg.clearParames();
rg.addParam("MedicalFacility", officeEntity.getDepartment().getHousing().getMedicalFacility().getName());
rg.addParam("FIOpatience",patienceEntity.getFio());
rg.addParam("Conclusion",textField.getText());
rg.addParam("DoctorFIO",staffEntity.getFio());
rg.create();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question