Design Simple Report in Jasper Report GUI.
As in most GUI based Report writer and Form Designer, user select various Designer objects such
as Textboxes, Radio buttons , Dropdown List item. etc.. Report writer generates source code and its properties for user.Below is such sample source code taken from Jasper report writer in which three
parameters are passed(user input) to run the query(in sql).Pay close attention how to pass parameters in Sql query(in jasper report $ sign placed before Parameters and Fields like $P{} denotes Parameters
and $F{} denotes reports fields. As user design report further ,report writer automatically generates
code for that. There are many predefined functions both text and numeric functions such as to convert
string into numeric or Dates into String etc, and numeric functions like sum(),max(),min(),avg() and many more...
<parameter name="sclass" class="java.lang.String">
<defaultValueExpression><![CDATA[$P{sclass}]]></defaultValueExpression>
</parameter>
<parameter name="stud_sec" class="java.lang.String"/>
<parameter name="user_year" class="java.lang.String"/>
<queryString language="SQL">
<![CDATA[select st.st_id,st.st_name,st.st_gender,st.st_dob,st.st_father_name,st.st_mother_name,st.st_class,st.st_section,st.fathers_mobile,st.stoppage from sch_db.student st WHERE st.st_section=$P{stud_sec} and st.school_year = $P{user_year} and st.st_class = $P{sclass}]]>
</queryString>
<field name="st_id" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="st_id"/>
<property name="com.jaspersoft.studio.field.tree.path" value="student"/>
</field>
above is screen shot of this simple report look at left side of editor..it shows fields, variables, functions,
textfields(Static) labels etc..(zoom it)
Hope this helps user to design Jasper report.
I will show in next session how to run the report from Java Program...
Comments
Post a Comment