Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to read in a Excel File and convert it to DBF file ?
Message
De
28/11/2008 20:46:51
 
 
À
28/11/2008 05:06:45
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01272982
Message ID:
01364591
Vues:
23
Compiling information from Cetin, Sergey and others:
1. If you don't want Excel to be installed in the machine
just do what Sergey explains at Message #1124888,
like Naomi told you. The only remark I do is that if you
have the data correctly formatted in the Excel file,
the fields type in the cursor could be Numeric, Date,
etc., and the data is correctly imported. If not, you will
loose data in the process. If so, use Character for
everything. Later you can filter and convert.
2. If you have Excel in the machine you can automatize
the process getting the names of the Sheets directly from
the Excel file and then use them to import the data.
vfile		= '...'

oExcel = CreateObject("Excel.Application")
oWorkbook = oExcel.Workbooks.Open(vFile)
tSheets = oWorkbook.Sheets.Count             && get total of sheets

DIMENSION nSheet(tSheets)

FOR n=1 TO tSheets
	nSheet(n) = oWorkbook.Sheets(n).Name      && get names of the sheets
NEXT

oExcel.Quit()		&& quits excel but don't unload it from memory.
			&& I have Office 2003 and it didn't remove EXCEL.EXE from memory
RELEASE oExcel		&& This remove Excel from memory

&& now you can create the cursors and import data into it
CREATE CURSOR FirstOne (Number N(10), Name C(60), Date D(8), Other C(50))
APPEND FROM (vFile) XL8 SHEET (nSheet(x))
For me, worked perfectly!
Hope this help.
***
TONY Nascimento
*****************

"Your mind is like a parachute. It only works if it is open" - Anthony J. D'Angelo

"The desire to know is natural to good men" - Leonardo da Vinci
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform