Report.SaveAs Function
Syntax
Arguments
- Layout_Name
The name of a form, browse, label, letter, or report layout.
- Format
Optional. Default = "PDF". The options for Format are:
- Format
- File Type
- "PDF"
Adobe Acrobat PDF Format.
Note: The PDF Printer drivers may not create valid PDF files if you have created reports that use a "percentage" as the property for the Background Fill property an object. The work around is to only use the "Solid", "Translucent" or "Transparent" option for the Background, Fill property.
- "HTML"
Dynamic HTML
- "RTF"
Rich Text Format
- "TXT"
Plain Text Format
- "Excel"
Excel format
- "XPS"
XPS (XML Paper Specification, an alternative to PDF) Format
- Filter_Expression
Optional. Default = ".T." (All records). A character filter expression that evaluates to a logical value and selects records from the table.
- Order_Expression
Optional. Default = "" (natural record order). A character order expression that sorts selected records.
- Output_Filename
Optional. Default = Layout_Name in the same folder as the database. The path and name to give the saved file.
- Open_Application
.T. = After the layout is printed, Alpha Anywhere opens the file with its associated applications. For example, if you saved as a Rich Text Format file, and Word is the associated application for .RTF files on your computer, Alpha Anywhere will start Word and load the file.
.F. = Do not open associated application.
- PrintOptions
Optional. Default = null_value().
You can override the default system settings on a permanent basis. When you override the system defaults, your settings are stored in a text file in the Alpha Anywhere program folder. These files are named:
AlphaFivePrinterDriver_htm.PrintOptions
AlphaFivePrinterDriver_pdf.PrintOptions
AlphaFivePrinterDriver_rtf.PrintOptions
- Arguments
Optional. Default = null_value(). Arguments that retrieve value(s) from variable(s) or prompts for value(s) at runtime. Only applicable to SQL Reports. Refer to SQL::Arguments Object.
- Options
Optional. Default = null_value().
Sets filter (WHERE) and order (ORDER BY) expressions for a query against SQL table. A pointer dot variable with 2 elements. See examples below.
.filter = Adds to the WHERE clause in the underlying SQL expression.
.order = Replaces the ORDER BY clause in the underlying SQL expression.
Description
The Report.SaveAs() method prints Layout_Name to file in PDF, HTML, RTF, or TXT formats. If no format is specified, the PDF format is used.
If you specify an optional Filter_Expression, the only records matching the filter are printed. (In addition to the filter specified here, the layout may have a filter defined within the layout definition).
The layout is printed to Output_Filename. If Output_Filename is not specified, the layout is printed to a file with the same name as the Layout_Name in the same folder as the database.
This script saves a report as a RTF file.
filename = report.saveas("Invoice","rtf")
This script saves a report as a PDF file, then launches Adobe Acrobat to view it.
dim fn as C fn = report.saveas("Customer List", "PDF", "", "", "C:\test.pdf", .T.)
This script saves copy of the Invoice report with an argument. You can add as many arguments to the arguments collection as you want.
DIM myargs as SQL::arguments myargs.add("whatcity","London") report.saveas("report1", "", "", .f., .f., myargs)
In this example, let's assume that the report is based on a SQL data source. If you specify a filter and order in the method's Filter_expression and Order_expression arguments, the filter and order will be applied after the data has been extracted from the SQL table and moved into a temporary local .dbf table. This is very inefficient. It would be much better to do the filtering and ordering on the server before the data is moved to the local temporary table. This is done using the optional Options argument. For example:
DIM myargs as SQL::arguments dim options as p options.filter = "city = 'london' .and. title = 'manager'" options.order = "lastname" report.saveas("report1", "", "", .f., .f., myargs,options)
When you specify the filter in options.filter, you can use arguments. For example:
DIM myargs as SQL::arguments myargs.add("whatcity","london") myargs.add("whattitle","manager") dim options as p options.filter = "city = :whatcity .and. title = :whatmanager" options.order = "lastname" report.saveas("report1", "", "", .f., .f., myargs,options)
When the report is based on a SQL data source you can combine local filtering with filtering on the server. In the above two examples, the filtering was performed on the server. However you can do further filtering on the client if you specify the Filter_expression argument. You might take this approach if you want to do some pre-filtering on the server to limit the number of record that are moved to the temporary local .dbf table, but then use some user-designed function in your local filter.
PDF Print Options
The available PDF Print Options are listed below:
- Option
- (Type) Default Value
- PrintOptions.Concatenate
(L) .F.
- PrintOptions.HasWatermark
(L) .F.
- PrintOptions.MultilingualSupport
(L) .F.
- PrintOptions.LinearizeForWeb
(L) .F.
- PrintOptions.Colors2GrayScale
(L) .F.
- PrintOptions.ConvertHyperlinks
(L) .F.
- PrintOptions.WatermarkType
(C) "Text"
- PrintOptions.WatermarkText
(C) "D R A F T"
- PrintOptions.WatermarkFontName
(C) "Times New Roman"
- PrintOptions.WatermarkFontSize
(N) 172
- PrintOptions.WatermarkRotation
(N) 450
- PrintOptions.WatermarkColorHex
(C) upper("e8fed2")
- PrintOptions.WatermarkHorizPos
(N) 120
- PrintOptions.WatermarkVertPos
(N) 120
- PrintOptions.WatermarkOnTop
(L) .F.
- PrintOptions.WatermarkPDF
(C) ""
- PrintOptions.Encrypt
(L) .F.
- PrintOptions.OwnerPassword
(C) ""
- PrintOptions.UserPassword
(C) ""
- PrintOptions.CanPrint
(L) .T.
- PrintOptions.CanModifyDocument
(L) .T.
- PrintOptions.CanCopy
(L) .T.
- PrintOptions.CanAddNotes
(L) .T.
- PrintOptions.Use128BitKey
(L) .F.
- PrintOptions.EmbedFonts
(L) .F. (Note: If a font is protected, it can't be embedded; this is often the case for bar code fonts, such as Code39.)
- PrintOptions.JpegQuality
(C) "Low" (default), "Medium", "High", "No Compression"
RTF Print Options
The available RTF Print Options are listed below:
- Option
- (Type) Default Value
- PrintOptions.MultilingualSupport
(L) .F.
- PrintOptions.Colors2GrayScale
(L) .F.
- PrintOptions.RTFType
(C) "Formatted Text"
HTML Print Options
The available HTML Print Options are listed below:
- Option
- (Type) Default Value
- PrintOptions.MultilingualSupport
(L) .F.
- PrintOptions.Colors2GrayScale
(L) .F.
- PrintOptions.ConvertHyperlinks
(C) .F.
- PrintOptions.HTMType
(C) "Layers"
See Also