devxlogo

Printing a Report to a RTF or HTML File

Printing a Report to a RTF or HTML File

Question:
Can you create a HTML or RTF file in Visual FoxPro? If so, how?

Answer:
VFP comes with a program (called GENHTML.PRG) that can generate HTML from many different sources: tables, reports, menus, forms, etc.

VFP keeps the name and path of this program in a system memory variable called _GENHTML. You can view the code by executing the following command from the command window:
MODIFY COMMAND (_GENHTML)

Here is the list of parameters for _GENHTML:

  • cOutFile: Specifies the name of the output .HTM file. If a filename without an extension is specified, .HTM is used.
  • vSource: Specifies the source filename, alias, or object (can pass the name of a table, screen, report, menu, or an object).
  • nShow:
    • 0/.F./Empty = Generate output file only
    • 1 = Create output file and view generated file
    • 2 = Create output file and show generated file in Internet Explorer
    • 3 = Create output file and show based on Save As HTML dialog selection
    • 4 = Create PUBLIC _oHTML object and generate file
    • 5 = Create PUBLIC _oHTML object without generating file
  • vIELink: Specifies a link to Internet Explorer object or Web browser control:
    • F./Empty = No link is created
    • .T. = Automatically creates instance of Internet Explorer
  • cStyle: Specifies Style ID reference in GenHTML.dbf.
  • cScope: Specifies the scope of scan by setting .cScope.
  • cHTMLClass: Specifies the class and, optionally, the class library and module that is instantiated for HTML object.

So to send a report named MyReport.FRX to an .HTM file named MyHTML.HTM and show it in Internet Explorer, execute the following command:

DO (_GENHTML) WITH "MyHTML.HTM","MyReport.FRX",2

The cStyle parameter allows you to apply style sheets to the generated text.

See also  Who are the Modern GPU Cloud Providers?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist