Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Import Excel data
Message
De
22/03/2007 11:30:49
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01207090
Message ID:
01207111
Vues:
27
>Hi,
>
>Working on an Excel data extraction project. The Excel worksheet may have several sheets that all need to read data from.
>
>I've gotten to the the point where I need to know the sheet names to be used for the select statement for the InitRecordset.
>
>Here is my sample code:
>
>LOCAL oXLSConnect, oRecXLS, oXLSRS
>oXLSConnect = CREATEOBJECT('adodb.connection')
>oXLSConnect.cConnectionString = [Provider=Microsoft.Jet.OLEDB.4.0;Data Source=] ;
>	+ GETFILE() + [;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";]
>oXLSConnect.Open
>
>oRecXLS = CREATEOBJECT('veRecHandler')   && veRecHandler is an internal class we have
>lcSqlCmd = "select * from [" + TRIM(sheet_name) + "]"
>oXLSRS = oRecXLS.InitRecordSet(adUseClient, adOpenStatic, adLockOptimistic, lcSqlCmd, oXLSConnect)
>oRecXLS.Rs2Cusror(oXLSRS, "C_" + TRIM(table_name))
>
>
>
>Any help is greatly appreciated.
>
>Regards,
>Ariel
lcXLS = GETFILE("xls") 
lcConn = "Driver={Microsoft Excel Driver (*.xls)};"+;
  "DriverId=790;Dbq="+m.lcXLS+;
  ";DefaultDir="+JustPath(m.lcXLS)+";" 
lnHandle = SQLStringConnect(lcConn) 
SQLTables(lnHandle,"", "SheetNames")
Scan
	lcTableName = Trim(SheetNames.Table_Name)
	lcOutput = Chrtran(m.lcTableName,' $','_')
	SQLExec(lnHandle,'select * from ['+m.lcTableName+']',m.lcOutput )
endscan
SQLDisconnect(lnHandle)
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