Article ID: 176894 - Last Review: June 29, 2004 - Revision: 2.2

How To Append Data from a Single Sheet of an Excel Workbook

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q176894
Expand all | Collapse all

SUMMARY

The undocumented SHEET clause of the APPEND FROM command allows you to import records from a specific sheet of a Microsoft Excel 5.0 workbook.

MORE INFORMATION

The following example shows how to import the data in a second sheet named sheet2 from an Excel workbook into a Visual FoxPro 3.0x or 5.0x table.

  1. Start Microsoft Excel version 5.0 or later.
  2. Create a new workbook.
  3. In Sheet1 of the workbook, type the following in separate cells, A1 through C1:
          The     first     sheet
    							
  4. Click on Sheet2 of the workbook and type the following data in the cells of sheet2 beginning in cell A1 and ending in cell C3:
          The     first     record
          The     second    record
          The     third     record
    							
    When this data is appended into the FoxPro table, it creates three records containing three fields.
  5. Save the workbook in the Visual FoxPro home folder as a Microsoft Excel 5.0 Workbook (.xls) named Zbook1.xls and close Excel.
  6. Start Visual FoxPro 3.0x or 5.0x and create a table using the following command:
          CREATE TABLE zjunk (first c(10), second c(10), third c(10))
    							
  7. Append the cells from Sheet2 to the first three records of table Ztest with the following command:
          APPEND FROM zbook1.xls TYPE XL5 SHEET SHEET2
    							
    When you browse the table you should see three records that contain the data from sheet2.

APPLIES TO
  • Microsoft Visual FoxPro 3.0b Standard Edition
  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 3.0b for Macintosh
Keywords: 
kbhowto KB176894