You are previewing JasperReports 3.5 for Java Developers.
O'Reilly logo
JasperReports 3.5 for Java Developers

Book Description

Create, Design, Format, and Export Reports with the world's most popular Java reporting library

  • Create better, smarter, and more professional reports using comprehensive and proven methods

  • Group scattered data into meaningful reports, and make the reports appealing by adding charts and graphics

  • Discover techniques to integrate with Hibernate, Spring, JSF, and Struts, and to export to different file formats

  • Written in a lucid and practical manner, this book introduces you to JasperReports and gets you creating complex and elegant reports

  • In Detail

    Do you want to create easily understood, professional, and powerful reports from disordered, scattered data using a free, open source Java class library? If your answer is yes, this book on JasperReports is what you are looking for. JasperReports is the world's most popular embeddable Java open source reporting library, providing Java developers with the power to easily create rich print and web reports.

    The book has been fully updated to use JasperReports 3.5, the latest version of JasperReports. Previously accepted techniques that have now been deprecated have been replaced with their modern counterparts. All examples in the book have been updated to use XML schemas for report templates. Coverage of new data sources that JasperReports now supports has been added to the book. Additionally, JasperReports can now export reports to even more formats than before and exporting reports to these new formats is covered in this new edition of the book.

    This book shows you exactly how to get started, and develop the skills to get the most from JasperReports. It introduces you to the latest version of JasperReports, and gets you creating complex and elegant reports.

    The book steers you through each point of report setup, to creating, designing, formatting, and exporting reports with data from a wide range of data sources, and integrating JasperReports with other Java frameworks.

    Starting with the basics of adding reporting capabilities to your application and creating report templates, you will first see how to produce your reports through the use of JRXML files, custom ANT targets, and then preview them in both the web browser and the native browser of JasperReports.

    Getting data into your reports is the next step, and you will see how to get data from a range of data sources, not only databases, but XML files, and Java Objects, among others.

    You will create better looking reports with formatting and grouping, as well as adding graphical elements to your reports. You will export your reports to a range of different formats, including PDF and XML.

    Creating reports will be made even easier with a walkthrough of the iReport Designer visual designing tool. To round things off, you will see how to integrate your reports with other Java frameworks, using Spring or Hibernate to get data for the report, and Java Server Faces or Struts for presenting the report.

    All examples have been updated to use XML schemas. New export formats, such as OpenDocument Text, and new data sources now supported by JasperReports are now covered in this updated edition.

    Table of Contents

    1. JasperReports 3.5 for Java Developers
      1. JasperReports 3.5 for Java Developers
      2. Credits
      3. About the Author
      4. About the Reviewers
      5. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      6. 1. An Overview of JasperReports
        1. A brief history of JasperReports
        2. What exactly is JasperReports?
        3. The features of JasperReports
          1. Flexible report layout
          2. Multiple ways to present data
          3. Multiple ways to supply data
          4. Multiple datasources
          5. Watermarks
          6. Subreports
          7. Exporting capabilities
        4. Class library dependencies
        5. Typical workflow
        6. Where to get help
        7. Summary
      7. 2. Adding Reporting Capabilities to our Java Applications
        1. Downloading JasperReports
          1. Setting up our environment
        2. JasperReports class library
          1. Required libraries for report compilation
            1. Apache Commons
              1. Apache Commons Digester
              2. Apache Commons Collections
              3. Apache Commons Logging
              4. Apache Commons BeanUtils
          2. Optional libraries and tools
            1. Apache ANT
            2. JDT compiler
            3. JDBC driver
            4. iText
            5. JFreeChart
            6. JExcelApi
        3. Summary
      8. 3. Creating your First Report
        1. Creating a JRXML report template
          1. Previewing the XML report template
        2. Creating a binary report template
          1. Compiling a JRXML template programmatically
          2. Previewing the compiled report template
          3. Compiling a JRXML template through ANT
        3. Generating the report
          1. Viewing the report
          2. Displaying reports in a web browser
        4. Elements of a JRXML report template
          1. <property>
          2. <import>
          3. <template>
          4. <style>
          5. <subDataset>
          6. <parameter>
          7. <queryString>
          8. <field>
          9. <sortField>
          10. <variable>
          11. <filterExpression>
          12. <group>
            1. <background>
          13. <title>
          14. <pageHeader>
          15. <columnHeader>
          16. <detail>
          17. <columnFooter>
          18. <pageFooter>
            1. <lastPageFooter>
          19. <summary>
          20. <noData>
        5. Summary
      9. 4. Creating Dynamic Reports from Databases
        1. Database for our reports
        2. Generating database reports
          1. Embedding SQL queries into a report template
          2. Generating the report
          3. Modifying a report query through report parameters
          4. Database reporting through a datasource
          5. A comparison of database report methods
        3. Summary
      10. 5. Working with Other Datasources
        1. Empty datasources
        2. Map datasources
        3. Java objects as datasources
        4. TableModels as datasources
        5. XML datasources
        6. CSV datasources
        7. Custom datasources
          1. Writing a custom JRDataSource implementation
          2. Using the custom JRDataSource implementation
        8. Summary
      11. 6. Report Layout and Design
        1. Controlling report-wide layout properties
        2. Setting text properties
          1. Styles
            1. Reusing styles through style templates
            2. Setting text style for individual report elements
              1. Using markup to style text
                1. Styled text
                2. HTML
                3. Rich Text Format
        3. Setting a report's background
        4. Report expressions
        5. Adding multiple columns to a report
          1. Final notes about report columns
        6. Grouping report data
        7. Report variables
          1. Built-in report variables
        8. Stretching text fields to accommodate data
        9. Laying out report elements
          1. Setting the size and position of a report element
        10. Setting common element properties
        11. Hiding repeated values
        12. Subreports
        13. Summary
      12. 7. Adding Charts and Graphics to Reports
        1. Adding geometrical shapes to a report
          1. Adding lines to a report
          2. Adding rectangles to a report
          3. Adding ellipses to a report
        2. Adding images to a report
          1. Attributes of the <image> element
            1. evaluationTime
            2. evaluationGroup
            3. hAlign
            4. vAlign
            5. IsLazy
            6. isUsingCache
            7. onErrorType
        3. Adding charts to a report
          1. Attributes of the <chart> element
            1. customizerClass
            2. evaluationGroup
            3. evaluationTime
            4. isShowLegend
          2. Chart customization
          3. Chart datasets
            1. Attributes of the <dataset> element
              1. incrementType
              2. incrementGroup
              3. resetType
              4. resetGroup
          4. Plotting charts
            1. Attributes of the <plot> element
              1. backcolor
              2. backgroundAlpha
              3. foregroundAlpha
              4. orientation
          5. Pie charts
          6. Bar charts
          7. XY line charts
          8. Other types of charts
        4. Summary
      13. 8. Other JasperReports Features
        1. Report localization
        2. Scriptlets
        3. Crosstabs
          1. Crosstab subelements
            1. <columnGroup>
            2. <crosstabCell>
            3. <crosstabDataset>
            4. <crosstabParameter>
            5. <measure>
            6. <parametersMapExpression>
            7. <reportElement>
            8. <rowGroup>
            9. <whenNoDataCell>
        4. Subdatasets
        5. Adding hyperlinks and anchors to reports
          1. Turning chart items into hyperlinks
        6. Handling very large reports
        7. Summary
      14. 9. Exporting to Other Formats
        1. Exporting overview
        2. Exporting to PDF
        3. Exporting to RTF
        4. Exporting to ODT
        5. Exporting to Excel
        6. Exporting to HTML
        7. Exporting to XML
        8. Exporting to CSV
        9. Exporting to plain text
        10. Directing HTML reports to a browser
        11. Summary
      15. 10. Graphical Report Design with iReport
        1. Obtaining iReport
        2. Setting up iReport
        3. Creating a database report in record time
          1. Tweaking the generated report
        4. Creating a report from scratch
        5. Creating more elaborate reports
          1. Adding images to a report
          2. Adding multiple columns to a report
          3. Grouping report data
          4. Adding charts to a report
        6. Help and support
        7. Summary
      16. 11. Integrating JasperReports with Other Frameworks
        1. Integrating JasperReports with Hibernate
        2. Integrating JasperReports with JPA
        3. Integrating JasperReports with Spring
        4. Integrating JasperReports with JSF
        5. Integrating JasperReports with Struts
        6. Summary