问题
I am trying the jasper report plugin with NetBeans. I created my connection (test is okay) I created the jrxml and I try to preview it.
It is compiled automatically (the .jasper appears) and I have a message saying : "the document has no page".
I read the problem could be the datasource that is empty but it is not the case.. so I decided to make a very simple jrxml (static : only text with no reference to any field of the database)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD JasperReport//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="report name" pageWidth="595" pageHeight="1500" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<background>
<band/>
</background>
<title>
<band height="79"/>
</title>
<pageHeader>
<band height="35"/>
</pageHeader>
<columnHeader>
<band height="61"/>
</columnHeader>
<detail>
<band height="696">
<textField isBlankWhenNull="false">
<reportElement key="textField-23" x="0" y="274" width="449" height="134"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Justified">
<font size="11" pdfFontName="Tiffy.ttf" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA["Vous avez reçu il y a quelques mois une attestation de la Caisse Primaire d'Assurance Maladie destinée à réduire le coût de votre adhésion à une complémentaire santé.\n\n"+
"Si vous rencontrez des difficultés dans vos démarches d'accès aux droits et aux soins, le Service social de l'Assurance Maladie est à votre disposition pour vous informer, vous conseiller et vous accompagner.\n\n" +
"Aussi, je propose de vous rencontrer à votre domicile le : "]]>
</textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45"/>
</columnFooter>
<pageFooter>
<band height="54"/>
</pageFooter>
<summary>
<band height="42"/>
</summary>
</jasperReport>
same think it compiles but I have the message
So I added those two lines :
<noData>no Data</noData>
<queryString>select * from dual</queryString>
Nothing is displayed obviously but the same message.. so connection seems alright no ?
回答1:
Even if you only have static texts in the body of your report, if your sql for the report is empty, jasper displays nothing by default. Try adding "select 1 as dummy" as your query and see if that solves it.
回答2:
Try an empty query and see the result. From this CodeRanch forum post I extracted the following:
When your query yields no results, there're 3 options that are provided by JR that you could make use of: (a) generate empty report (PDF), i.e., no pages (b) generate a single blank page report (c) generate a report showing all sections, except the detail section
This can be done by setting the value of the attribute [B}whenNoDataType[/B] for element jasperReport. The 3 accepted values are: (a) NoPages (b) BlankPage (c) AllSectionsNoDetail
That worked for me.
回答3:
To verify if the datasource is not the problem, you can put a static text in the No Data
section of the report. Then in the report's properties
When No Data : No Data Section
If the static text is displayed in the report, then data source is your problem.
回答4:
This error is caused because the report has been compiled to compile it to click in Compile Report.
来源:https://stackoverflow.com/questions/13824125/jasper-the-document-has-no-page