Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Single call to excel
Message
From
09/04/2007 14:44:52
 
 
To
09/04/2007 12:26:03
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01213473
Message ID:
01213566
Views:
20
>>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

Cetin thanks!
I was thinking it was either you or Borislav who help me before on this but this code sample does not look familiar. Is there a way to do it without the ado connection? How about the various formatting commands like borders, fonts, etc.?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform