150 likes | 287 Views
iReport An Introduction TEC01. Patty White. Agenda. Anatomy of an Aspen Report Formatting Report Fields Adding a New F ield to the Report A Taste of Java: String Methods. Anatomy of an Aspen Report . Input Definition gathers information from user.
E N D
iReportAn IntroductionTEC01 Patty White
Agenda • Anatomy of an Aspen Report • Formatting Report Fields • Adding a New Field to the Report • A Taste of Java: String Methods
Anatomy of an Aspen Report Input Definitiongathers information from user Java Source gathers data based on user’s input Format Definitiondisplays the data gathered in Java source
iReport – visual reporting tool for JasperReports JasperReports – embeddable Java report library – the report engine Download and install iReport 2.0.4 to your computer.http://sourceforge.net/projects/ireport/files/iReport (classic)/iReport-2.0.4 Install Java Runtime Environment (JRE) if you are unable to open iReport.http://java.sun.com Launch iReport from your Desktop (outside of Aspen). You can now edit report formats!
District View: Tools > Reports * Windows only (no Mac or Linux). Not recommended for customizations.
Modify a Report Format Definition District View: Tools > Reports SYS-STD-010 A system-delivered report. When you make a copy of the report, replace with a 3-character district/school code. ADM – Admin ATT – Attendance CND – Conduct • GRD – Grades • HTH – Health • SCH – Schedule • STD – Student • STF – Staff
Options > Copy • Name does not have to be unique, but the Report ID does. • Keep the original Report ID, replacing SYS with 3-character district/school code. • Weight = priority • Changing the version of the report engine (JasperReports) can have adverse effects. • Leave the Custom checkboxes unchecked since we are copying the report, not modifying it. Birthday List XXX-STD-010
Make a copy. Download Format Definition . Edit using iReport. Upload Format Definition . Use Options > Compile Format. If you get compile time errors, return to step 3. Save the report. To test, use Options > Run.Or navigate to screen where report exists in Reports menu. Hide original SYS- version by un-checking all views on report’s Navigation sub-tab.
Customizing a report: adding a field • Determine the following: • Is new field on report’s base table? Yes > go to step 2. • Is new field on related table? Yes > go to step 3. • Add field to report’s base table. • Specify field with Java name from Data Dictionary. • Right-click in Document structure, and select Add. • Enter Java name of field. • Use this field in your report with the syntax $F{fieldName} • Sample screens show syntax $F{gradeLevel}
Add field to related table. • Right-click in Document structure, and select Add. • Specify related table, then field. Examples: • person.genderCode person.dob • person.lastNameperson.firstName • Attendance, conduct or grades report require specifying Student table since report is based on something else (attendance, conduct or grades). • student.gradeLevel • student.person.dob • Use these fields in your report with the syntax $F{fieldName} • $F{person.genderCode} or $F{student.fieldB023}
Reports with get() function • Another way of referencing fields on related tables (not Base table of report) • Advantage of the get() function: only need to define table (student, person, school, etc.) in field list • $F{student.gradeLevel} = $F{student}.getGradeLevel() • $F{student.fieldB023} = $F{student}.getFieldB023() • $F{person.dob} = $F{person}.getDob()
Taste of Java • String Methods • toUpperCase() • string.toUpperCase() • $F{nameView}.toUpperCase() • trim() – removes white space from both ends of string • string.trim() • $F{nameView}.trim() • substring() - returns selected block of characters. • string.substring(intbeginIndex, intendIndex) • $F{person.firstName}.substring(0,1) For a complete list of the Java string class methods: http://java.sun.com/javase/7/docs/api/
String Comparisons • equals() and not equal • string.equals(anObject) !string.equals(anObject) • $F{yog}.equals(“2010”) !$F{yog}.equals(“2010”) • length() • string.length() • $F{homeroom}.length() • IF/Then/Else statement • Comparison ? result_if_true : result_if_false • $F{homeroom}.length()==0 ? “N/A” : $F{homeroom} • If length of homeroom field = 0, print “N/A”, otherwise print homeroom.
Thank you. pwhite@x2dev.com