Agenda Jasperreports Report Creation Process Data Sources

Agenda Jasperreports Report Creation Process Data Sources

Agenda • JasperReports Product Description Embedding JasperReports into JBoss Applications • JasperReports for Jboss Teodor Danciu Founder • Sample JasperReports/JBoss JasperReports Integration February 22, 2005 © JBoss Inc. 2005 2 JasperReports Report Creation Process • Report Design 9 JRXML – XML-based report definition 9 Rich information presentation language 9 Alternative methods for JRXML editing 9 Open-source Java-based library • Swing and Eclipse based visual report designers • Programmatic API 9 Seamlessly-embeddable • XML Editors 9 Runtime environment agnostic • Report compilation 9 Pluggable report compilers 9 Data source agnostic 9 Compiles design to ready-to-use form 9 Flexible calculation capabilities • Report filling 9 Populate with data from any source 9 Pixel-perfect, complex layouts 9 Data supplied by parent application • Report storage (optional) 9 Wide range of output channels 9 Serializable as a JasperPrint object 9 PDF, HTML, XLS, XML, CSV output options 3 4 Library API Overview Data Sources • Runtime environment agnostic 9 Jasper does not make any assumptions about type of data source JasperCompileManager JasperPrintManager 9 All data supplied as either input parameters, or from a data source print 9 Parent application is responsible for supplying JRXmlLoader JRCompiler JasperFillManager fill data • Parameterized query support XML JasperDesign JasperReport JasperPrint 9 Partial or total dynamic/runtime query parse compile fill construction using report parameters HTML • Pluggable data model API GUI Tool export 9 Simple and common data supplier interface • JRDataSource interface CSV 9 Pre-packaged JDBC data source JasperExportManager implementation XML • Report embedded SQL query 9 JavaBeans based data source implementations for wrapping EJBs, Hibernate or POJOs 9 XML data source 5 6 1 Report Layout Complex Layouts • Section oriented and multi-column report layouts • Complex report requirements may 9 Title, detail, summary, page, column include: and group headers and footers, etc. 9 Simultaneous iteration through multiple • Data grouping data sets 9 Any number of nested groups 9 Aggregation of multiple pieces of 9 Inserts group footer/header sections on information each group break • Wide range of graphic and text elements • Complex report requirements are 9 Lines, rectangles, images, static texts, dynamic text fields, etc handled via “subreports” 9 Comprehensive control over report element style properties 9 Any report template can be used as a • Pixel-perfect layout subreport inside another template 9 Designed with printing in mind 9 Allows report designers to achieve 9 All report elements can be precisely positioned and sized arbitrarily complex report layout • Drill-down / Drill-through 9 Reports can contain various types of hyperlinks 9 Enables drill-down reports and drill-through to external document 7 8 Report Expressions Calculation Engine • Built-in and user-defined variables • Report expressions defined using Java 9 Page number, record counts, etc 9 Provides robust expression definition 9 Late-fill capability 9 Enables existing code to be leveraged • Built-in and calculations 9 Implemented using arbitrarily scalable algorithms: sum, count, min, max, • JasperReports special syntax average, variance, standard deviation 9 Enables references within expression • User-defined calculations parameters, fields, or report variables 9 Built on top of expressions 9 Pluggable calculation interface • Flexible scope of calculations • Expressions are compiled to bytecode 9 Report, page, column, or group level 9 Faster evaluation vs. interpreter or scripting • Scriptlet API allows custom-code execution during report-filling language 9 Convenient way to place some business logic associated with the report data 9 E.g. prepare data for a chart 9 10 Internationalization Report Viewers • Embeddable report viewers • Leverages Java platform internationalization 9 Built-in Java/Swing report viewer support 9 Available open source Eclipse/SWT report viewer 9 Unicode 9 Locales 9 Resource bundles • Single report design can be rendered in different languages/locales 9 Text element translation 9 Date/number/time/currency formatting 11 12 2 Requirements JasperReports for JBoss • Java JDK 9 JDK 1.2.2 or higher • XML 9 Working with static report templates 9 JAXP 1.1 XML Parser • Jakarta Commons Digester Component (version 1.1 or later) 9 Ad-hoc report templates 9 http://jakarta.apache.org/commons/digester/ • Jakarta Commons BeanUtils Component (version 1.1 or later) 9 Data sources 9 http://jakarta.apache.org/commons/beanutils/ • Jakarta Commons Collections Component (version 1.0 or later) 9 Reports in HTML format 9 http://jakarta.apache.org/commons/collections/ • Jakarta Commons Logging Component (version 1.0 or later) 9 PDF and XLS output 9 http://jakarta.apache.org/commons/logging/ • JDBC 9 JDBC 2.0 Driver • PDF 9 iText (version 1.01 or later) • http://www.lowagie.com/iText/ • XLS 9 Jakarta POI (version 2.0 or later) • http://jakarta.apache.org/poi/ 13 14 Static Report Templates Ad-hoc Report Templates • Report compilation using ANT • Dynamic report structure <target name="compile-reports"> 9 User input required for report layout <taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask"> 9 Higher level or simplified report design framework <classpath refid="classpath"/> </taskdef> <jrc srcdir="./reports" destdir="./build/reports" tempdir="./build/temp" • Building report templates using the API xmlvalidation="true"> 9 Specialized package and object model <classpath refid="classpath"/> </jrc> 9 Runtime report template compilation </target> • Altering report templates without requiring recompilation • Deploying and locating report files 9 Style related and non-validation related modifications File reportFile = new File(application.getRealPath("/reports/WebappReport.jasper")); ... JasperReport jasperReport = (JasperReport)JRLoader.loadObjectFromLocation("com/mycomp/rpt/Invoice.jasper") 15 16 Data Sources Reports in HTML Format • JavaBeans compatible data source implementations • Paginated HTML output 9 JRBeanCollectionDataSource 9 JRBeanArrayDataSource • Flow oriented HTML output • Access to nested object properties • Working with images in HTML • Reporting directly from DTOs, EJBs, Hibernate or simple JRHtmlExporter exporter = new JRHtmlExporter(); Java data objects Map imagesMap = new HashMap(); session.setAttribute("IMAGES_MAP", imagesMap); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, sbuffer); exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image.jsp?image="); exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex)); exporter.exportReport(); 17 18 3 PDF and XLS Output • PDF Output bytes[] bytes = JasperExportManager.exportReportToPdf(jasperPrint); ... response.setContentType("application/pdf"); response.setContentLength(bytes.length); • XLS Output JRXlsExporter exp = new JRXlsExporter(); exp.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); Questions exp.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exp.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE); exp.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.FALSE); exp.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE); exp.exportReport(); ... response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "inline; filename=\"file.xls\""); response.setContentLength(bytes.length); 19 20 4.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us