Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can somebody please give a hand?
Message
 
 
À
06/03/2009 14:51:08
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01386076
Message ID:
01386311
Vues:
74
The code as is seems to work great. But I don't want to have Excel visible and I want to automacally save it under the name and also apply some fancy formatting. This part is not working for me yet.

I'm going to let my manager to test it too, may be there is something wrong with my Office.

>
>Rand(-1)
>Select c.Company,;
>  c.Contact, ;
>  RTRIM(e.First_Name)+' '+Rtrim(e.Last_Name) As eName, ;
>  CAST(Chrtran(e.Notes,Chr(13),'') As m) As Notes ;
>  FROM (_samples+'data\customer') c, (_samples+'data\employee') e ;
>  INTO Cursor xx ;
>  nofilter
>
>loExcel = Createobject('Excel.Application')
>With loExcel
>  .Workbooks.Add()
>  .Visible =.T.
>  VFP2Excel('xx',.ActiveWorkbook.ActiveSheet.Range('A1'))
>  .ActiveWorkbook.ActiveSheet.Usedrange.Columns.Autofit
>Endwith
>
>*** Author: Cetin Basoz
>Function VFP2Excel
>  Lparameters tcCursorName, toRange, tcHeaders
>  tcCursorName = Iif(Empty(m.tcCursorName),Alias(),m.tcCursorName)
>  Local loConn As AdoDB.Connection, loRS As AdoDB.Recordset, ;
>    lcTemp, loError, lcError
>
>  lcTemp = Forcepath(Sys(2015) + '.dbf',Sys(2023))
>  Select (m.tcCursorName)
>  Copy To (m.lcTemp)
>  loConn = Createobject("Adodb.connection")
>  loConn.ConnectionString = "Provider=VFPOLEDB;Data Source=" + Sys(2023)
>  loConn.Open()
>  loRS = loConn.Execute("select * from " + Justfname(m.lcTemp))
>
>  toRange.Offset(1,0).CopyFromRecordSet(loRS)  && Copy data starting from headerrow + 1
>
>  For ix=1 To Iif( !Empty(m.tcHeaders), ;
>      ALINES(aHeader, m.tcHeaders,1,','), ;
>      loRS.Fields.Count )
>    toRange.Offset(0,m.ix-1).Value = ;
>      Iif( !Empty(m.tcHeaders), ;
>      aHeader[m.ix], ;
>      Proper(loRS.Fields(m.ix-1).Name) )
>    toRange.Offset(0,m.ix-1).Font.Bold = .T.
>  Endfor
>
>  loRS.Close
>  loConn.Close
>  Erase (m.lcTemp)
>Endfunc
>
Cetin
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform