Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to convert a Excel File to DBF file
Message
De
13/05/2005 07:15:07
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
13/05/2005 00:09:19
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 6 SP5
OS:
Windows XP SP2
Network:
Novell 4.x
Database:
Visual FoxPro
Divers
Thread ID:
01013706
Message ID:
01013772
Vues:
14
>Hi,
>
>I want to convert a Excel file to a DBF file, how to coding ?
>Just convert it, no need to open and read the excel file contents.
>
>Regards,
>Derek Yim

Derek,
Converting it to a dbf might not be as simple as it sounds under all cases. For regular stuff there are many ways to do it. Two of these below:
#Define xlDBF3 8
lcXLSFile = Sys(5)+Curdir()+"MyXLS.xls"
lcOutPath = 'XLSheets'
If !Directory(m.lcOutPath)
	Md (m.lcOutPath)
endif
ox = Createobject('Excel.Application')
With ox
  .Workbooks.Open(m.lcXLSFile)
  For Each loSheet In .ActiveWorkbook.Sheets
  	If loSheet.UsedRange.Rows.Count > 0
  		loSheet.Activate
  		loSheet.Range('A1').Select
	    loSheet.SaveAs(Addbs(Fullpath(m.lcOutPath))+loSheet.Name, xlDBF3)
    endif
  Endfor
  .ActiveWorkbook.Saved = .T.
  .Quit
Endwith
lcXLS = Sys(5)+Curdir()+'myXLS.xls'
lcConn = "Driver={Microsoft Excel Driver (*.xls)};"+;
  "DriverId=790;Dbq="+m.lcXLS+;
  ";DefaultDir="+JustPath(m.lcXLS)+";" 
lnHandle = SQLStringConnect(m.lcConn) 
SQLTables(m.lnHandle,"", "SheetNames")

Scan
	lcTableName = Trim(SheetNames.Table_Name)
	lcOutput = Chrtran(m.lcTableName,' $','_')
	SQLExec(m.lnHandle,'select * from ['+m.lcTableName+']',m.lcOutput )
endscan
SQLDisconnect(m.lnHandle)
* Select and browse cursors in data session
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform