IMPORT Command

Imports data from an external file format to create a new Visual FoxPro table.

IMPORT FROM FileName   [DATABASE DatabaseName [NAME LongTableName]]
   [TYPE] FW2 | MOD | PDOX | RPD | WK1    | WK3 | WKS | WR1 | WRK | XLS
    | XL5 [SHEET cSheetName]   | XL8 [SHEET cSheetName]   [AS nCodePage]

Parameters

  • FileName
    Specifies the name of the file from which to import data. If you don't include an extension with the file name, the default extension for the specified file type is assumed.

  • DATABASE DatabaseName
    Specifies a database to which the new table is added.

  • NAME LongTableName
    Specifies a long name for the new table. Long names can contain up to 128 characters and can be used in place of short file names in the database.

  • TYPE
    The keyword TYPE is optional, but you must include one of the following file types:

    File type Description
    FW2 Include FW2 to import FW2 files, created by Framework II.
    MOD Include MOD to import MOD files, created by Microsoft Multiplan version 4.1.
    PDOX Include PDOX to import Paradox files. Database files in Paradox versions 3.5 and 4.0 by Borland can be imported by including the PDOX option.
    RPD Include RPD to import RPD files, created by RapidFile.
    WK1 | WK3 | WKS Include WK1 to import data from a Lotus 1-2-3 spreadsheet. Columns from the spreadsheet become fields in the table and the spreadsheet rows become records in the table. A WK1 extension is assigned to spreadsheets created in Lotus 1-2-3 revision 2.x; a WK3 extension is assigned to spreadsheets created in Lotus 1-2-3 revision 3.x; and a .wks extension is assigned to spreadsheets created in Lotus 1-2-3 revision 1-A.
    WR1 | WRK Include WR1 to import data from a Lotus Symphony spreadsheet. Columns from the spreadsheet become fields in the table and the spreadsheet rows become records in the table. A WR1 extension is assigned to spreadsheets created in Symphony version 1.10, and a .wrk extension is assigned to spreadsheets created in Symphony version 1.1.
    XLS Include XLS to import data from Microsoft Excel worksheets versions 2.0, 3.0, and 4.0. Columns from the worksheet become fields in the table and the worksheet rows become records in the table. Worksheet files created in Microsoft Excel have an .xls extension.
    XL5 [SHEET cSheetName] Include XL5 to import data from Microsoft Excel version 5.0. Columns from the worksheet become fields in the table and the worksheet rows become records in the table. Worksheet files created in Microsoft Excel have an .xls extension.

    If you omit the SHEET clause, the data in Sheet1 is imported. To import data from a specific sheet, include the SHEET keyword and specify the sheet name with cSheetName.

    XL8 [SHEET cSheetName] Include XL8 to import data from Microsoft Excel 97. Columns from the worksheet become fields in the table and the worksheet rows become records in the table. Worksheet files created in Microsoft Excel have an .xls extension.

    If you omit the SHEET clause, the data in Sheet1 is imported. To import data from a specific sheet, include the SHEET keyword and specify the sheet name with cSheetName.

  • AS nCodePage
    Specifies the code page of the imported file. Visual FoxPro copies the contents of the imported file and, as it copies the data, automatically converts the data to the current Visual FoxPro code page.

    If you specify a value for nCodePage that is not supported, Visual FoxPro displays an error message. You can use GETCP( ) for nCodePage to display the Code Page dialog box, allowing you to specify a code page for the imported file.

    If you omit AS nCodePage and Visual FoxPro cannot determine the code page of the imported file, Visual FoxPro copies the contents of the imported file and, as it copies the data, automatically converts the data to the current Visual FoxPro code page. If you omit AS nCodePage and Visual FoxPro can determine the code page of the imported file, Visual FoxPro automatically converts the data in the imported file from the data's code page to the current Visual FoxPro code page. Use CPCURRENT( ) to determine the current Visual FoxPro code page.

    If nCodePage is 0, Visual FoxPro assumes the code page of the imported file is the same as the current Visual FoxPro code page and no code page conversion occurs.

Remarks

Most software packages store their data in file formats that cannot be opened directly in Visual FoxPro. IMPORT creates a new Visual FoxPro table from data stored in file formats that Visual FoxPro cannot directly read.

A new table is created with the same name as the file from which the data is imported. A .dbf extension is assigned to the newly created table.

See Also

APPEND FROM | COPY TO | EXPORT | GETCP( )