writing fixed headers to Excel sheet
Posted: Tue Jul 25, 2006 5:42 am
How can I write fixed headers to fields written to Excel sheet using OLE.
Code: Select all
FUNCTION buildexcel()
*-------------------
LOCAL cPath := "E:\programs\clipper\fwh\sitex\test.XLS"
local oExcel , oBook, oSheet
LOCAL nline:=1
oExcel = CREATEOLEOBJECT( "Excel.Application" )
oBook = OleInvoke( OleGetProperty( oExcel, "WorkBooks" ), "Add" )
oSheet = OleGetProperty( oBook, "WorkSheets", 1 )
select 3
use mach index mach3
set filter to alltrim(3->mc_cu_acct)=="2125447"
3->(DBGOTOP())
DO WHILE !(3)->(EOF())
OleSetProperty( OleGetProperty( oSheet, "Cells", nLine, 1 ), "Value", (3)->mc_type )
OleSetProperty( OleGetProperty( oSheet, "Cells", nLine, 2 ), "Value", (3)->mc_model )
OleSetProperty( OleGetProperty( oSheet, "Cells", nLine, 3 ), "Value", (3)->mc_serial )
OleSetProperty( OleGetProperty( oSheet, "Cells", nLine, 4 ), "Value", (3)->mc_brn )
nLine:=nLine+1
(3)->(DBSKIP(1))
ENDDO
OleSetProperty( oExcel, "Visible", .t. )
OLEInvoke(oExcel,"Quit")
RETURN NIL