HOWTO: Append Data from a Single Sheet of an Excel Workbook

Last reviewed: November 21, 1997
Article ID: Q176894
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0b, 5.0, 5.0a
  • Microsoft Visual FoxPro for Macintosh, version 3.0b

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.

Keywords          : VFoxMac vfoxwin
Version           : MACINTOSH:3.0b; WINDOWS:3.0b,5.0,5.0a
Platform          : MACINTOSH WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 21, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.