재스퍼 플러그인을 사용하여 pdf로 보고서를 얻습니다.이 예제 (http://grails.org/plugin/jasper)를 사용하여 보고서를 얻으려고합니다. 아래에 사용 된 pdf 형식의 특정 ID 정보를 얻으려고합니다. 코드.재 스퍼 보고서 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 페이지에서 사용하여 특정 ID 보고서를 얻었습니다.
<?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>
위 코드는 web-apps/report 폴더 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가 잘못 표시됩니다. 이 문제를 해결하려면 안내해주세요.
iReport에서 보고서를 확인 했습니까? 그게 유효합니까? –
iReport에서 보고서를 확인하는 방법. 나에게 새로운 개념이므로 물어볼 것입니다. 어떻게 유효한지 알 수 있습니까? – manu
iReport를 설치 했습니까? 그렇다면 템플릿을 컴파일하고 (미리보기 탭을 통해) 미리보기를 시도하십시오 –