PRB: Number of Records IMPORT/EXPORTed to Spreadsheet Differs

ID: Q109839

The information in this article applies to:

SYMPTOMS

If you use the COPY TO or EXPORT TO commands to export a database to a spreadsheet file type, and then use the APPEND FROM or IMPORT FROM commands to import that spreadsheet back into a database, the number of records FoxPro reports copied (during the export) is one less than the number of records it reports added (during the import).

CAUSE

When you are copying to a spreadsheet file type, the COPY TO and EXPORT TO commands add an extra record (row) to the beginning of the destination file (spreadsheet). This record contains the names of the database fields and is not included in the FoxPro message that reports the number of records copied, since it is not an actual database record.

However, when the APPEND FROM or IMPORT FROM command imports the records (rows) from that same spreadsheet back into a database, the extra record containing the field names is treated like any other record in the spreadsheet, so FoxPro includes it when reporting the number of records added/imported.

MORE INFORMATION

This information applies to the following file types:

   DIF, MOD, SYLK, WK1, WKS, WR1, WRK, XLS

Steps to Reproduce Behavior

1. Start FoxPro.

2. Create and run a program with the following code:

      SET STATUS ON    && So you can see all messages on the desktop
      CREATE TABLE test (charfld C(20), numfld N(10))
      INSERT INTO test (charfld, numfld) VALUES ('Chris Tester', 1234)
      COPY STRUCTURE TO copytest.dbf

      COPY TO copytest.xls TYPE XLS
       * Message on Desktop: 1 records copied
      EXPORT TO exp-test.xls TYPE XLS
       * Message on Desktop: 1 records copied

      USE copytest.dbf
      APPEND FROM copytest.xls TYPE XLS
       * Message on Desktop: 2 records added

      USE
      IMPORT FROM exp-test.xls TYPE XLS
       * Message in Wait window: 2 Records Imported

For more information about the extra row created by the COPY TO and EXPORT TO commands, query on the following words here in the Microsoft Knowledge Base:

   exported and first and record and field and names

Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b KBCategory: kbprg kbprb KBSubcategory: FxinteropSpread

Last Reviewed: June 26, 1995