BIRT: A Field Guide to Reporting Second Edition the eclipse series SERIES EDITORS Erich Gamma ■ Lee Nackman ■ John Wiegand Eclipse is a universal tool platform, an open extensible integrated development environment (IDE) for anything and nothing in particular Eclipse represents one of the most exciting initiatives hatched from the world of application development in a long time, and it has the considerable support of the leading companies and organizations in the technology sector Eclipse is gaining widespread acceptance in both the commercial and academic arenas The Eclipse Series from Addison-Wesley is the definitive series of books dedicated to the Eclipse platform Books in the series promise to bring you the key technical information you need to analyze Eclipse, high-quality insight into this powerful technology, and the practical advice you need to build tools to support this evolutionary Open Source platform Leading experts Erich Gamma, Lee Nackman, and John Wiegand are the series editors Titles in the Eclipse Series John Arthorne and Chris Laffra Official Eclipse 3.0 FAQs 0-321-26838-5 David Carlson Eclipse Distilled 0-321-28815-7 Eric Clayberg and Dan Rubel Eclipse: Building Commercial-Quality Plug-Ins, Second Edition 0-321-42672-X Adrian Colyer, Andy Clement, George Harley, and Matthew Webster Eclipse AspectJ: Aspect-Oriented Programming with AspectJ and the Eclipse AspectJ Development Tools 0-321-24587-3 Naci Dai, Lawrence Mandel, and Arthur Ryman Eclipse Web Tools Platform: Developing Java™ Web Applications 0-321-39685-5 Erich Gamma and Kent Beck Contributing to Eclipse: Principles, Patterns, and Plug-Ins 0-321-20575-8 Jeff McAffer and Jean-Michel Lemieux Eclipse Rich Client Platform: Designing, Coding, and Packaging Java™ Applications 0-321-33461-2 Diana Peh, Alethea Hannemann, Paul Reeves, and Nola Hague BIRT: A Field Guide to Reporting 0-321-44259-8 Dave Steinberg, Frank Budinsky, Marcelo Paternostro, Ed Merks EMF: Eclipse Modeling Framework 0-321-33188-5 Jason Weathersby, Don French,Tom Bondur, Jane Tatchell, and Iana Chatalbasheva Integrating and Extending BIRT 0-321-44385-3 For more information on books in this series visit www.awprofessional.com/series/eclipse BIRT: A Field Guide to Reporting Second Edition Diana Peh • Nola Hague • Jane Tatchell Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests For more information, please contact: U.S Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States please contact: International Sales international@pearsoned.com Visit us on the Web: informit.com/aw Copyright© 2008 by Actuate Corporation All rights reserved This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise For information regarding permissions, write to: Pearson Education, Inc Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax: (617) 671-3447 ISBN-13: 978-0-321-58027-6 ISBN-10: 0-321-58027-3 Text printed in the United States at OPM in Laflin, Pennsylvania First printing, June 2008 Co nten ts Foreword xix Preface xxiii About this book xxiii Who should read this book xxiii Contents of this book xxiv Typographical conventions xxviii Acknowledgments xxix Part I Installing BIRT Chapter Prerequisites for BIRT Downloading Eclipse BIRT components BIRT Report Designer software requirements About types of BIRT builds Chapter Installing a BIRT Report Designer Installing BIRT Report Designer Full Eclipse Install Installing BIRT RCP Report Designer 10 Troubleshooting installation problems 11 Avoiding cache conflicts after you install a BIRT report designer 12 Specifying a Java Virtual Machine when starting BIRT report designer 12 Installing a language pack 13 Updating a BIRT Report Designer installation 14 Updating BIRT RCP Report Designer installation 15 Part II Getting Started 17 Chapter Learning the Basics 19 About BIRT reports 19 Overview of the report design process 19 v About the report design environment Starting BIRT Report Designer Report design views Report editor Palette Data Explorer Library Explorer Property Editor Navigator Outline Problems Report design files Report output formats Previewing a report Viewing sample reports Tutorial 1: Building a simple listing report Task 1: Create a new project Task 2: Create a new report Task 3: Build a data source Task 4: Build a data set Task 5: Lay out the report Task 6: Sort the data Task 7: Format the report Edit the column headings Format the column headings Display first and last names on the same line Increase the space between rows Task 8: Create a report title Next steps Chapter Planning Your Report 53 Identifying the content of the report Determining how the report will be viewed Considering international reporting requirements Deciding the layout and format of the report Drawing a mock-up Considering reuse of report components Managing report design resources Deciding how the report will be deployed Part III 54 55 56 56 58 58 59 59 Accessing and Binding Data 61 Chapter Connecting to a Data Source 63 About BIRT data sources Accessing data using JDBC Creating a JDBC data source Managing JDBC drivers vi 21 22 24 25 26 26 26 26 26 26 26 27 28 29 30 32 33 34 36 37 39 42 44 44 45 47 49 50 52 Contents 63 64 64 66 Adding a JDBC driver 67 Deleting a JDBC driver 69 Restoring a JDBC driver 69 Accessing data in a text file 70 Text file structure 70 Text file data types 71 Creating a flat file data source 72 Accessing data in an XML file 73 Accessing a web service 74 Creating reusable data sources 76 Creating a connection profile 77 Using a connection profile 79 Setting connection properties when a report runs 81 Setting the folder path for text files at run time 82 Setting the database user name and password at run time 84 Troubleshooting data source problems 87 Chapter Retrieving Data 89 About data sets 89 Selecting data 90 Using a SQL query to retrieve data from a JDBC data source 90 Writing a basic SQL query 90 Combining data from multiple tables 91 Using a stored procedure to retrieve data from a JDBC data source 95 Specifying what data to retrieve from a text file 97 Specifying what data to retrieve from an XML data source 98 Specifying what data to retrieve from a web service 102 Viewing and changing output columns 110 Adding a computed field to a data set 111 Joining data sets 113 Verifying the data returned by a data set 115 Specifying the data to retrieve at run time 116 About the Query Text property 116 Specifying a value for the Query Text property 117 Chapter Binding Data 119 Understanding column bindings 119 Descriptive names 121 Dynamic updates of calculated data 121 Creating column bindings 122 Editing and deleting column bindings 124 Copying data elements 125 More about column-binding expressions 126 Part IV Chapter Designing Reports 129 Laying Out a Report 131 Contents vii Understanding the layout model About the report layout elements Overview of the layout process Creating the sections of a report Organizing elements in a grid Adding rows and columns Deleting rows and columns Organizing elements in a table Deciding where to place elements in a table Binding a table to a data set Adjusting table rows and columns Organizing elements in a list Deciding where to place elements in a list Binding a list to a data set Placing report elements Placing report elements side by side Inserting a data set field Inserting a computed field Inserting an image Resizing an image Providing a text alternative Chapter 131 133 133 134 134 135 136 136 137 138 140 140 141 142 142 143 144 144 146 152 152 Displaying Text 153 Types of textual elements Deciding which textual element to use Using a dynamic text element Using a label element Using a text element Applying multiple style formats in a text element Combining a JavaScript expression with static text in a text element Combining a value from a data set field with static text in a text element Formatting dynamic values in a text element Displaying data set field values that are stored as HTML text 153 155 158 159 160 160 161 162 162 163 Chapter 10 Formatting Report Content 165 Formatting data Formatting numeric data Formatting numeric data in a data element Formatting numeric data in a text element Formatting date-and-time data Formatting date-and-time data in a data element Formatting date-and-time data in a text element Formatting string data Formatting text in a data element Formatting text data in a text element Formatting with styles Creating styles Reusing CSS styles viii Contents 166 167 167 168 168 169 170 170 170 172 172 172 177 Importing styles 177 Linking a CSS file 178 Applying a style 182 Modifying a style 182 Deleting a style 182 Formatting data based on conditions 182 Creating a formatting rule 183 Modifying a formatting rule 185 Creating multiple formatting rules 186 Deleting a formatting rule 187 Alternating row colors in a table 187 Specifying alignment of content in a table or grid 190 Aligning text horizontally 190 Aligning content vertically 191 Adjusting the spacing of content in a report 191 Resizing rows and columns 194 Resizing margins, borders, and padding of elements 195 Specifying fixed layout for HTML output 196 Displaying content across multiple columns 199 Specifying alternate values for display 201 Hiding elements based on conditions 203 Chapter 11 Sorting and Grouping Data 207 Sorting data 208 Ways to sort data 209 Sorting string data case-insensitively 211 Grouping data 212 Grouping data by intervals 216 Grouping string data by intervals 217 Grouping numeric data by intervals 218 Grouping date-and-time data by intervals 219 Sorting data at the group level 220 Creating multiple groups 224 Changing the order of groups 226 Adding group headings 227 Inserting group header rows 228 Displaying group headings in the detail row 229 Specifying expressions for group headings 231 Tutorial 2: Grouping report data 231 Task 1: Open the report design 232 Task 2: Save the report as a new file 233 Task 3: Add the credit limit field to the data set 233 Task 4: Add credit limit data to the report 234 Task 5: Group customer data by credit limit 235 Task 6: Display credit limit ranges in the group header 238 Task 7: Display aggregate information 239 Display the number of customers in each group 239 Display the number of customers in the report 242 Contents ix ... to link data to a chart, use the chart builder to filter data, plot the data by defining x-and y-axes, and sort and group data You also learn how to create a combination chart and a meter chart... row-and-column matrix that looks similar to a spreadsheet This chapter explains how to prepare data for a cross tab and how to build a cross tab The chapter also includes a tutorial that provides an example... necessary data bindings A data binding defines an expression that specifies what data to display This chapter explains how to create and manage data bindings Part IV, Designing Reports Part IV