Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Better way to code Excel automation?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01313820
Message ID:
01350010
Vues:
28
I figured it out, it was the connection string. In the query, I needed brackets around the sheet name and added the $. Now, if I can get it to bring in the column names correctly instead of as a record.
Code:
FOR x=1 TO ALEN(aSheets,1)
       lsConnstr = [Driver=] + ;
	[{Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};] + ;
	[DBQ=] + lsXLBook
       lnSQLHand = SQLSTRINGCONNECT( lsConnstr )
       lsSQLCmd = "Select * FROM ["+aSheets[x]+"$]"
       lnSuccess = SQLEXEC( lnSQLHand, lsSQLCmd, [xlResults]+TRANSFORM(x) )
ENDFOR
SELECT ("xlResults"+TRANSFORM(x))
BROWSE NOWAIT
>Whar ODBC error do you get?
>
>>I have tried, I get a handle but the query fails. I think the sqlexe does not like the name "Sheet1$" or the real sheet name (all the sheets are named) in the query string. I cannot successfully execute the query. I get a handle, so the connStr is good. Any ideas?
>>
>>>Check Importing data from a Microsoft Excel 2007 workbook using Visual FoxPro 9.0
Extreme Programming = Plan -> Design -> Code -> Test
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform