LPARAMETERS tabel, initial, final
LOCAL  nrc, i, c
STORE 0 TO nrc, i
STORE '' TO c

A='C:\MY DOCUMENTS'
B='C:\DOCUMENTS AND SETTINGS'
DO CASE
CASE DIRECTORY('&A')
	SET DEFAULT TO '&A'
CASE DIRECTORY('&B')
	SET DEFAULT TO '&B'
OTHERWISE
	MD &A
	SET DEFAULT TO '&A'
ENDCASE	


exista_excel=.F.

initial = ','+initial+',' &&Pentru a recunoste coloanele'
final = ','+final+',' &&---||---

nrc = OCCURS(',', '&initial')
nrc=nrc-1 && scade vircula din fata

LOCAL ARRAY c_initial(nrc)
LOCAL ARRAY c_final(nrc)
	
FOR i = 1 TO nrc
	n = AT(',', '&initial', i)
	n2 =AT(',', '&initial', i+1)
	c_Initial[i] = SUBSTR('&initial', n+1, n2-n-1)
	*MESSAGEBOX(c_initial[i])
	n = AT(',', '&final', i)
	n2 =AT(',', '&final', i+1)
	c_final[i] = SUBSTR('&final', n+1, n2-n-1)
	*MESSAGEBOX(c_final[i])
ENDFOR 
	
FOR i=1 TO nrc
	IF i=nrc
		c=c+c_initial[i]+' as '+c_final[i]
	ELSE
		c=c+c_initial[i]+' as '+c_final[i]+','
	ENDIF 
ENDFOR 
		
calea_fis = PUTFILE('Nume fisier:', 'Foaie_Excel', 'XLS')
IF EMPTY(calea_fis)  && Esc pressed
 	RETURN 
ENDIF
	
SELECT &c FROM &tabel INTO CURSOR cur
SELECT cur
EXPORT TO (calea_fis) TYPE XL5

SET DEFAULT TO &DIRGEN
RETURN




PROCEDURE EXPORTARE2
LPARAMETERS tabel
*, initial, final
LOCAL  nrc, i, c
STORE 0 TO nrc, i
STORE '' TO c

A='C:\MY DOCUMENTS'
B='C:\DOCUMENTS AND SETTINGS'
DO CASE
CASE DIRECTORY('&A')
	SET DEFAULT TO '&A'
CASE DIRECTORY('&B')
	SET DEFAULT TO '&B'
OTHERWISE
	MD &A
	SET DEFAULT TO '&A'
ENDCASE	


*!*	exista_excel=.F.

*!*	initial = ','+initial+',' &&Pentru a recunoste coloanele'
*!*	final = ','+final+',' &&---||---

*!*	nrc = OCCURS(',', '&initial')
*!*	nrc=nrc-1 && scade vircula din fata

*!*	LOCAL ARRAY c_initial(nrc)
*!*	LOCAL ARRAY c_final(nrc)
*!*		
*!*	FOR i = 1 TO nrc
*!*		n = AT(',', '&initial', i)
*!*		n2 =AT(',', '&initial', i+1)
*!*		c_Initial[i] = SUBSTR('&initial', n+1, n2-n-1)
*!*		*MESSAGEBOX(c_initial[i])
*!*		n = AT(',', '&final', i)
*!*		n2 =AT(',', '&final', i+1)
*!*		c_final[i] = SUBSTR('&final', n+1, n2-n-1)
*!*		*MESSAGEBOX(c_final[i])
*!*	ENDFOR 
*!*		
*!*	FOR i=1 TO nrc
*!*		IF i=nrc
*!*			c=c+c_initial[i]+' as '+c_final[i]
*!*		ELSE
*!*			c=c+c_initial[i]+' as '+c_final[i]+','
*!*		ENDIF 
*!*	ENDFOR 
*!*			
calea_fis = PUTFILE('Nume fisier:', 'Foaie_Excel', 'XLS')
IF EMPTY(calea_fis)  && Esc pressed
 	RETURN 
ENDIF
*!*		
*!*	SELECT &c FROM &tabel INTO CURSOR cur
SELECT &tabel
EXPORT TO (calea_fis) TYPE XL5

SET DEFAULT TO &DIRGEN
RETURN



