table.EXPORT Function

Syntax

V Export(), Specify the required values in the Export dot variable, then use the following command:

Arguments

export.file

Type "C". The path and name of the file being created.

export.type

Type "N". A code that specifies the type of file being created.

Code
Details
FILE_FORMAT_ASCII

Number: 0 Description: Character-Separated ASCII Ext: .ASC

FILE_FORMAT_TABLE_ASCII

Number: 1 Description: Table ASCII Ext: .TBL

FILE_FORMAT_RICH_TEXT

Number: 2 Description: Rich Text Format (RTF) Ext: .RTF

FILE_FORMAT_EXCEL_VERSION_3

Number: 3 Description: Microsoft Excel, Version 3.0 Ext: .XLS

FILE_FORMAT_EXCEL_VERSION_4

Number: 4 Description: Microsoft Excel, Version 4.0 Ext: .XLS

FILE_FORMAT_123_VERSION_1

Number: 5 Description: Lotus 1-2-3, Version 1.0/1A Ext: .WKS

FILE_FORMAT_123_VERSION_2

Number: 6 Description: Lotus 1-2-3, Version 2.0 Ext: .WK1

FILE_FORMAT_123_VERSION_3

Number: 7 Description: Lotus 1-2-3, Version 3.0 Ext: .WK3

FILE_FORMAT_SYMPHONY_VERSION_1

Number: 8 Description: Lotus Symphony, Version 1.0 Ext: .WRK

FILE_FORMAT_SYMPHONY_VERSION_2

Number: 9 Description: Lotus Symphony, Version 2.0 Ext: .WR1

FILE_FORMAT_EXCEL_VERSION_2003

Number: 10 Description: Excel 2003 Ext: .XLS

FILE_FORMAT_EXCEL_VERSION_2007

Number: 11 Description: Excel 2007 Ext: .XLSX

export.names

Type "C". Specifies whether or not the field names should be exported along with the data.

TRUE (.T.) = export fieldnames
FALSE (.F.) = do not export fieldnames.
export.options

Type "C". The format for a character-separated ASCII file can vary. The default character-separated ASCII file is a comma-delimited file, with character fields in quotation marks, and a carriage return and line feed to separate records. If you want a different format for a character-separated ASCII file, you can adjust the export settings using one or more of the codes in the Options String:

Option Code
Function
Q

Quote character fields

L

Strip leading blanks from fields

T

Strip trailing blanks from fields

S

Suppress trailing separators

N

Preserve line breaks. Converts line breaks in exported memo fields to "\N". If this option is not specified, then line breaks are converted to spaces.

export.field_sep

Type "C". The Field Separator String and the Record Separator String parameters are also used with character-separated ASCII files to define how to denote the end of fields and records. These strings can include any characters, including the following special separator characters:

export.rec_sep

Type "C".

Carriage return and line feed combination
Carriage return
Line feed
Escape
Tab
export.fetch_parent

Type "L". Used only parent tables in sets.

TRUE (.T.) = When exporting data from a set with one-to-many links, only exports data from the parent table, and one-to-one links off the parent table.
FALSE (.F.) = Exports a parent record for each matching one-to-many child record.
export.fields

Type "N". Specifies how many fields are to be exported.

export.field1 ... export.fieldN

Type "C". The names of the fields to be exported.

Description

Export records in table to specified output file.

Discussion

The .EXPORT() method is a high-level utility function you use to export the records of a table or set to a file of a different format. Most parameters passed to export through the export function variable correspond directly with the prompts and options appearing on the Export Builder. You perform an Export operation on the table referenced by the object pointer, .

Example 

This script exports 4 fields from the Customer table to 'an ASCII table file. The export of field names is optional.

dim tbl as P
tbl = table.open("customers")
filename = ui_get_file("Destination File", "ASCII(*.ASC)", "customer.asc","N")
if filename = "" then
    end
end if
response = ui_get_radio("Export Fieldnames To File? ",1,"Yes","No")
if response = "Yes" then
    export_names = .T.
else
    export_names = .F.
end if
export.file = filename
export.type = 1
export.names = export_names
export.options = "Q"
export.field_sep = ","
export.rec_sep = ""
export.fields = 5
export.field1 = "cust_id"
export.field2 = "salutation"
export.field3 = "first_name"
export.field4 = "last_name"
export.field5 = "home_phone"
tbl.export()

See Also