Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy dbf to xls
Message
From
13/08/2010 01:57:40
 
 
To
12/08/2010 09:46:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01476252
Message ID:
01476428
Views:
63
many thanks cetin - i will work through your code and give it a try - meantime i have stored your comments and code for future use. so far all are still using 07 and seem on safe terrain by the comments i have received.

k

>>Two parter: would appreciate comments on either or both
>>1.
>>Is it still safe to convert dbf to xls with the following:
>>copy file myfile.dbf to myxfile.xls
>>It works but i'm wondering if office (2007) is viewing this file as a fake xls
>>
>>2.
>>how do i remove top line of my newly copied xls?
>>
>>many thanks
>>k
>
>1) For 2007? Probably yes, for a later version like 2010 not. I suggest not to use 'copy to .. type xls'.
>2) If you don't use 'copy to .. .type xls' and go with the safer automation + ADO transfer method then actually you need to write that headers line explicitly if you want it. ie:
>
>
>Local oExcel
>oExcel = Createobject("Excel.Application")
>With oExcel
>  .WorkBooks.Add
>  .Visible = .T.
>  VFP2Excel(_samples+'data\testdata.dbc',;
>    'select * from customer',;
>    .ActiveWorkBook.ActiveSheet.Range('A1'))
>Endwith
>
>Function VFP2Excel
>  Lparameters tcDataSource, tcSQL, toRange
>  Local loConn As AdoDB.Connection, ;
>    loRS As AdoDB.Recordset,;
>    ix
>  loConn = Createobject("Adodb.connection")
>  loConn.ConnectionString = "Provider=VFPOLEDB;Data Source="+m.tcDataSource
>  loConn.Open()
>  loRS = loConn.Execute(m.tcSQL)
>
>*!*	  For ix=1 To loRS.Fields.Count
>*!*	    toRange.Offset(0,m.ix-1).Value = Proper(loRS.Fields(m.ix-1).Name)
>*!*	    toRange.Offset(0,m.ix-1).Font.Bold = .T.
>*!*	  Endfor
>*!*	  toRange.Offset(1,0).CopyFromRecordSet( loRS )
>
>  toRange.CopyFromRecordSet( loRS )
>
>  loRS.Close
>  loConn.Close
>Endfunc
>
Cetin
Previous
Reply
Map
View

Click here to load this message in the networking platform