CrysDev: A Developer s Guide to Integrating Crystal Reports Craig Berntson Hentzenwerke Publishing
vii List of Chapters Chapter 1: Introducing Crystal Reports 1 Chapter 2: Touring Crystal Reports 17 Chapter 3: Creating your First Report 51 Chapter 4: Accessing Data 73 Chapter 5: Intermediate Reporting 105 Chapter 6: Advanced Reporting 133 Chapter 7: Subreports 149 Chapter 8: Using Formulas 163 Chapter 9: The RDC: Introduction, Printing, and Databases 189 Chapter 10: The RDC: Manipulating Data 225 Chapter 11: The RDC: Formatting the Report 245 Chapter 12: Previewing the Report at Runtime 283 Chapter 13: The Report Designer Control 303 Chapter 14: Exporting Reports 313 Chapter 15: Integrating COM Components 343 Chapter 16: Web Reporting 357 Chapter 17: Crystal Reports.NET 385 Chapter 18: Licensing and Distribution 401 Chapter 19: Crystal Reports Tools 417
ix Table of Contents Our Contract with You, The Reader Acknowledgements About the Author How to Download the Files iii xvii xix xxi Chapter 1: Introducing Crystal Reports 1 Crystal Reports versions 2 Installing Crystal Reports 2 What s changed in version 9 13 What s missing 13 What s new 14 Upcoming chapters 14 Summary 15 Chapter 2: Touring Crystal Reports 17 Report Experts 17 Data page 17 Links page 17 Fields page 18 Grouping page 18 Summaries page 18 Group Sorting page 18 Chart page 18 Record Selection page 18 Template page 18 Blank Reports 19 The Crystal Reports desktop 19 Menus 19 Toolbars 25 Status bar 28 Design page 28 Preview page 29 Report Sections 30 Section Expert 30 Formatting report objects 31 Common page 32 Border page 33 Font page 34 Paragraph page 35 Hyperlink page 36 Resizing and moving objects 36
x Using the mouse 37 Using the keyboard 37 The Object Size and Position window 37 Guidelines 37 Setting options 38 Application options 38 Report options 46 The report-processing model 47 Pre-pass 1 48 Pass 1 48 Pre-pass 2 48 Pass 2 48 Pass 3 48 Summary 48 Chapter 3: Creating Your First Report 51 Designing the report 51 Sketching the report 51 The report data 53 Your first report, step-by-step 53 Selecting the data source 54 Adding data fields to the report 55 Adding a calculated field 58 Grouping and group totals 60 Formatting the report 64 Adding the page header 66 Charting made easy 68 Summary 71 Chapter 4: Accessing Data 73 Using the Database Expert 73 Creating a new connection 74 Selecting database objects 87 Linking tables 89 Field definitions files 92 Creating a field definition file 92 Using a field definition file 94 Working with images 95 Images in the database 96 Adding a watermark 96 Limiting records selected 97 The Select Expert 98 Miscellaneous data functions 100 Set Database Location 100 LogOn or Off Server 100 Show SQL Query 101
xi Perform Grouping on Server 102 Report Bursting Indexes 102 Summary 103 Chapter 5: Intermediate Reporting 105 Understanding the Crystal Repository 105 Adding objects to the repository 106 Using repository objects in a report 107 Updating objects in the repository 107 Sorting 108 Groups 108 Drill-down 113 Hierarchical groups 113 Summaries 114 Subtotals and grand totals 114 Running totals 116 Cross-tabs 117 Charts 123 Basic charting 124 Advanced charting 128 Maps 129 The Data tab 129 The Type tab 130 The Text tab 131 Summary 132 Chapter 6: Advanced Reporting 133 Report parameters 133 Multiple-value parameters 135 Default values 137 Report alerts 139 OLE objects 142 Embedded fields 144 Hierarchical reports 146 Summary 147 Chapter 7: Subreports 149 Inserting a subreport 149 Unlinked subreports 150 Linked subreports 157 On-demand subreports 159 Updating subreports 160 Summary 162
xii Chapter 8: Using Formulas 163 The Formula Editor 165 The General toolbar 167 The Workshop toolbar 167 The Custom Function toolbar 168 The Workshop Tree 168 The Editor toolbar 169 Understanding formulas 171 Comments 171 Data types 171 Variables 174 Fields 174 Operators 175 Functions 182 Custom functions 183 The Formula Extractor 185 The Formula Expert 186 Summary 187 Chapter 9: The RDC: Introduction, Printing, and Databases 189 Understanding the Report Design Component 190 Getting started with RDC programming 191 Registering the runtime component 192 Working with collections 194 The Application object 195 The Report object 199 The Database object 206 Working with tables 207 Passing stored procedure parameters 209 The DatabaseTable object 209 The ConnectionProperties object 211 Working with the ConnectionProperties object 211 Getting connection property information 213 Working with fields 214 Linking tables 215 Connecting to data some examples 217 Logging on and off a server database 217 Connecting to ADO 218 Connecting through an ODBC connection 219 Connecting to XML 220 Connecting to file-based data 220 You connected to your data, now what? 220 Summary 223
xiii Chapter 10: The RDC: Manipulating Data 225 Sorting 225 Working with Groups 226 Summary Fields 228 Running Totals 231 SQL Expressions 234 Formula Fields 236 Parameter Fields 237 Report Alerts 241 Summary 243 Chapter 11: The RDC: Formatting the Report 245 Working with Areas 245 Condition Formulas 248 Working with Sections 249 The ReportObject object 251 TextObject object 251 Field elements 253 LineObject object 257 BoxObject object 257 FieldObject object 258 Picture fields 263 Special variable fields 263 Summary fields 265 BlobFieldObject object 265 Crosstabs 267 GraphObject object 269 The FieldDefinitions collection 275 MapObject object 276 OLEObject 276 OLAPGridObject object 278 The ObjectSummaryFieldDefinitions collection 279 Unbound fields 279 Subreports 280 Summary 282 Chapter 12: Previewing the Report at Runtime 283 Registering the control 283 Creating a preview form 284 Methods of the Viewer Control 291 Showing the report 291 Retrieving information 293
xiv Events 294 Report objects events 295 Drill events 297 Toolbar objects events 297 Miscellaneous events 299 Summary 301 Chapter 13: The Report Designer Control 303 Registering the Control 303 Creating a design form 304 Working with the designer 310 Providing Help 311 Using the Designer Control 312 Summary 312 Chapter 14: Exporting Reports 313 Programmatic exports 314 Exporting to files 318 Adobe Acrobat (PDF) 318 Microsoft Word 319 Microsoft Excel 320 Rich Text Format (RTF) 323 HTML 325 XML 328 Comma Separated Values (CSV) 332 Tab-Separated Text 334 Text 335 Report Definition 337 Exporting to an application 338 Exporting to MAPI 338 Exporting to ODBC 339 Summary 341 Chapter 15: Integrating COM Components 343 Formulas revisited 343 Events 344 Report events 344 Section events 352 Separate image files 354 Report variables 355 Summary 356
xv Chapter 16: Web Reporting 357 Report design revisited 357 Embedded hyperlinks 357 Cascading style sheets 359 Navigation 360 Report Parts 362 Working with ASP 364 Page rendering objects 366 Customizing the Viewer 371 The Report Application Server 372 Customizing the RAS 379 The RAS SDK 382 Summary 384 Chapter 17: Crystal Reports.NET 385 Windows-based applications 385 Web-based applications 388 The Crystal Reports.NET designer 393 Connecting to ADO.NET 394 XML web services 396 Publishing a web service 396 Consuming a web service 397 The CrystalDecisions namespaces 398 Summary 399 Chapter 18: Licensing and Distribution 401 Distribution 401 RDC distribution 401 Web reporting 414.NET distribution 414 Licensing 414 The License Manager 415 Summary 416 Chapter 19: Crystal Reports Tools 417 Documentation files 417 The Crystal Decisions web site 418 Hot fixes and service packs 419 Utilities 420 Support forums 421 Summary 421