ExportReport()


" "

short ExportReport(long QueryID, short SourceType, BSTR Source, BSTR OutputFileName,
 short PageLength, short PageWidth, Boolean IncludeDateTime, Boolean IncludePageNumbers, 
 [VARIANT Format], [VARIANT UseFormPageSetup])

Description

This function creates a report for the query and writes it to a file. You define the formatting and layout for the report in a QMF form. The output file is an ASCII text file. A pair of carriage returns and line feed characters separates each line. A form-feed character separates each page. It is best to view the output file using a fixed-pitch font.

Parameters

Name Description
QueryID The ID of the query, as returned from InitializeQuery().
SourceType

Use one of the following to specify the source of the form:

0 (RSF_DEFAULT) -- Use the default form. FormName should be an empty string.
1 (RSF_DATABASE) -- Use a form from the database. Specify the form owner and name (Owner.Name) in the FormName parameter. To use a form located on a different database server, first use ExportForm() to export the form to a file and then specify a SourceType of RSF_FILE.
2 (RSF_FILE) -- Use the form contained in a file. Specify the filename in the FormName parameter.

Source The name (filename or Owner.Name) of the form that you want to use.
OutputFileName The name of the file to which you want to write the report.
PageLength The number of lines on each page of the report. A PageLength of negative one (-1) specifies continuous output. That means there are no page breaks unless the report is wider than PageWidth.
PageWidth The number of characters on each line of the report. A PageWidth of negative one (-1) specifies continuous output That means the lines are made just long enough to contain the full width of the report.
IncludeDateTime Non-zero specifies that the date and time are included at the bottom of each page. Zero specifies that the date and time are not included.
IncludePageNumbers Non-zero specifies that page numbers are included at the bottom of each page. Zero specifies that page numbers are not included.
Format

Optionally, specifies the format of the exported report.

  • If zero, the format is plain text, specifying that the output should be exactly as produced by the form (text or HTML, depending on the type of form)
  • If non-zero, the format is HTML, specifying that the output should be HTML.

With non-HTML forms, the output is converted to HTML by adding HTML tags at the beginning and end of the output. The default value is zero.

UseFormPageSetup Optionally, a non-zero for this parameter will ignore the parameters for PageLength, PageWidth, IncludeDateTime, and IncludePageNumbers in this API call. Instead, their values will be taken from the form.

Return Value

The return value will be zero if successful or non-zero if unsuccessful. If the return value is non-zero, you can call GetLastErrorString(), GetLastErrorType(), GetLastSQLCode(), GetLastSQLError(), or GetLastSQLState() to get additional error information.

Related Tasks

ExportForm()
PrintReport()
PrintReportEx()