Jump to content
We've recently updated our Privacy Statement, available here ×

problem with run my report


Jakub

Recommended Posts

Hi, I am total beginner with JasperReport. I read tutorials on this website or google, but I have a problem with run my report. I have 3 requierements on my report.

 

1. I want set up title report from my swing application

2. I would like set up data from MySQL database (I paste in my .jrxml file SQL base answer, and I want add specify data - WHERE name LIKE "John" etc. - from my swing application)

3. One last page I want sum 3th columns - price.

 

I create .jrxml file in iReport, in this file I create 3 field id, name, price (some names as columns from database table), variable Celkem (Sum price), but I know not how next. iReport compile .java file with same name as .jrxml file, this .java and .jrxml files I paste to my NetBeans project.In .java file I want create set functions (title etc.)?

 

Thanks you for your help me

 

My jrxml file

/****************************************************/

<?xml version="1.0" encoding="Cp1250" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport

name="Tisk"

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="595"

pageHeight="842"

columnWidth="535"

columnSpacing="0"

leftMargin="30"

rightMargin="30"

topMargin="20"

bottomMargin="20"

whenNoDataType="NoPages"

isTitleNewPage="false"

isSummaryNewPage="false">

<property name="ireport.scriptlethandling" value="0" />

<property name="ireport.encoding" value="Cp1250" />

<import value="java.util.*" />

<import value="net.sf.jasperreports.engine.*" />

<import value="net.sf.jasperreports.engine.data.*" />

 

<queryString><![CDATA[sELECT id,name,price from foo;]]></queryString>

 

<field name="id" class="java.lang.Integer"/>

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

<field name="price" class="java.lang.Double"/>

 

<variable name="Celkem" class="java.lang.Double" resetType="Report" calculation="Sum">

<variableExpression><![CDATA[$F{price}]]></variableExpression>

</variable>

<background>

<band height="0" isSplitAllowed="true" >

</band>

</background>

<title>

<band height="50" isSplitAllowed="true" >

</band>

</title>

<pageHeader>

<band height="50" isSplitAllowed="true" >

</band>

</pageHeader>

<columnHeader>

<band height="30" isSplitAllowed="true" >

</band>

</columnHeader>

<detail>

<band height="100" isSplitAllowed="true" >

</band>

</detail>

<columnFooter>

<band height="30" isSplitAllowed="true" >

</band>

</columnFooter>

<pageFooter>

<band height="50" isSplitAllowed="true" >

</band>

</pageFooter>

<lastPageFooter>

<band height="50" isSplitAllowed="true" >

</band>

</lastPageFooter>

<summary>

<band height="50" isSplitAllowed="true" >

</band>

</summary>

</jasperReport>

Post edited by: Jakub, at: 2006/08/07 08:57

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi, I rewrite my jrxml file, copy this file to my Netbeans project directory, .java file I copy to src directory in my project. Every ok, any errors or warning, but in application is show JOption pane with

message Document is empty. My code in application is

 

///////////////////////////////////////////////////

 

java.sql.Connection conn = null;

 

Map<String, Object> params = new HashMap<String, Object>();

params.put("My title text","Nadpis");

// params.put("SELECT id,nazev,cena from majetek","sqlDotaz");

params.put("My summary text","Soucet");

 

try

{

JasperReport jasperReport =

JasperCompileManager.compileReport(reportSource);

 

JeUzivPrihlasen je = new JeUzivPrihlasen();

 

 

if(je.jeNastaveno()){

 

SpojDatabazi db = new SpojDatabazi(true);

conn = db.getConnection();

db = null;

je = null;

}

je = null;

 

JasperPrint jasperPrint = JasperFillManager.fillReport(

jasperReport, params, conn);

 

JasperViewer.viewReport(jasperPrint);

}

 

catch (JRException ex)

{

JOptionPane.showMessageDialog(this,"Error with load data!","Error",JOptionPane.ERROR_MESSAGE);

ex.printStackTrace();

}

 

///////////////my jrxml file////////////////////////

 

<?xml version="1.0" encoding="UTF-8" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport

name="Tisk"

columnCount="1"

printOrder="Horizontal"

orientation="Portrait"

pageWidth="595"

pageHeight="842"

columnWidth="535"

columnSpacing="0"

leftMargin="30"

rightMargin="30"

topMargin="20"

bottomMargin="20"

whenNoDataType="NoPages"

isTitleNewPage="false"

isSummaryNewPage="false">

<property name="ireport.scriptlethandling" value="2" />

<property name="ireport.encoding" value="UTF-8" />

<import value="java.util.*" />

<import value="net.sf.jasperreports.engine.*" />

<import value="net.sf.jasperreports.engine.data.*" />

 

<parameter name="Nadpis" isForPrompting="false" class="java.lang.String"/>

<parameter name="sqlDotaz" isForPrompting="false" class="java.lang.String"/>

<parameter name="Soucet" isForPrompting="false" class="java.lang.String"/>

 

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

<field name="cena" class="java.lang.Double"/>

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

 

<background>

<band height="0" isSplitAllowed="true" >

</band>

</background>

<title>

<band height="50" isSplitAllowed="true" >

<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="0"

y="1"

width="533"

height="36"

key="textField-1"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font pdfEncoding ="Cp1250"/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$P{Nadpis}]]></textFieldExpression>

</textField>

</band>

</title>

<pageHeader>

<band height="50" isSplitAllowed="true" >

</band>

</pageHeader>

<columnHeader>

<band height="30" isSplitAllowed="true" >

</band>

</columnHeader>

<detail>

<band height="100" isSplitAllowed="true" >

</band>

</detail>

<columnFooter>

<band height="30" isSplitAllowed="true" >

</band>

</columnFooter>

<pageFooter>

<band height="50" isSplitAllowed="true" >

</band>

</pageFooter>

<lastPageFooter>

<band height="50" isSplitAllowed="true" >

</band>

</lastPageFooter>

<summary>

<band height="48" isSplitAllowed="true" >

<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="2"

y="16"

width="532"

height="32"

key="textField-2"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement>

<font pdfEncoding ="Cp1250"/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$P{Soucet}]]></textFieldExpression>

</textField>

</band>

</summary>

</jasperReport>

Link to comment
Share on other sites

Hi, I debug my application, and con include valid informations from my database. On example I do not load any data from database, I need visit title and summary text in text fields in report.

 

 

Map<String, Object> params = new HashMap<String, Object>();

params.put("Nadpis","Text my title ");

params.put("Soucet","Text my summary");

 

 

 

But report is empty. :( .

Thanks

Link to comment
Share on other sites

Thank you for your help me, my friend me send function jrxml file, I rewrite this file for me and work it! I don`t know, where I have error. I generate report from iReport.

Yet another how I load data from database and I am happiest man. :)

 

Regards

Link to comment
Share on other sites

Hi, today my report is load data from database, but I have only one problem. If my report include etc. 5 rows, this rows are through all report. In between are big white rows. How I load rows under himself?

 

Thanks size=400]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/report.jpg

Post edited by: Jakub, at: 2006/08/09 16:41

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...