1. How to import from a tab delimited file.
2. How to import directly from an xls file.
bFile := {||'c:\awt\kyocera.xls'}
oExcel := TOleAuto():New("Excel.Application")
oExcel:WorkBooks:Open(eval(bFile))
oSheet := oExcel:Get("ActiveSheet")
oExcel:Visible := FALSE
nRows := oSheet:UsedRange:Rows:Count()
do while nRowInc <= nRows
CursorWait()
cCode := oSheet:Cells(nRowInc,"A"):Value
cDesc := oSheet:Cells(nRowInc,"B"):Value
cGroup := 15
nCost := oSheet:Cells(nRowInc,"F"):Value
nSell := oSheet:Cells(nRowInc,"G"):Value
cSpplr := 'KYO01 '
if (valtype(cGroup) = 'C')
cGroup := str(cGroup,3)
oKyocera:group := LEFT(ALLTRIM(cGroup) + space(3),3)
endif
if (valtype(cGroup) = 'N')
cGroup := str(cGroup,3)
oKyocera:group := LEFT(ALLTRIM(cGroup) + space(3),3)
endif
if (valtype(cCode) = 'C')
oKyocera:code := cCode
endif
if (valtype(cCode) = 'N')
oKyocera:code := LTRIM(str(cCode,15))
endif
if ! empty(cDesc)
oKyocera:desc := cDesc
endif
if ! empty(nCost)
oKyocera:cost := nCost
endif
if ! empty(nSell)
oKyocera:sell := nSell
endif
oKyocera:append()
nRowInc++
enddo
oExcel = nil
CursorArrow()
return(nil)
//---------------------------------------------------------------------------//
Hope this helps
Colin
#include "Fivewin.ch"
//----------------------------------//
Function Main()
Local oExcel,oWorkBook,cFileName:="D:\FwhExtra\FwhTests\xTest", ;
dDate,nNumber,cDesc,nAmount,nRows,nRowInc
oExcel := CreateObject( "Excel.Application" )
oExcel:WorkBooks:Open(cFileName)
oSheet := oExcel:Get("ActiveSheet")
oExcel:Visible := .F.
nRows := oSheet:UsedRange:Rows:Count()
nRowInc:=3
Do while nRowInc <= nRows
CursorWait()
dDate := oSheet:Cells(nRowInc,"A"):Value
nNumber := oSheet:Cells(nRowInc,"B"):Value
cDesc := oSheet:Cells(nRowInc,"C"):Value
nAmount := oSheet:Cells(nRowInc,"D"):Value
MsgInfo(Dtoc(dDate)+CRLF+str(nNumber)+CRLF+cDesc+CRLF+str(nAmount))
nRowInc++
enddo
oExcel:Quit()
CursorArrow()
Return NIL
//-----------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 81 guests