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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Excel

Status
Not open for further replies.

SgtPepps

IS-IT--Management
May 1, 2002
109
GB
I need to create 1000s of records in a FoxPro2.0 database that i already have in an Excel Spreadsheet. I can import OK but FoxPro uses Column Headers to create field names. It'll create a brand new DB and name fields the same as Excel Columns.

Can i easily copy an existing database structure over an imported spreadsheet? Hopefully creating the field structure i need.

Or Print a DB field structure so i can manually modify the fields?

Or somthing to the same effect.

Thanks for any help, i've so much to do in so little time.

Mike
 
If all you want to do is rename the column headings, just open the table and list the structure. You can then scroll down the field names and change them as you like:

USE MyTable EXCLUSIVE
LIST STRUCTURE TO PRINT
MODIFY STRUCTURE


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Lets assume your file is a list of customers with the following structure

LAST
FIRST
ADD
CITY
STATE
ZIP
Lets assume the Excel Spread Sheet is called CUST.XLSwill create a DBF with the following Structure

LAST_NAME
FIRST_NAME
ADDRESS
CITY
STATE
ZIP_CODE
------------------------------------------------------------
1) Open Excel and save the file as tank.dbf
2) Open Foxpro and open the tank.dbf file.
3) List Stru to print.
4) Zap the file if this is a process you will have to repeat over and over again.
5) Run EXCELCON.PRG
------------------------------------------------------------
*EXCELCON.PRG
* 2/14/04
* AUTOMATED IMPORT OF RECORDS FROM EXCEL SPREADSHEET
**********************************************************
@ 1,1 SAY " ADDING RECORDS FROM SPREAD SHEET " COLOR W+/R+
@ 12,23 SAY "PROCESSING OCCURRING ..... PLEASE WAIT!"
SELE A
USE CUSTOMERS
SELE B
USE TANK
APPE FROM CUST.XLS TYPE XLS
GO TOP
SCAN
SELE A
DO WHILE NOT RLOCK()
ENDDO
APPE BLANK
REPL LAST WITH B.LAST_NAME
REPL FIRST WITH B.FIRST_NAME
REPL ADD WITH B.ADDRESS
REPL CITY WITH B.CITY
REPL STATE WITH B.STATE
REPL ZIP WITH B.ZIP_CODE
UNLOCK
SELE B
ENDSCAN
CLOSE DATA
USE TANK EXCL
ZAP
CLEA
RETU
* EOF EXCELCON.PRG
------------------------------------------------------------
You will need to make the necessary changes in the code if you are doing this once or multiple time. Also you should test this with a blank copy of the file before you actually use it live. If this is something you will allow and end user to do, you might also want to rename the excel spread sheet after the file import so they cannot keep running the program and adding duplicate records over and over


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top