FUNCTION TABLETOEXCel

PARAMETERS pcAlias,pcExcelFile

PRIVATE lnNoOFRows,lnNoofColumns,lnRowNo,lnColNo,lcAlias,i,j

lcAlias = ALIAS()
SELECT (pcAlias)
GO TOP 
lnNoOFRows = RECCOUNT(pcAlias)
lnNoOFCoilmns = fCount(pcAlias)
objExcelApp = CreateObject("Excel.Application")
WITH objExcelApp
	.SheetsInNewWorkbook = 1
	.Workbooks.Add()
	.Worksheets(1).Select()
	FOR j = 1 TO lnNoOFCoilmns
		.cells(1,j).value = FIELD(j,pcAlias)
	ENDFOR 
	FOR i = 2 TO lnNoOfRows +1
WAIT WINDOW STR(i) NOWAIT 
		FOR j = 1 TO lnNoOFCoilmns
			LCfLDnAME = (FIELD(j,pcAlias))
			lcValue   = &lcFldName
			.Cells(i,j).Value = lcvalue
*!*				IF TYPE(LCfLDnAME) = 'D'
*!*					.Cells(i,j).Value = DTOC(&LCfLDnAME)
*!*				ELSE 			
*!*					.Cells(i,j).Value = &LCfLDnAME
*!*				ENDIF 
		ENDFOR
		SKIP IN (PcAlias)
	ENDFOR
	objExcelApp.ActiveCell.Worksheet.SaveAs(pcExcelFile)
	objExcelApp.quit
ENDWITH
RELEASE objExcelApp