Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Import Excel data
Message
 
À
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:
01207125
Vues:
28
>>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

Hi,

Thanks for the reply. Considered that (already have code in another project that has it) but due to data types and formatting, had to use the method in my sample code.
The mskb #194124 (http://support.microsoft.com/kb/194124/EN-US/) PRB: Excel Values Returned as NULL Using DAO OpenRecordset ) explains the issue when the column has mixed numeric and text values.

Regards,
Ariel
Speak using soft and sweet words in case you have to eat them later.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform