Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel won't open VFP tables
Message
From
18/05/2006 18:31:28
 
 
To
18/05/2006 13:05:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01117509
Message ID:
01123426
Views:
21
>>>>It has bugged me for a long time that Excel does not offer the possibility to open VFP files directly. It does read dBase files, but to do that you must copy tables TYPE FOX2X.
>>>>
>>>>Has anybody mentioned this to MS before?
>>>>
>>>>Alex
>>>
>>>Alex,
>>>Which version of Excel doesn't read VFP tables directly (VFPOLEDB is considered direct,no?).
>>>Cetin
>>
>>Hi Cetin,
>>
>>I want to import a cursor that has long names into Excel. Can you explain how to do it using VFPOLEDB? I will be using automation and then saving it as a bonafide xls file.
>>
>>TIA,
>>
>>Alex
>
>
>* Create a table with LNF fieldnames
>* in a directory with an LNF path
>Local lcLNFDir
>lcLNFDir = "c:\An LNF path"
>Md (m.lcLNFDir)
>Create Database ( Addbs(m.lcLNFDir)+"myDatabase" )
>Select cust_id As CustomerID, ;
>  company As "ThisIsAnLNF_Company_Name_of_customer", ;
>  contact As "ThisIsAnLNF_Contact_FirstName_and_LastName_of_customer", ;
>  city, Region, country ;
>  from (_samples+'Data\Customer') ;
>  into Table ( Addbs(m.lcLNFDir)+"myLNFTable" ) ;
>  database ( Addbs(m.lcLNFDir)+"myDatabase" )
>Close Databases All
>
>* Send data to excel
>* PS: This is one of the many ways
>VFP2Excel(Addbs(m.lcLNFDir)+"myDatabase.dbc",;
>  'select * from myLNFTable',;
>  "ThisIsVFPData")
>
>Erase ( Addbs(m.lcLNFDir)+"*.*" )
>Rd (m.lcLNFDir)
>
>Function VFP2Excel
>  Lparameters tcDataSource, tcSQL, tcSheetName
>  Local loConn As AdoDB.Connection, ;
>    loRS As AdoDB.Recordset,;
>    lcTempRs As String, ;
>    lcTemp As String, ;
>    oExcel As Excel.Application
>
>  lcTempRs = Sys(5)+Curdir()+Sys(2015)+'.rst'
>  loConn = Createobject("Adodb.connection")
>  loConn.ConnectionString = "Provider=VFPOLEDB;Data Source="+m.tcDataSource
>  loConn.Open()
>  loRS = loConn.Execute(m.tcSQL)
>  loRS.Save(m.lcTempRs)
>  loRS.Close
>  loConn.Close
>  loRS.Open(m.lcTempRs)
>
>  oExcel = Createobject("Excel.Application")
>  With oExcel
>    .WorkBooks.Add
>    .Visible = .T.
>    With .ActiveWorkBook.ActiveSheet
>      .Name = m.tcSheetName
>      .QueryTables.Add( loRS, .Range("A1")).Refresh()
>    Endwith
>  Endwith
>  loRS.Close
>  Erase (m.lcTempRs)
>
Cetin


Thank you for an excellent and very educational answer, Cetin. Though I haven't tested it yet it is what I was looking for.

BTW I tried to give you three stars but because this thread is in Chatter I'm not allowed. Please consider this worth three symbolic stars.

Alex
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform