473,545 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create dynamic report through JRXML???

13 New Member
Hey! I am working on jrxml to create dynamic re0ports. I have parameterized the columns i.e. the jrxml for that report can be used to generate other reports as well.

However, i have not managed to make the fields flexible. That is, if the user selects 4 columns it would work but if 1 or 2 or 3 columns are selected, it gives an error since the field names are unidentified.

Please post a solution urgently if something like a default expression for fieldname can be created or a for loop/java script can be used.

Moreover, how can jasper designer be exactly used to achieve this?

The jrxml is as follows:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <!DOCTYPE jasperReport
  3.   PUBLIC "-//JasperReports//DTD Report Design//EN"
  4.   "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
  5.  
  6. <jasperReport name="report1">
  7.  
  8.     <parameter name="reportTitle" class="java.lang.String"/>
  9.     <parameter name="author" class="java.lang.String"/>
  10.     <parameter name="startDate" class="java.lang.String"/>
  11.  
  12.  <parameter name="C1" class="java.lang.String">
  13.         <defaultValueExpression>
  14.             new java.lang.String("")
  15.         </defaultValueExpression>
  16.     </parameter>
  17.  
  18.     <parameter name="C2" class="java.lang.String">
  19.         <defaultValueExpression>
  20.             new java.lang.String("")
  21.         </defaultValueExpression>
  22.     </parameter>
  23.  
  24.     <parameter name="C3" class="java.lang.String">
  25.         <defaultValueExpression>
  26.             new java.lang.String("")
  27.         </defaultValueExpression>
  28.     </parameter>
  29.  
  30.     <parameter name="C4" class="java.lang.String">
  31.         <defaultValueExpression>
  32.             new java.lang.String("default parameter value")
  33.         </defaultValueExpression>
  34.     </parameter>
  35.  
  36.     <field name="COLUMN_1" class="java.lang.Integer"/>
  37.     <field name="COLUMN_2" class="java.lang.Integer"/>
  38.     <field name="COLUMN_3" class="java.lang.Integer"/>
  39.     <field name="COLUMN_4" class="java.lang.Integer"/>
  40.  
  41.     <title>
  42.         <band height="60">
  43.             <textField>
  44.                 <reportElement x="0" y="10" width="500" height="40"/>
  45.                 <textElement textAlignment="Center">
  46.                     <font size="24"/>
  47.                 </textElement>
  48.                 <textFieldExpression class="java.lang.String">
  49.                     <![CDATA[$P{reportTitle}]]>
  50.                 </textFieldExpression>
  51.             </textField>
  52.             <textField>
  53.                 <reportElement x="0" y="40" width="500" height="20"/>
  54.                 <textElement textAlignment="Center"/>
  55.                 <textFieldExpression class="java.lang.String">
  56.                     <![CDATA["Run by: " + $P{author}
  57.                         + " on " + $P{startDate}]]>
  58.                 </textFieldExpression>
  59.             </textField>
  60.         </band>
  61.     </title>
  62.  
  63.  
  64. <columnHeader>
  65.         <band height="30">
  66.             <rectangle>
  67.                 <reportElement x="0" y="0" width="500" height="25"/>
  68.                 <graphicElement/>
  69.             </rectangle>
  70.  
  71.             <textField>
  72.                 <reportElement x="0" y="5" width="170" height="15"/>
  73.                 <textFieldExpression class="java.lang.String">
  74.                     <![CDATA[$P{C1}]]>
  75.                 </textFieldExpression>
  76.             </textField>
  77.  
  78.             <textField>
  79.                 <reportElement x="70" y="5" width="170" height="15"/>
  80.               <textFieldExpression class="java.lang.String">
  81.                     <![CDATA[$P{C2}]]>
  82.                 </textFieldExpression>
  83.             </textField>
  84.  
  85.             <textField>
  86.                 <reportElement x="150" y="5" width="150" height="15"/>
  87.               <textFieldExpression class="java.lang.String">
  88.                     <![CDATA[$P{C3}]]>
  89.                 </textFieldExpression>
  90.             </textField>
  91.  
  92.             <textField>
  93.                 <reportElement x="300" y="5" width="150" height="15"/>
  94.               <textFieldExpression class="java.lang.String">
  95.                     <![CDATA[$P{C4}]]>
  96.                 </textFieldExpression>
  97.  
  98.             </textField>
  99.  
  100.  
  101.             </band>
  102.     </columnHeader>
  103.  
  104.  
  105. <detail>
  106.         <band height="20">
  107.  
  108.             <textField>
  109.                 <reportElement x="5" y="0" width="50" height="15"/>
  110.                 <textElement/>
  111.                 <textFieldExpression class="java.lang.Integer">
  112.                     <![CDATA[$F{COLUMN_1}]]>
  113.                 </textFieldExpression>
  114.             </textField>
  115.  
  116.             <textField>
  117.                 <reportElement x="90" y="0" width="150" height="15"/>
  118.                 <textElement/>
  119.                 <textFieldExpression class="java.lang.Integer">
  120.                     <![CDATA[$F{COLUMN_2}]]>
  121.                 </textFieldExpression>
  122.             </textField>
  123.  
  124.             <textField>
  125.                 <reportElement x="170" y="0" width="50" height="15"/>
  126.                 <textElement/>
  127.                 <textFieldExpression class="java.lang.Integer">
  128.                     <![CDATA[$F{COLUMN_3}]]>
  129.                 </textFieldExpression>
  130.             </textField>
  131.  
  132.             <textField>
  133.                 <reportElement x="320" y="0" width="150" height="15"/>
  134.                 <textElement/>
  135.                 <textFieldExpression class="java.lang.Integer">
  136.                     <![CDATA[$F{COLUMN_4}]]>
  137.                 </textFieldExpression>
  138.             </textField>
  139.  
  140.         </band>
  141.     </detail>
  142.  
  143. </jasperReport> 
Dec 20 '09 #1
1 9645
Ricardo Mariaca
1 New Member
I recommend to use DynamicReports, is open source and you can create dynamic reports very easy
Apr 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
17515
by: Climber | last post by:
Hello, I want to now how to do a dynamic report with Crystal Report (C# .Net), the number of colum and row are different each time because they depend of my data base. Thanks Climber
0
3664
by: Benny | last post by:
Hello Experts, Currently Im working on a web application using asp.net with C#. I need to create a report depends on user's selection of the database fields, i.e. the user may want to display the customer name and address (from the customers table) on the report. The question is how can I create a dynamic crystal report for this...
6
4807
by: Peter Herath | last post by:
I want to create a dynamic report using a crosstab query...... pls someone look into my attached example database and help me out to do the report generation.... example is like dis...: there are 4 combo boxes.. when u select an item from each combo box and click the ViewReport Button then those selected item values should go as parameters...
2
1711
by: zoro25 | last post by:
Hi, I want to create a dynamic report and for that I'm using a very simple Combo Box (only one item) and I want to use this filter on my report. Here's the code I came up with: Private Sub Enter_Click() Dim strSite_Name As String Dim strEnter As String If IsNull(Me.cboSite_Name.Value) Then strSite_Name = "Like '*'...
0
1151
by: josur | last post by:
Hi, I would like to know if is possible to create dynamic reports based on cubes. What i mean is,after creating a cube with a couple of dimensions and measure if is there any way to give the normal users on the report manager or report builder the freedom to choose their own dimensions/measure so they can output the report with the choosen...
3
18684
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child...
4
2679
by: Sep410 | last post by:
Hi all, I have to create a dynamic report in vb.net. I never had done something like this before.Users want to see tables name and when they choose the table they will select which fields should appear in report. How should I do tha?
2
8737
by: J360 | last post by:
I'm using VB in Access 2003 to generate a dynamic report. I first open the report in design view to set all the grouping levels etc. I then use with rpt .printer.orientation = acProrlandscape ... End With I then open and display the report using docmd and acviewpreview. The report opens everytime...
5
3229
by: Mr Key | last post by:
Hi, I hope someone could help me on this, I have a query of several fields from which I want to create report of few fields selected by user. Say total fields be 30 as Field1...Field30, The first three fields will be displayed on the reports but only one of the rest fields (Field4...30) will be available depending on the user request. The User...
0
7484
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5997
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3470
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.