共用方式為


How to: Generate Output for Reports

You can generate output reports and labels by performing the following:

  • Printing Reports

  • Sending Reports to the Screen

  • Sending Reports to a File

  • Saving Reports as HTML

Note

Some of the actions discussed in this topic have different results, depending on the setting of REPORTBEHAVIOR. When you use the command SET REPORTBEHAVIOR 90, Visual FoxPro uses a ReportListener object to generate your results through GDI+ instead of GDI. For more information, see SET REPORTBEHAVIOR Command.

Printing Reports

You can change printer settings before you print the report or print the report programmatically.

To print a report or label

  1. Choose the Print… option on the File menu, and select Report or Label as the Type of output to print in the Print dialog box. Click the ellipsis (...) button to choose the report or label file (.frx or .lbx) to print. Alternatively, open the report or label in the appropriate designer and click Run Report on the Report menu.

  2. The Print dialog box opens so you can make changes to printer settings.

  3. In the Print dialog box, click Print.

To print reports and labels programmatically

  • Option 1: Use the REPORT FORM or LABEL command with the TO PRINTER clause.

  • Option 2: Use REPORT FORM or LABEL command with the clause OBJECT TYPE 0.

  • Option 3: Use REPORT FORM or LABEL command with the clause OBJECT<oReference>, where <oReference> is an instance of a ReportListener-derived class with its ListenerType property value set to 0. For more information, see ListenerType Property.

When using these commands, you can also display or suppress display of the Print dialog box and print status message. You can set many other options, such as which records to print.

For more information, see REPORT FORM Command or LABEL Command.

Sending Reports to the Screen

You can send report or label output to the main Visual FoxPro screen or currently active window.

To send report or label output to the screen or currently active window

  • When using the REPORT FORM and LABEL commands, omit all clauses that direct output other than to the screen or currently active window.

Tip

Visual FoxPro 9's GDI+ reporting rendering mechanism does not echo the contents of the report or label directly to the current output window, so ensure that SET REPORTBEHAVIOR is set to 80 when you want this result. Alternatively, you can use a ReportListener object to draw the report contents to a shape or container on _SCREEN, or in any Visual FoxPro form. Creating a Custom Preview Container for an example performing this task with minimal code.

Sending Reports to a File

Sending reports to a file makes it possible for you to create an electronic version of the report and print them as a batch file on your printer at a later time.

To send a report to a file

  • Use the REPORT FORM or LABEL command and include the TO FILE clause.

For more information, see REPORT FORM Command or LABEL Command.

Saving Reports as HTML

You can save a report in Hypertext Markup Language (HTML) format.

Tip

You must first save the report and any changes to disk before saving it as HTML.

To save a report as HTML

  1. Open the report or label in the appropriate designer.

  2. On the File menu, click Save As HTML.

  3. In the Save As HTML dialog box, select the options you want.

  4. To save the HTML (.htm) file with a different name, click the ellipsis (...) button to open the Save As dialog box so you can specify a different name. When you are finished in the Save As dialog box, click Save.

  5. In the Save As HTML dialog box, click OK.

For more information, see Save As HTML Dialog Box.

Tip

Without opening the Report or Label Designer, you can also generate HTML from your report form by using the command REPORT FORM <your filename> OBJECT TYPE 5. This command uses an instance of the ReportListener HTML Foundation Class to generate your HTML file; the Save As HTML dialog box invokes the same object to perform its task.

See Also

Tasks

How to: Preview Reports
How to: Control Record Selection in Report Output

Reference

ReportListener Object

Other Resources

Running Reports