簡體   English   中英

Jasper文檔沒有頁面

[英]Jasper the document has no page

我正在嘗試將NetBeans與Jasper報告插件配合使用。 我創建了我的連接(測試正常),我創建了jrxml,然后嘗試預覽它。

它會自動編譯(出現.jasper),並且我收到一條消息:“文檔無頁面”。

我讀過問題可能是數據源為空,但事實並非如此。.因此,我決定制作一個非常簡單的jrxml(靜態:僅文本,不引用數據庫的任何字段)

    <?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>

同樣認為它可以編譯,但我有消息


所以我添加了這兩行:

<noData>no Data</noData>
<queryString>select * from dual</queryString>

顯然沒有顯示任何內容,但是顯示了相同的消息..所以連接似乎還好嗎?

即使報表的主體中只有靜態文本,如果報表的sql為空,默認情況下jasper也不會顯示任何內容。 嘗試添加“選擇1作為虛擬對象”作為查詢,看看是否可以解決。

嘗試一個空查詢並查看結果。 從此CodeRanch論壇帖子中,我提取了以下內容:

當查詢沒有結果時,JR提供了3個選項,您可以利用它們:(a)生成空白報告(PDF),即,無頁面(b)生成單個空白頁面報告(c)生成一份報告,顯示除詳細信息部分外的所有部分

這可以通過為元素jasperReport設置屬性[B} whenNoDataType [/ B]的值來完成。 接受的3個值是:(a)NoPages(b)空白頁(c)AllSectionsNoDetail

那對我有用。

要驗證數據源是否不是問題,可以在報表的“ No Data部分中放置靜態文本。 然后在報表的屬性中

When No Data : No Data Section

如果報表中顯示了靜態文本,則數據源就是您的問題。

導致此錯誤的原因是,報告已被編譯為可編譯以在“編譯報告”中單擊。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM