2012-03-05 10 views
6

Sto provando a creare un rapporto con Jasper iReport 4.5 e sto utilizzando una tabella per mostrare alcuni dati. La tabella viene riempita da una query e quando si verifica l'anteprima della query nell'editor di query, ottengo esattamente i risultati desiderati. Ma quando provo a creare l'anteprima del report, tutto ciò che ottengo è "Il documento non ha pagine". Nemmeno il testo statico nell'intestazione della tabella viene visualizzato.La tabella iReport di Jasper restituisce un documento vuoto sebbene la query funzioni

Ecco l'XML del rapporto, ma senza la query:

<?xml version="1.0" encoding="UTF-8"?> 
<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="subReportTextManualCustomerRating" pageWidth="500" pageHeight="842" columnWidth="460" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> 
    <property name="ireport.zoom" value="1.4641000000000008"/> 
    <property name="ireport.x" value="0"/> 
    <property name="ireport.y" value="0"/> 
    <style name="table"> 
     <box> 
      <pen lineWidth="1.0" lineColor="#000000"/> 
     </box> 
    </style> 
    <style name="table_TH" mode="Opaque" backcolor="#F0F8FF"> 
     <box> 
      <pen lineWidth="0.5" lineColor="#000000"/> 
     </box> 
    </style> 
    <style name="table_CH" mode="Opaque" backcolor="#BFE1FF"> 
     <box> 
      <pen lineWidth="0.5" lineColor="#000000"/> 
     </box> 
    </style> 
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF"> 
     <box> 
      <pen lineWidth="0.5" lineColor="#000000"/> 
     </box> 
    </style> 
    <style name="table 1"> 
     <box> 
      <pen lineWidth="1.0" lineColor="#000000"/> 
     </box> 
    </style> 
    <style name="table 1_TH" mode="Opaque" backcolor="#FFFFFF"> 
     <box> 
      <pen lineWidth="0.5" lineColor="#000000"/> 
     </box> 
    </style> 
    <style name="table 1_CH" mode="Opaque" backcolor="#FFBFBF"> 
     <box> 
      <pen lineWidth="0.5" lineColor="#000000"/> 
     </box> 
    </style> 
    <style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF"> 
     <box> 
      <pen lineWidth="0.5" lineColor="#000000"/> 
     </box> 
    </style> 
    <subDataset name="CustomerType"> 
     <parameter name="TEXT_MANUAL_OID" class="java.lang.String"/> 
     <queryString> 
     </queryString> 
     <field name="Anzahl" class="java.lang.Long"/> 
     <field name="Typ" class="java.lang.String"/> 
     <field name="Bezeichnung" class="java.lang.String"/> 
    </subDataset> 
    <parameter name="TEXT_MANUAL_OID" class="java.lang.String"/> 
    <queryString> 
     <![CDATA[]]> 
    </queryString> 
    <summary> 
     <band height="143"> 
      <componentElement> 
       <reportElement key="table 1" style="table 1" x="0" y="0" width="460" height="143"/> 
       <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> 
        <datasetRun subDataset="CustomerType"> 
         <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
        </datasetRun> 
        <jr:column width="90"> 
         <jr:tableHeader style="table 1_TH" height="30"> 
          <staticText> 
           <reportElement x="0" y="0" width="90" height="30"/> 
           <textElement/> 
           <text><![CDATA[Kontakt Typen]]></text> 
          </staticText> 
         </jr:tableHeader> 
         <jr:detailCell style="table 1_TD" height="20"> 
          <textField> 
           <reportElement x="0" y="0" width="90" height="20"/> 
           <textElement/> 
           <textFieldExpression><![CDATA[$F{Typ}]]></textFieldExpression> 
          </textField> 
         </jr:detailCell> 
        </jr:column> 
        <jr:column width="90"> 
         <jr:tableHeader style="table 1_TH" height="30"> 
          <staticText> 
           <reportElement x="0" y="0" width="90" height="30"/> 
           <textElement/> 
           <text><![CDATA[Ergebniserklärung]]></text> 
          </staticText> 
         </jr:tableHeader> 
         <jr:detailCell style="table 1_TD" height="20"> 
          <textField> 
           <reportElement x="0" y="0" width="90" height="20"/> 
           <textElement/> 
           <textFieldExpression><![CDATA[$F{Bezeichnung}]]></textFieldExpression> 
          </textField> 
         </jr:detailCell> 
        </jr:column> 
        <jr:column width="90"> 
         <jr:tableHeader style="table 1_TH" height="30"> 
          <staticText> 
           <reportElement x="0" y="0" width="90" height="30"/> 
           <textElement/> 
           <text><![CDATA[Anzahl der Kontakte]]></text> 
          </staticText> 
         </jr:tableHeader> 
         <jr:detailCell style="table 1_TD" height="20"> 
          <textField> 
           <reportElement x="0" y="0" width="90" height="20"/> 
           <textElement/> 
           <textFieldExpression><![CDATA[$F{Anzahl}]]></textFieldExpression> 
          </textField> 
         </jr:detailCell> 
        </jr:column> 
       </jr:table> 
      </componentElement> 
     </band> 
    </summary> 
</jasperReport> 
+1

Hai creato datasource per il rapporto? È necessario impostare l'origine dati rilevante come attiva (in 'iReport'). Quale origine dati (xml o qualcos'altro) stai usando? –

+0

Sì, ho un'origine dati valida e ho impostato la tabella per utilizzare l'origine dati del report principale –

+1

Ok, ho appena scoperto di cosa si trattava. Ho dovuto creare una query per il report principale, anche se non lo uso da nessuna parte in questo report. Quindi ho appena aggiunto selezionare 1 come dummy_field come query per il report principale, e ora la tabella mostra i dati che voglio. Purtroppo, posso rispondere alla mia stessa domanda in 7 ore perché il mio account è nuovo. –

risposta

5

Ok, ho appena scoperto di cosa si trattasse. Ho dovuto creare una query per il report principale, anche se non lo uso da nessuna parte in questo report. Quindi ho appena aggiunto "seleziona 1 come dummy_field" come query per il report principale, e ora la tabella mostra i dati che voglio.

5

C'è un altro metodo.

Segui seguito passo

  1. Clicca sul nome del rapporto principale
  2. scegliere nome della proprietà: quando nessun tipo di dati
  3. scegliere valore della proprietà: tutte le sezioni nessun dettaglio

Utilizzando questo c'è non è necessario aggiungere sql fittizio.

1

Nel mio caso, mi hanno fornito fonte di dati vuota e problema risolto

JasperPrint jasperPrint = JasperFillManager.fillReport(path,null, new JREmptyDataSource()); 
Problemi correlati