Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Single call to excel
Message
De
09/04/2007 12:26:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
09/04/2007 12:16:16
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01213473
Message ID:
01213478
Vues:
44
This message has been marked as the solution to the initial question of the thread.
>I recall someone giving me advice on sending a batch of data to excel in a single call rather than sending each cell explicitly, but I am unable to locate my notes on the subject. Would someone indulge my lack of memory and organization and share that technique with me again?
>
>Thanks

Something like this?
VFP2Excel(_samples+'data\testdata.dbc','select * from customer',"Customers")

function VFP2Excel
lparameters tcDataSource, tcSQL, tcSheetName
Local loConn As AdoDB.Connection, ;
	loRS As AdoDB.Recordset,;
	oExcel as Excel.Application

loConn = Createobject("Adodb.connection")
loConn.ConnectionString = "Provider=VFPOLEDB;Data Source="+m.tcDataSource
loConn.Open()
loRS = loConn.Execute(m.tcSQL)
oExcel = Createobject("Excel.Application")
With oExcel
	.WorkBooks.Add
	.Visible = .T.
	With .ActiveWorkBook.ActiveSheet
		.Name = m.tcSheetName
		FOR ix=1 TO loRS.Fields.Count
			.Cells(1,m.ix).Value = PROPER(loRs.Fields(m.ix-1).Name)
		endfor
		.Range('A2').CopyFromRecordSet( loRS )
		.UsedRange.Rows(1).Font.Bold = .t.
		.UsedRange.Columns.Autofit
	Endwith
Endwith
loRs.Close
loConn.Close
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