Friday, May 6, 2005
From the Edge: Printing Report as Text Document
Section: Reports
Chapter: Running R:BASE Your Way!
Platform: R:BASE 7.x and V-8 "Turbo" for Windows
Builds: 7.1.81.30505 or higher
R:BASE 7.x and V-8 "Turbo" support the following Report Output
OPTIONs:
. SCREEN
. PRINTER
. Adobe Acrobat Document (.PDF)
. Bitmap File (.BMP)
. Enhanced Metafile (.EMF)
. Excel Document (.XLS)
. GIF Image File (.GIF)
. HTML Document (.HTM)
. JPEG Image File (.JPG)
. Report Emulation Text File (.TXT)
. RTF Document (.RTF)
. Text File (.TXT)
. TIFF Image File (.TIF)
. Windows Metafile (.WMF)
As you can see by the file type and their extensions, the
"Report Emulation Text File" and "Text File" both have the
same .TXT extensions. So, what is the difference between
Report Emulation Text File and Text File?
The "Report Emulation Text File" allows you to print the
exact report as plain readable text including all bands,
such as Report Header, Page Header, Break Headers, Break
Footers, Page Footers and Report Footers, if any. On the
other hand, the "Text File" allows you to define a particular
band to print the data as Comma Delimited, Tab Delimited or
Fixed Length file. This is the perfect option to export
selective and/or summarized data used in a report band.
Syntax to PRINT the report as Report Emulation Text File:
PRINT reportname OPTION ETXT|FILENAME filename.txt|OPEN ON
Example:
CONNECT ConComp
PRINT ColumnarReport OPTION ETXT|FILENAME ColumnarReport.TXT|OPEN ON
Syntax to PRINT the report as Text File:
PRINT reportname OPTION TXT|FILENAME filename.txt|OPEN ON
Example:
CONNECT ConComp
PRINT ColumnarReport OPTION TXT|FILENAME ColumnarReport.TXT|OPEN ON
In order to PRINT the report as "Text File", first you need to
identify the "Band" to be included for the text file. If a user
attempts to PRINT the report as Text File (OPTION TXT) without
first having defined the Text File Setup in Report Designer, the
program will return an -ERROR- message. The same rule applies when
printing the report as Text File using the Print to a File option
from the Database Explorer.
Here's how to use the "Print to Text File Setup ..." :
01. Report Designer | File | Print to Text File Setup...
Notice the following options:
File Name:
File Type:
Bands:
Available Controls, Select Controls, Save Length
02. Select the File Name: (Click on [File] Button
Example: TestFile.TXT
03. Select File Type: Fixed Length
Available Options: Comma Delimited, Tab Delimited, Fixed Length
04. Select Band: Detail
05. Select Column(s) from the list of Available Controls
06. Customize each selected column and make sure to define Length,
if Fixed Length file type is selected. Click [Save Length]
button to save the length for selected column.
This step is not required if the Comma Delimited or Tab Delimited
option is selected.
07. Click [OK] button to save these settings when using Print to
Text File.
Along with other report settings, these settings will be saved
with the report.
Repeat step 06 to define the length for each column, if necessary.
All of these property settings prepare the report to be printed
to a text file.
08. While still in Report Designer, Select Report Preview.
Click on "Printer" icon
Check "Print to File" Option
You'll notice the type "Text File" and the Text File Name as
defined in Step 02 above.
The print dialog will then display a Print to File CheckBox and
File... button (so the user can change the file name specified
in the Text File Name property).
Click [OK] button to print the file as TEXT.
09. Close the Report Designer or simply Click on R> Prompt icon from
the Tool Bar.
10. At the R> Prompt, type:
DIR TestFile.TXT
Notice the size of TestFile.TXT file.
To view the entire text file, type:
LAUNCH TestFile.TXT
Take a look at the File using MS NotePad.
11. To automate the entire printing process, use:
PRINT ReportName WHERE ... ORDER BY ... OPTION TXT
This will allow the report to print to a text file without user
intervention.
The report will print to the filename specified in the Text File
Name property, but the Print Dialog will not display the Print
to File CheckBox or File... button.
For a PDF version of this document, please visit:
From The Edge: http://www.razzak.com/fte
(Powered by R:WEB Suite)
Enjoy and make sure to have fun!
Very Best R:egards,
Razzak.