FUNCTION MAIN()
LOCAL oExcel, oSheet
LOCAL nRow
oExcel = CREATEOBJECT( "Excel.Application" )
oExcel:WorkBooks:Add()
oSheet = oExcel:ActiveSheet
USE TEST
nRow = 1
WHILE !EOF()
oSheet:Cells( nRow, 1 ):Value = FIELD -> last
oSheet:Cells( nRow, 2 ):Value = FIELD -> first
nRow++
SKIP
ENDDO
oExcel:Visible = .T.
RETURN NIL
function test
local nCounter, nStart, oClipBoard
local oExcel, oWorkBook, oSheet
// create excel objects
oExcel = CREATEOBJECT( "Excel.Application" )
oExcel:WorkBooks:Add()
oWorkBook = oExcel:Get( "ActiveWorkBook" )
oSheet = oExcel:Get( "ActiveSheet" )
nCounter := 1
nStart := nCounter
cMemo := ''
do while .not. eof()
// build record
cMemo += Field1
cMemo += chr(9)+Field2
cMemo += chr(9)+Field3
cMemo += CRLF
nCounter++
skip
// update sheet every 1000 records or eof()
if mod( nCounter, 1000 ) = 0 .or. eof()
oClipBoard := tclipboard():New()
if oClipBoard:Open()
oClipBoard:SetText( cMemo )
oClipBoard:Close()
endif
pClipBoard:close()
oExcel:oSheet:Cells( nStart, 1 ):Select()
oExcel:oSheet:paste()
nStart := nCounter
cMemo := ''
endif
enddo
return( nil )
Rick Lipkin wrote:Enrico .. here is your modified code .. 2 questions
FUNCTION MAIN()
LOCAL oExcel, oSheet
LOCAL nRow
oExcel = CREATEOBJECT( "Excel.Application" )
oExcel:WorkBooks:Add()
oSheet = oExcel:ActiveSheet
USE TEST
oSheet:Cells( 1, 1 ):Value = "LAST"
oSheet:Cells( 1, 2 ):Value = "FIRST"
oSheet:Cells( 1, 3 ):Value = "HIREDATE"
nRow = 2
WHILE !EOF()
oSheet:Cells( nRow, 1 ):Value = FIELD -> last
oSheet:Cells( nRow, 2 ):Value = FIELD -> first
oSheet:Cells( nRow, 3 ):Value = FIELD -> hiredate
nRow++
SKIP
ENDDO
oSheet:Cells( nRow, 1 ):Value = "Test for"
oSheet:Cells( nRow, 2 ):Value = "empty date"
oSheet:Cells( nRow, 3 ):Value = CTOD( "" )
oSheet:Columns( "A:C" ):AutoFit()
// oExcel:Visible = .T.
FERASE( "C:\XHARBOUR\SAVED.XLS" )
oSheet:SaveAs( "C:\XHARBOUR\SAVED.XLS" )
oExcel:Quit()
RETURN NIL
// #include "fivewin.ch"
FUNCTION MAIN()
LOCAL oExcel, oSheet
LOCAL nRow
LOCAL nCounter, nStart, nSeconds, nSecOle, nSecClip
oExcel = CREATEOBJECT( "Excel.Application" )
oExcel:WorkBooks:Add()
oSheet = oExcel:ActiveSheet
nRow := 1
oSheet:Cells( nRow, 1 ):Value = "Counter"
oSheet:Cells( nRow, 2 ):Value = "Date"
oSheet:Cells( nRow, 3 ):Value = "Row"
nCounter := 1
nStart := nCounter
nSeconds := seconds()
DO WHILE nCounter < 2000
oSheet:Cells( nCounter+nRow, 1 ):Value = nCounter
oSheet:Cells( nCounter+nRow, 2 ):Value = date()-nCounter
oSheet:Cells( nCounter+nRow, 3 ):Value = nCounter-1
nCounter++
ENDDO
nSecOle := seconds()-nSeconds
nRow += nCounter+2
oSheet:Cells( nRow, 1 ):Value = "Counter"
oSheet:Cells( nRow, 2 ):Value = "Date"
oSheet:Cells( nRow, 3 ):Value = "Row"
nSeconds := seconds()
nCounter := 1
nStart := nCounter
cMemo := ''
DO WHILE nCounter < 2000
// build record
cMemo += ltrim( str( nCounter ) )
cMemo += chr(9)+dtoc( date()-nCounter )
cMemo += chr(9)+ltrim( str( nCounter+nRow-1 ) )
cMemo += chr(10)
nCounter++
// update sheet every 1000 records or eof()
IF mod( nCounter, 1000 ) = 0 // .or. eof()
// This is for Fivewin Code
/*
oClipBoard := tClipBoard():New()
IF oClipBoard:Open()
oClipBoard:SetText( cMemo )
oClipBoard:Close()
ENDIF
*/
// This is for xHarbour Console
GTSetClipboard( cMemo )
oSheet:Cells( nRow+nStart, 1 ):Select()
oSheet:paste()
nStart := nCounter
cMemo := ''
ENDIF
ENDDO
// clear clipboard buffer (Fivewin Code)
/*
oClp := TClipBoard():New()
IF oClp:Open()
oClp:SetText( '' )
oClp:Close()
ENDIF
msginfo( 'Ole = '+ltrim(str(nSecOle))+CRLF+;
'Clip = '+ltrim(str(nSecClip)) )
*/
// This is for xHarbour Console
nSecClip := seconds()-nSeconds
? 'Ole = '+ltrim(str(nSecOle))
? 'Clip = '+ltrim(str(nSecClip))
wait
nSecClip := seconds()-nSeconds
oSheet:Columns( "A:C" ):AutoFit()
oExcel:Visible = .T.
// FERASE( "C:\XHARBOUR\SAVED.XLS" )
//
// oSheet:SaveAs( "C:\XHARBOUR\SAVED.XLS" )
// oExcel:Quit()
RETURN( nil )
Rick Lipkin wrote:any way to make sure all the contents of the column get left justified ??
oSheet:Cells( nRow, 1 ):Value := "'" + cert->zip
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 52 guests