Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Excel to DBF

Status
Not open for further replies.

breezett93

Technical User
Jun 24, 2015
128
US
My Google searches only brought up websites trying to get me to download their software to convert it for me. I would prefer a more secure way through FoxPro.

I also tried exporting through Excel, but I couldn't find a .dbf format.

Thanks.
 
I was using Excel 2003 and save as dbf until MS removed the option from the newer versions.

Now I create DBF using automation.

Logic Explanation:

Create a table with at least 4 fields
XLSNAME, XLSCOL, DBFCOL, FTYPE

XLSNAME: if there are x different dbf file having different field names, assign each with it unique name
XLSCOL: First row is the fileds names.
DBFCOL: Equivalent DBF Field Name. DBF Filed name is limited to 9 chars.
FTYPE : Field type, Char, Numeric, Date, ++

Data Example:
FILE1 DATEOFBIRTH DOF D
FILE1 FIRSTNAME FNAME C
FILE1 CITYOFBIRTH CITY C
FILE1 CITY_OF_BIRTH CITY C
FILE1 CITY CITY C
FILE1 AGE AGE N


Go through the XLSX/XLS file and do validation on each value.
Make sure you check for NULL and BLANK
Check the field type and convert to the proper type if it is not.
replace the target table with the proper values in their respective fields.

You can even list all the fileds on the form preceded with a CheckBox and user can tick the ones it requires.
You can add a CommandButton to select the XLSX/XLS file.


 
This problem was recently covered and a superb solution provided by the incomparable Mr Vilhelm-Ion Praisach. I've used his utility to import xlsx files of about 30,000 + lines , no problems.

Thread reference : Import to Memo Fields 2 thread184-1755524

Usage is as simple as

Importfromxlsx("MyExcelFile")

Appendfromxlsx("MyExcelFile")

The first one creates the table, based on the first imported row of the spreadsheet (tries to mimic VFP's import command).
The second one append the spreadsheet content to and existing table (tries to mimic VFP's append from command)

 
Very nice words, thank you clipper01 :)

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
I agree what you still do actively for VFP in your blog is beyond compare, Vilhelm-Ion.

Bye, Olaf.

 
Thank you, I am overwhelmed :)

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top