Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy dbf to xls
Message
De
12/08/2010 09:46:09
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01476252
Message ID:
01476351
Vues:
70
>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
Ç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