Chapter 1 Introduction - dFPUG

Chapter 1 Introduction - dFPUG
Chapter 1: Introduction
1
Chapter 1
Introduction
Reports are key to a successful software application. It could even be argued that
both commercial and custom applications can be judged by how well they generate
output. After all, it doesn’t matter how efficiently the users can enter data, how much
information the system can store, or how many complicated calculations the system
can process if there’s no way to see the final outcome of all that work.
All too often, developers look down on the task of creating reports. In some shops, it’s even
considered a low-end task that’s given to junior developers. I passionately disagree with this
philosophy for several reasons.
Reports can be very high-profile and very important to the success of a company. The
executives of a company rely on the reports created by your application to make decisions. If
the reports you create are difficult to understand—or worse, inaccurate—bad decisions could
be made. These bad decisions could even lead to the downfall of the company.
Reports can be internal or external to a company. In other words, some reports are
only used within the company. However, in many other situations, reports are used outside
of the company and highly affect the business and sales. For example, a report can be a
sales proposal for an insurance company. Another example is a financial report given to a
company’s accountants or auditors. And another example is a 50-page report showing the
results of an inspection, for which the client charges big bucks. If these reports do not look
professional and are not accurate, the sales and repeat business of that company could be
greatly impacted. So considering how important these reports are, do you really want to put a
junior programmer on something this important?
Here’s another reason why you should consider reports a top priority in any application
you develop. Many times, the executives don’t use your application on a day-to-day basis.
They rely on their staff to do that. The only interaction the executives have with your
application is the printed reports that are handed to them on a daily, weekly, and monthly
basis. Therefore, the executive’s opinion about the software is heavily weighed by what he or
she sees. I don’t know about you, but that’s certainly enough to motivate me to provide topquality reports in all the applications I develop—especially because the executives are the ones
signing my check!
Overview of chapters
Throughout this book you’ll see two terms that need a little clarification up front—the Report
Designer and the Report Writer. The Report Designer is the tool used to create reports from
within Visual FoxPro. The Report Writer is the Visual FoxPro engine that runs the reports
you’ve created. These two terms are used quite often, so be sure you understand the difference
between them.
2
The Visual FoxPro Report Writer: Pushing it to the Limit and Beyond
Wizards
The next chapter, Chapter 2, “The Report Wizard,” is dedicated to explaining the Report
Wizards. By working through the quick and easy wizards, you’ll have a chance to learn about
some of the features of Visual FoxPro reports without having to get into the nitty-gritty. It’s a
great place to start so you’re not overwhelmed all at once.
The Report Wizard supplied with Visual FoxPro consists of two separate options: a Oneto-Many Report Wizard and a Single-Table Report Wizard. In addition to the Report Wizard,
there’s also a Label Wizard to assist you in creating labels.
The Report Designer
Chapters 3-8 are dedicated to teaching you how to create reports with the Visual FoxPro
Report Designer. You’ll start with Chapter 3, “Learning the Basics.” This chapter gets you
started using the Report Designer. From there, you move on to Chapter 4, “The Data Source,”
which explains where the data comes from and all the different options you have in making it
available for use in the report.
Next, you move on to Chapter 5, “Report Objects,” which is the meat and potatoes of
creating a report. This chapter explains how to put things on the report and move them around.
The next chapter, Chapter 6, “Adding Pizzazz to the Objects,” explains how to spiff up all the
things you put on the report in the previous chapter. This chapter is where you learn how to
add finesse to the report.
The next two chapters—Chapter 7, “Data Grouping,” and Chapter 8, “Report
Variables”—take you deeper into the Report Designer and teach you how to build the complex
reports needed to solve many reporting issues of today’s applications.
The “after life”
After you’ve learned how to create reports, Chapter 9, “Running Reports,” shows you how to
run the reports. This chapter also discusses distributing reports with your application and how
to give end users the ability to modify reports.
By the time you reach Chapter 10, “Solutions to Real-World Problems,” you’ll know just
about everything there is to know about the Report Writer. This chapter shows you how to pull
together all the things you’ve learned so you can solve some real-world reporting problems.
This is one of those chapters you’ll read and say to yourself, “Aha!”
The next chapter, Chapter 11, “Hacking the FRX,” dives into the inner workings of Visual
FoxPro reports. By learning how it works behind the scenes, you gain the advantage of being
able to manually manipulate reports into submission with brute force. Sometimes life is not
fair and you have to play hardball. By the time you’re done with this chapter, you’ll know how
to take the gloves off and rumble.
The Label Designer
Labels are nothing more than reports—on tiny paper. All you have to do is tell Visual FoxPro
what size the label is, and from there, it’s practically the same as designing a report. Chapter
12, “Labels,” walks you through creating labels and points out the few differences between
reports and labels.
Chapter 1: Introduction
3
The “other world”
The final chapter, Chapter 13, “Beyond the VFP Report Writer,” is dedicated to exposing you
to several different third-party tools and utilities. Some of them work with the Visual FoxPro
Report Writer, and some of them are used in place of the Visual FoxPro Report Writer. The
idea behind this chapter is to make you aware of other options so you can make the best
decision possible for all your reporting needs.
Parts of a report
Visual FoxPro reports are driven by a single table or cursor. For each record in the table
or cursor, one Detail band is generated on the report. You must have at least one record in
the table or cursor for the report to print. If no records exist in the table or cursor, no report
is printed.
Reports consist of several different parts, called bands. Some reports only contain a few
bands, and other, more complex reports contain all the possible bands. Figure 1 and
Figure 2 show a sample report with all the possible bands of a Visual FoxPro report.
This report, BANDS.FRX, is included in the source code available with this book. The
following list explains what those bands are and when they’re printed.
•
Title band: The Title band is printed once, and only once, at the beginning of the
report. It can appear on its own page, or other bands may immediately follow the
Title band. The Title band is an optional band you can add to a report.
•
Page Header band: The Page Header band appears at the top of each and every
page. This band is mandatory; however, you don’t have to put anything in it, and you
can define it with a zero height.
•
Column Header band: The Column Header band appears at the top of each and
every column set. A column set may consist of several columns of data for an
individual record, and some reports may have multiple column sets, such as 2-up
mailing labels. This band is automatically added to a report when the report is defined
as having multiple column sets. For reports with a single column set, this band does
not appear.
•
Group Header band: The Group Header band is added to a report whenever you
define a Data Grouping. It prints once at the beginning of a new Data Grouping, and
optionally, can be defined to repeat when the Data Group overflows to another page.
In an overflow situation, the Page Header band prints first, followed by the Column
Header band (if applicable), and then the Group Header band is printed. For each
Data Group defined on a report, one Group Header band is created. Therefore, it’s
possible to have multiple Group Header bands.
•
Detail band: The Detail band is printed once for each record in the table that drives
the report. You can, however, run a report with the summary option, which
suppresses the Detail band altogether.
•
Group Footer band: The Group Footer band is added to a report whenever you
define a Data Grouping. It prints once following the last Detail band of a particular
4
The Visual FoxPro Report Writer: Pushing it to the Limit and Beyond
Data Grouping. For each Data Group defined on a report, one Group Footer band is
created. Therefore, it’s possible to have multiple Group Footer bands.
•
Column Footer band: The Column Footer band appears at the bottom of each and
every column set. This band is automatically added to a report when the report is
defined as having multiple column sets. For reports having a single column set, this
band does not appear.
•
Page Footer band: The Page Footer band appears at the bottom of each and every
page. This band is mandatory; however, you don’t have to put anything in it, and you
can define it with a zero height.
•
Summary band: The Summary band prints only once after the final Detail band and
after any final Group Footer bands. Notice that the Summary band prints before the
Column Footer and Page Footer bands. You can also indicate that you’d rather have
the Summary band print on its own page after all other bands, in which case no Page
Header or Page Footer band prints with the Summary band.
General information
This book is based on Visual FoxPro 7.0, prior to the release of Service Pack 1. However, the
Report Writer hasn’t changed much over the years. In fact, there’s really not a whole lot of
difference between today’s Report Writer and the legacy FoxPro 2.x Report Writer. Much of
what you’ll learn in this book can be applied to older versions of the Report Writer.
Throughout this book, you’ll see the following icons used to point out special notes, tips,
and bug alerts.
This icon is used to point out information specific to FoxPro 2.x. It may
be a simple note telling you a feature didn’t exist in FoxPro 2.x, or it
may be a tip on how to simulate a missing feature. I also use this icon
to point out any major differences between the 2.x version and the
current version that might trip you up when following along.
icon is used to bring special information to your attention. Sometimes
it’s a tip to help you do something special. Other times it’s used to point out
‡ This
a gotcha so you can avoid it.
This icon is used to point out bugs that exist in the Visual FoxPro
Report Writer so you can work around them.
Chapter 1: Introduction
Figure 1. The first page of this report shows all but the Summary band.
5
6
The Visual FoxPro Report Writer: Pushing it to the Limit and Beyond
Figure 2. The last page of this report shows the Summary band. Also notice that no
Title band prints on this page.
Chapter 1: Introduction
7
Toolbars
Several toolbars are used in the Report Designer. Many of them are specific to a particular
chapter and are discussed when appropriate. However, there’s one general toolbar, the Report
Designer toolbar, which can be used to access many options and other toolbars used within the
VFP Report Designer.
You can display the Report Designer toolbar (shown in Figure 3) using one of two
methods. The first method is to select View | Toolbars… from the main VFP Menu bar. This
invokes the Toolbars dialog, from which you can select the Report Designer option and then
select the OK button. The second method is to right-click on an unused portion of any docked
toolbar and then select Report Designer.
Figure 3. Use the Report Designer toolbar to access many options and toolbars used
within the VFP Report Designer.
The Report Designer toolbar consists of the following five buttons, from left to right.
•
Data Grouping: This button is used to invoke the same Data Grouping dialog that
can also be invoked by selecting Report | Data Grouping… from the main VFP Menu
bar. This dialog is discussed in greater detail in Chapter 7, “Data Grouping.”
•
Data Environment: This button is used to invoke the same Data Environment that
can also be invoked by selecting View | Data Environment… from the main VFP
Menu bar. The Data Environment is discussed in greater detail in Chapter 4, “The
Data Source.”
•
Report Controls Toolbar: This button is used to toggle the same Report Controls
toolbar that can also be toggled by selecting View | Report Controls Toolbar from the
main VFP Menu bar. The Report Controls toolbar is discussed in greater detail in
Chapter 5, “Report Objects.”
•
Color Palette Toolbar: This button is used to toggle the same Color Palette toolbar
that can also be toggled by selecting View | Color Palette Toolbar from the main VFP
Menu bar. The Color Palette toolbar is discussed in greater detail in Chapter 6,
“Adding Pizzazz to the Objects.”
•
Layout Toolbar: This button is used to toggle the same Layout toolbar that can
also be toggled by selecting View | Layout Toolbar from the main VFP Menu bar.
The Layout toolbar is discussed in greater detail in Chapter 6, “Adding Pizzazz to
the Objects.”
8
The Visual FoxPro Report Writer: Pushing it to the Limit and Beyond
Enjoy!
I hope you enjoy this book and learn tons of new things. My goal in writing this book is to
teach you how to get the most out of the Visual FoxPro Report Writer so you can create
awesome reports for all your applications. I can’t stress enough how important reports are to
the usefulness and image of a final application.
Chapter 2: The Report Wizard
9
Chapter 2
The Report Wizard
Visual FoxPro provides several different wizards to help you create tables, forms,
queries, and so on. The great news for you is that an excellent Report Wizard is also
included in the product… at no extra charge! The wizard helps you create reports driven
from a single table as well as reports created from a parent-child set of tables. This
chapter walks you through the basic steps of using the Report Wizard to create your first
few reports.
The Report Wizard supplied with Visual FoxPro consists of two separate options: a One-toMany Report Wizard and a Single-Table Report Wizard. These tools assist you in creating
simple reports inside of VFP. You can use the wizard to create reports that are meant to be run
as-is, or you can use the wizard to create a report that you later edit with the VFP Report
Designer to add more features or complex options.
Starting the Report Wizard
The first step in using the Report Wizard is choosing which type of report you want to create.
Select Tools | Wizards | Report from the main VFP Menu bar to display the dialog shown in
Figure 1.
Figure 1. Use the Wizard Selection dialog to choose whether you want to create a
one-to-many report or a single-file report.
You can create two different types of reports with the Report Wizard. The first type is a
One-To-Many report. This type of report is driven from a parent-child set of tables. For
example, a Customer table (the parent) and an Invoice table (the child) are used to create a
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising