2011-11-10 21 views
6

मैं पीडीएफ में रिपोर्ट प्राप्त करने के लिए जैस्पर प्लगइन का उपयोग करता हूं .मैं इस उदाहरण (http://grails.org/plugin/jasper) का उपयोग करके रिपोर्ट प्राप्त करने का प्रयास कर रहा हूं। नीचे उपयोग किए गए पीडीएफ प्रारूप में विशेष आईडी जानकारी प्राप्त करने के लिए कोड।grails में जैस्पर रिपोर्ट

<div class="buttons"> 
       <g:form> 
        <g:hiddenField name="id" value="${userManagementInstance?.id}" /> 
        <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span> 
        <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span> 
       </g:form> 
      </div> 
      <g:jasperReport jasper="use" format="PDF" name="users"> 
<input type="hidden" name="id" value="${userManagementInstance?.id}" /> 
</g:jasperReport> 

मैंने विशेष आईडी रिपोर्ट प्राप्त करने के लिए show.gsp पृष्ठ में कोड का ऊपर उपयोग किया।

<?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="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> 
    <property name="ireport.scriptlethandling" value="0"/> 
    <property name="ireport.encoding" value="UTF-8"/> 
    <import value="net.sf.jasperreports.engine.*"/> 
    <import value="java.util.*"/> 
    <import value="net.sf.jasperreports.engine.data.*"/> 
    <style name="pagetitle" isDefault="false" fontName="SansSerif" fontSize="14"/> 
    <parameter name="id" isForPrompting="false" class="java.lang.String"> 
<defaultValueExpression><![CDATA["<parameter error>"]]></defaultValueExpression> 

</parameter> 

<queryString><![CDATA[select * from user_management where id =$P{id}]]></queryString> 
     <field name="id" class="java.lang.String"/> 

    <field name="user_id" class="java.lang.String"/> 
    <field name="user_name" class="java.lang.String"/> 

    <background> 
     <band/> 
    </background> 



    <title> 
     <band height="79"> 
      <staticText> 
       <reportElement style="pagetitle" x="0" y="0" width="201" height="46"/> 
       <textElement/> 
       <text><![CDATA[all]]></text> 
      </staticText> 
     </band> 
    </title> 
    <pageHeader> 
     <band height="35"/> 
    </pageHeader> 
    <columnHeader> 
     <band height="61"> 
     <staticText> 
       <reportElement key="staticText" x="0" y="39" width="100" height="20"/> 
       <textElement/> 
       <text><![CDATA[id]]></text> 
      </staticText> 

      <staticText> 
       <reportElement key="staticText" x="130" y="39" width="100" height="20"/> 
       <textElement/> 
       <text><![CDATA[userId]]></text> 
      </staticText> 
      <staticText> 
       <reportElement key="staticText" x="266" y="39" width="100" height="20"/> 
       <textElement/> 
       <text><![CDATA[userName]]></text> 
      </staticText> 

     </band> 
    </columnHeader> 
    <detail> 
     <band height="42"> 
     <textField isBlankWhenNull="false" hyperlinkType="None"> 
       <reportElement key="textField" x="0" y="15" width="130" height="20"/> 
       <textElement/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{id}]]></textFieldExpression> 
      </textField> 

      <textField isBlankWhenNull="false" hyperlinkType="None"> 
       <reportElement key="textField" x="130" y="15" width="136" height="20"/> 
       <textElement/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{user_id}]]></textFieldExpression> 
      </textField> 
      <textField isBlankWhenNull="false" hyperlinkType="None"> 
       <reportElement key="textField" x="266" y="15" width="130" height="20"/> 
       <textElement/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{user_name}]]></textFieldExpression> 
      </textField> 

     </band> 
    </detail> 
    <columnFooter> 
     <band height="45"/> 
    </columnFooter> 
    <pageFooter> 
     <band height="54"/> 
    </pageFooter> 
    <summary> 
     <band height="42"/> 
    </summary> 
</jasperReport> 

मैं ऊपर दिए गए कोड का उपयोग वेब-ऐप्स/रिपोर्ट फ़ोल्डर use.jasper में करता हूं।

Error 500: Executing action [index] of controller [org.codehaus.groovy.grails.plugins.jasper.JasperController] in plugin [jasper] caused exception: null 
Servlet: grails 
URI: /inventoryManagment/grails/jasper.dispatch 
Exception Message: invalid stream header: 3C3F786D 
Caused by: invalid stream header: 3C3F786D 
Class: Unknown 
At Line: [-1] 

लेकिन मुझे त्रुटि मिल रही है जो अवैध स्ट्रीम हेडर है: 3C3F786D। तो कृपया इस समस्या को हल करने के लिए मुझे मार्गदर्शन करें।

+1

क्या आपने आईआरपोर्ट में अपनी रिपोर्ट की जांच की? क्या यह वैध है? –

+0

iReport में रिपोर्ट कैसे जांचें। यह मेरे लिए नई अवधारणा है, इसलिए मैं पूछ रहा हूं। यह कैसे जानना वैध है या नहीं? – manu

+2

क्या आपने iReport इंस्टॉल किया है? यदि हां, तो टेम्पलेट को संकलित करने का प्रयास करें और इसे पूर्वावलोकन करने का प्रयास करें ('पूर्वावलोकन' टैब के माध्यम से) –

उत्तर

1

ऐसा लगता है कि आप .jrxml फ़ाइल का उपयोग कर सबरेपोर्ट पर प्रतिक्रिया दे रहे हैं। लेकिन, आप संकलित संस्करण का उपयोग करना चाहिए। Jasper।

मुझे उम्मीद है कि यह काम करता है!

+0

मेरे लिए काम नहीं करता .... एक ही त्रुटि, लेकिन अलग हेडर कोड। जैस्पर रीपॉर्ट्स लाइब्रेरी 4.6.0 का उपयोग करके, जेएसपीएमएल + जेस्पर फाइल जेस्पर सॉफ्ट स्टूडियो 1.1.1 का उपयोग करके जेनरेट की गई –

संबंधित मुद्दे