EXCEL and FWH
Posted: Sun Mar 19, 2006 6:14 am
Is there a Direct way of dealing with Excel and extract data from .dbf under some conditions to constitute Excel files ?
www.FiveTechSoft.com
https://fivetechsoft.com/forums/
Code: Select all
FUNCTION buildexcel()
*-------------------
local oExcel
local oBook
local oSheet
local nLine:=1
select 3
use mach
oExcel := CREATEOBJECT( "Excel.Application" )
oBook := oExcel:WorkBooks:Add()
oSheet:= oBook:Worksheets(1)
nLine:=1
3->(DBGOTOP())
DO WHILE !(3)->(EOF())
oSheet:Cells( nLine, 1 ):Value = (3)->mc_serial
oSheet:Cells( nLine, 2 ):Value = (3)->mc_name
nLine:=nLine+1
(3)->(DBSKIP(1))
ENDDO
oExcel:Visible := .T.
return nil
You have to use xHarbour or link hbole.lib.Ehab Samir Aziz wrote:There is no a class called createobject .
I did not find hbole.lib. Is its usage alternative of using harbour instead of xHarbour ?You have to use xHarbour or link hbole.lib.
Code: Select all
FUNCTION buildexcel()
*-------------------
local oExcel
local oBook
local oSheet
local nLine:=1
select 3
use mach
oExcel := CREATEOLEOBJECT( "Excel.Application" )
oBook:=OleInvoke( OleGetProperty( oExcel, "WorkBooks" ), "Add" )
oSheet:=OleInvoke( OleGetProperty( oExcel, "WorkSheets(1)" ))
nLine:=1
3->(DBGOTOP())
DO WHILE !(3)->(EOF())
oSheet:Cells( nLine, 1 ):Value = (3)->mc_serial
oSheet:Cells( nLine, 2 ):Value = (3)->mc_name
nLine:=nLine+1
(3)->(DBSKIP(1))
ENDDO
oExcel:Visible := .T.
return nil
Code: Select all
FUNCTION buildexcel()
local oExcel , oBook, oSheet
local nLine :=1
oExcel = CREATEOLEOBJECT( "Excel.Application" )
oBook = OleInvoke( OleGetProperty( oExcel, "WorkBooks" ), "Add" )
oSheet = OleGetProperty( oBook, "WorkSheets", 1 )
OleSetProperty( OleGetProperty( oSheet, "Cells", nLine, 1 ), "Value", "test" )
OleSetProperty( oExcel, "Visible", .t. )
return nil
Code: Select all
FUNCTION ADDNMRNG_WORK()
//----------------------
LOCAL cPath := "E:\programs\clipper\fwh\sitex\OLE.XLS"
LOCAL oExcel
LOCAL oBook
LOCAL osheet
LOCAL nline:=0
oExcel := CreateOLEObject("Excel.Application")
OLESetProperty(oExcel,"Visible",TRUE)
oBook:=OleInvoke( OleGetProperty( oExcel, "WorkBooks" ), "Add" )
oSheet:=OleInvoke( OleGetProperty( oBook, "Worksheets(1)" ))
OLEInvoke(oBook,"Open",cPath)
select 3
use mach
nLine:=1
3->(DBGOTOP())
DO WHILE !(3)->(EOF())
oSheet:Cells( nLine, 1 ):Value = (3)->mc_serial
oSheet:Cells( nLine, 2 ):Value = (3)->mc_name
nLine:=nLine+1
(3)->(DBSKIP(1))
ENDDO
OLEInvoke(oExcel,"Quit")
RETURN NIL