2016-06-25 6 views
-1

私はカスタムデータソースを使用してジャスパーレポートを作成しています。 iReportを使用してレポートを作成しています。 Web上のさまざまな記事に続いて動作するレポートを見ることができますが、生成されたJrxmlがカスタムJRDatasourceからデータをフェッチすることをどのように知っているのか理解できません。 私のカスタムデータソースクラスを指しているJrxmlはどこにも見えませんか?カスタムデータソースを使用したJrxmlの理解

もっと詳しい情報を提供できる人はいますか?ここで

が生成Jrxml

<?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="test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a19f56bb-4764-4dad-8177-9a410a0cb69d"> 
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/> 
<queryString> 
    <![CDATA[]]> 
</queryString> 
<field name="productCode" class="java.lang.String"/> 
<field name="stockLevelStatus" class="java.lang.String"> 
    <fieldDescription><![CDATA[stockLevelStatus]]></fieldDescription> 
</field> 
<background> 
    <band splitType="Stretch"/> 
</background> 
<pageHeader> 
    <band height="35" splitType="Stretch"/> 
</pageHeader> 
<detail> 
    <band height="125" splitType="Stretch"> 
     <textField> 
      <reportElement x="10" y="60" width="100" height="30" uuid="53ec360c-996a-48eb-9777-efbb9d5fa3d7"/> 
      <textFieldExpression><![CDATA[$F{productCode}]]></textFieldExpression> 
     </textField> 
     <staticText> 
      <reportElement x="10" y="0" width="100" height="30" uuid="dc8fcc8f-6294-4d5b-97de-4b68d2e6bb8b"/> 
      <text><![CDATA[productCode]]></text> 
     </staticText> 
     <textField> 
      <reportElement x="140" y="60" width="100" height="30" uuid="5219cffe-1786-4bd8-a8af-83eebda483cf"/> 
      <textFieldExpression><![CDATA[$F{stockLevelStatus}]]></textFieldExpression> 
     </textField> 
     <staticText> 
      <reportElement x="140" y="0" width="100" height="30" uuid="27edec96-50c6-4de0-830a-9593a0da7c17"/> 
      <text><![CDATA[stockLevelStatus]]></text> 
     </staticText> 
    </band> 
</detail> 
</jasperReport> 

いる人は、カスタムデータソースとJrxmlを共有することはできますか?

答えて

1

最後に、多くのR & Dの後、私はこの問題を解決することができます。 ".jrxml"ファイルは、テーブルのデータがカスタムデータソースから来るJasperレポートにテーブルをプロットするためのファイルです。

カスタムデータソースの記述方法を説明しているWeb上の記事はたくさんありますが、カスタムデータソースをjrxmlファイルで使用する方法の例はありません。

<?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="custom" language="groovy" pageWidth="595" pageHeight="420" whenNoDataType="BlankPage" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" scriptletClass="de.hybris.platform.cockpit.reports.scriptlets.DateTimeScriptlet" resourceBundle="localization/jasperreports"> 
<property name="ireport.zoom" value="1.0"/> 
<property name="ireport.x" value="0"/> 
<property name="ireport.y" value="0"/> 
<subDataset name="custome_datasource">  
    <queryString> 
     <![CDATA[select 1 from DUAL]]> 
    </queryString> 
    <field name="productCode" class="java.lang.String"/> 
    <field name="stockLevelStatus" class="java.lang.String"> 
     <fieldDescription><![CDATA[stockLevelStatus]]></fieldDescription> 
    </field> 
</subDataset> 
<queryString> 
    <![CDATA[select 1 from DUAL]]> 
</queryString> 
<title> 
    <band height="80" splitType="Stretch"> 
     <staticText> 
      <reportElement x="10" y="0" width="500" height="30"/> 
      <textElement textAlignment="Center" verticalAlignment="Middle"> 
        <font fontName="Arial" size="16" isBold="true"/> 
      </textElement> 
      <text><![CDATA[Stock Level Status Report]]></text> 
     </staticText> 
    </band> 
</title> 
<detail> 
    <band height="340" splitType="Stretch"> 
     <componentElement> 
      <reportElement key="table" x="0" y="0" width="555" height="238"/> 
      <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="custome_datasource"> 
        <dataSourceExpression><![CDATA[new my.dataproviders.StockLevelDataProvider()]]></dataSourceExpression> 
       </datasetRun> 
       <jr:column width="130"> 
        <jr:columnHeader height="30" rowSpan="1">       
         <staticText> 
          <reportElement x="0" y="0" width="92" height="25" backcolor="#99CCFF"/> 
          <textElement textAlignment="Center" verticalAlignment="Middle"> 
           <font fontName="Arial" size="9" isBold="true"/> 
          </textElement> 
          <text><![CDATA[ProductCode]]></text> 
         </staticText> 
        </jr:columnHeader> 
        <jr:detailCell height="30" rowSpan="1"> 
         <textField> 
          <reportElement x="0" y="10" width="90" height="20"/> 
          <textElement textAlignment="Center" verticalAlignment="Middle"> 
           <font fontName="Arial" size="9" isBold="false"/> 
          </textElement> 
          <textFieldExpression class="java.lang.String"><![CDATA[$F{productCode}]]></textFieldExpression> 
         </textField> 
        </jr:detailCell> 
       </jr:column> 
       <jr:column width="130"> 
        <jr:columnHeader height="30" rowSpan="1"> 
         <staticText> 
          <reportElement x="0" y="0" width="92" height="25" backcolor="#99CCFF"/> 
          <textElement textAlignment="Center" verticalAlignment="Middle"> 
           <font fontName="Arial" size="9" isBold="true"/> 
          </textElement> 
          <text><![CDATA[StockLevel]]></text> 
         </staticText> 
        </jr:columnHeader> 
        <jr:detailCell height="30" rowSpan="1"> 
         <textField> 
          <reportElement x="0" y="10" width="90" height="20"/> 
          <textElement textAlignment="Center" verticalAlignment="Middle"> 
           <font fontName="Arial" size="9" isBold="false"/> 
          </textElement> 
          <textFieldExpression class="java.lang.String"><![CDATA[$F{stockLevelStatus}]]></textFieldExpression> 
         </textField> 
        </jr:detailCell> 
       </jr:column> 
      </jr:table> 
     </componentElement> 
    </band> 
</detail> 

関連する問題