# Utilities

*TOOLS/QRYEXPORT | Create an Export File Based on Query Definition

## Invocation

CALL "*tools/qryexport", queryName$, queryLib$, exportfile$ [, queryopts$, show_flg$]

Where:

queryName$ | Required | Input | Name of the query to use to generate the export file.
queryLib$ | Required | Input | Library where the query is defined.
exportfile$ | Required | Input | Name of the export file to write to. (To write to a client machine, include the [lcl] prefix in the file name.) Export file types are determined by their file extension. Supported types include:
.csv | Comma-separated
.slk | Symbolic link
.txt | Tab delimited
.xml | Microsoft XML
queryopts$ | Optional | Input | Flag to determine additional content to add to the file. Possible values are:
"" Null | (Default) No additional content.
H | Show hidden columns in the query definition. (By default, hidden columns are excluded from the file.)
show_flg$ | Optional | Input | Flags to determine interactive behavior at run time. Possible values are:
"" Null | (Default) The export file is generated silently.
D | The generated file is displayed using the default app (e.g. Excel).
E | Error message for errors that occur during file generation are displayed in message boxes.
P | A progress bar is displayed while the file is generated.
* | All of the above.
#### Note: Any combination of D, E and P is acceptable.

## Description

This utility is a CALLed program that exports data to a spreadsheet-supported file based on a query definition. The file has of a header record consisting of the column headings defined in the query, followed by data records of the resulting query data set. By default, columns defined as hidden in the query definition are excluded but can be included by setting the queryopts$ optional parameter to "H".

The file types that are supported are comma separated (.csv), tab delimited (.txt), symbolic link (.slk) and Microsoft XML (.xml). The type of file is determined by its file extension. Unsupported file extensions will result in Error #17: Invalid file type or contents.

#### Note:
This program will EXIT ERR if an error is encountered.

(The QryExport utility was added in PxPlus 2024.)