Convert xls to FoxPro dbf?


I have the data file in both Excel and txt format. I need to convert it into FoxPro dbf format. In Exel XP (on Win2K), there are three options for dbf format: db II, db III and db IV.

For FoxPro, which one should I use? Or should I use something entirely different.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use DBase III if you are writing it from Excel to a file for opening in VFP.
You could also use the following to append the data directly from the XLS file.
You can try type XLS first and then XL5 and XL8 if necessary.  You can also specify which sheet to open with thw XL5 and XL8 types.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Here is some code that is taken from a form that does exactly what you need.  The problem with xls to DBF is that depending on the data fields that are in the XLS the will transform to a large numeric field.  This field will be the days that have passed since 12-31-1899 (the turn of the 19th century).  If you import the xls file and you see dates that appear to be of this nature just derive the true date by adding these days to the date equilvalent of this field

Store CTOD('12/31/1899') + Field to NewDate.  Other than that issue this code is pretty straight forward.

STORE (sys(5) + SYS(2003)) to Hold_Path  && Root
SET default to &Import_Path  && My import Directory
m.FileName  = GetFILE([xls,XLS],'Get XLS Input Data','Select',0,'Generate New Accounts')  && File Dialog
IF !EMPTY(M.FileName)  && Got an xls file
    Set default to &Import_Path  && set path to write
    Store JUSTSTEM(M.FileName) to TheName  && dbf name
    Store 'IMPORT FROM ' + M.FileName + ' TYPE XL8 AS 1252' to Command
    Select &TheName
SET default to &Hold_path && Reset path

Any other questions you can e-mail me at

caseyleeAuthor Commented:
Dear Slink9,

The Excell cannot be used to translate to .dbf because it does not transformed the time correctly. It always add the date of 1/1/1900 to the time, no matter what format the time column is.

Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Could you provide a sample XL file.
That is a DBF file's DATETIME format.  You can pull the time out of it by doing a TTOC() on the field.
In Foxpro 7.0 DBase IV version opens/imports correctly.  When modifying it,VFP will ask you if you want to convert it to a current version.  You will want to copy (COPY AS)it to at least the default which is "1252".

  You can export it to an older version of Excel, such as Excel 95 or 97.  Then import it into Foxpro.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.