Código: Selecionar todos
*------------------------------------------------------------------------------*
* FUNCAO EXPORTACAO
*------------------------------------------------------------------------------*
Function Exportar()
PUBLIC nRecCountC := 0
PUBLIC cPastaArq := GetCurrentFolder() + "\ARQUIVOS", cPastaSgf := GetCurrentFolder()
MAIN.StatusBar.Item(1) := ' Aguarde...... Exportando ' + AllTrim(Str(nRecCountB)) + ' Registros para diversos arquivos conforme o nome do municipio'
WAIT WINDOW "Aguarde..... Exportando " + AllTrim(Str(nRecCountB)) + ' Registros... Podendo Demorar...' NOWAIT
DIRMAKE(cPastaArq)
SET DEFAULT TO "&cPastaArq"
SET DEVICE TO PRINTER
cMu := ''
*SET PRINTER TO (cMu + ".CSV")
Try
ret1:=FDB:Execute(csql)
Catch e
Error Connection FDB
Return
End
if !ret1:eof()
do while !ret1:eof()
nRecCountC++
_nb1:=ret1:fields["NB"]:VALUE
_nm1:=ret1:fields["NM"]:VALUE
_cpf1:=ret1:fields["CPFOK"]:VALUE
_vl1:=ret1:fields["VL"]:VALUE
_ns1:=ret1:fields["NS"]:VALUE
_mu1:=ret1:fields["MU"]:VALUE
_uf1:=ret1:fields["UF"]:VALUE
_lg1:=ret1:fields["LG"]:VALUE
_br1:=ret1:fields["BR"]:VALUE
_cp1:=ret1:fields["CEP"]:VALUE
_ddd1:=ret1:fields["DDD"]:VALUE
_tel1:=ret1:fields["NU_TELEFON"]:VALUE
_esp1:=ret1:fields["ESP"]:VALUE
_dib1:=ret1:fields["DIB"]:VALUE
_ddb1:=ret1:fields["DDB"]:VALUE
IF Empty ( _NB1 ) ; _NB1 := ' ' ; ENDIF
IF Empty ( _NM1 ) ; _NM1 := ' ' ; ENDIF
IF Empty ( _CPF1 ) ; _CPF1 := ' ' ; ENDIF
IF Empty ( _VL1 ) ; _VL1 := ' ' ; ENDIF
IF Empty ( _NS1 ) ; _NS1 := ' ' ; ENDIF
IF Empty ( _MU1 ) ; _MU1 := ' ' ; ENDIF
IF Empty ( _UF1 ) ; _UF1 := ' ' ; ENDIF
IF Empty ( _LG1 ) ; _LG1 := ' ' ; ENDIF
IF Empty ( _BR1 ) ; _BR1 := ' ' ; ENDIF
IF Empty ( _CP1 ) ; _CP1 := ' ' ; ENDIF
IF Empty ( _DDD1 ) ; _DDD1 := ' ' ; ENDIF
IF Empty ( _TEL1 ) ; _TEL1 := ' ' ; ENDIF
IF Empty ( _ESP1 ) ; _ESP1 := ' ' ; ENDIF
IF Empty ( _DIB1 ) ; _DIB1 := ' ' ; ENDIF
IF Empty ( _DDB1 ) ; _DDB1 := ' ' ; ENDIF
If cMu <> ALLTRIM(_MU1) + ' - ' + ALLTRIM(_UF1)
cMu := ALLTRIM(_MU1) + ' - ' + ALLTRIM(_UF1)
SET PRINTER TO (cMu + ".CSV")
ExportMenu()
Endif
@ PROW() ,000 SAY CHR(34) + _NB1 + CHR(34) + ';' ;
+ CHR(34) + _NM1 + CHR(34) + ';' ;
+ CHR(34) + _CPF1 + CHR(34) + ';' ;
+ CHR(34) + _VL1 + CHR(34) + ';' ;
+ CHR(34) + _NS1 + CHR(34) + ';' ;
+ CHR(34) + _MU1 + CHR(34) + ';' ;
+ CHR(34) + _UF1 + CHR(34) + ';' ;
+ CHR(34) + _LG1 + CHR(34) + ';' ;
+ CHR(34) + _BR1 + CHR(34) + ';' ;
+ CHR(34) + _CP1 + CHR(34) + ';' ;
+ CHR(34) + _DDD1 + CHR(34) + ';' ;
+ CHR(34) + _TEL1 + CHR(34) + ';' ;
+ CHR(34) + _ESP1 + CHR(34) + ';' ;
+ CHR(34) + DTOC(_DIB1) + CHR(34) + ';' ;
+ CHR(34) + DTOC(_DDB1) + CHR(34) + ';'
@ PROW()+1,000 SAY ""
ret1:movenext()
If cMu <> ALLTRIM(_MU1) + ' - ' + ALLTRIM(_UF1)
SET PRINTER TO
cMu := ""
Endif
enddo
endif
SET PRINTER TO
SET DEFAULT TO "&cPastaSgf"
WAIT CLEAR
MAIN.StatusBar.Item(1) := AllTrim(Str(nRecCountC)) + ' - Registros Exportados com sucesso para diversos arquivos conforme o nome do Municipio. Para consulta-los clique no Botao "Pasta".'
MsgInfo( AllTrim(Str(nRecCountC)) + ' - Registros Exportados com sucesso para diversos arquivos conforme o nome do Municipio. Para consulta-los clique no Botao "Pasta".', [Registros Exportados])
return
*------------------------------------------------------------------------------*
* FUNCAO MENU DA EXPORTACAO
*------------------------------------------------------------------------------*
Function ExportMenu()
@ PROW() ,000 SAY CHR(34) + "BENEFICIO" + CHR(34) + ";" ;
+ CHR(34) + "NOME" + CHR(34) + ";" ;
+ CHR(34) + "CPF" + CHR(34) + ";" ;
+ CHR(34) + "VALOR" + CHR(34) + ";" ;
+ CHR(34) + "DATA NASC" + CHR(34) + ";" ;
+ CHR(34) + "MUNICIPIO" + CHR(34) + ";" ;
+ CHR(34) + "UF" + CHR(34) + ";" ;
+ CHR(34) + "ENDERECO" + CHR(34) + ";" ;
+ CHR(34) + "BAIRRO" + CHR(34) + ";" ;
+ CHR(34) + "CEP" + CHR(34) + ";" ;
+ CHR(34) + "DDD" + CHR(34) + ";" ;
+ CHR(34) + "TELEFONE" + CHR(34) + ";" ;
+ CHR(34) + "ESP" + CHR(34) + ";" ;
+ CHR(34) + "DIB" + CHR(34) + ";" ;
+ CHR(34) + "DDB" + CHR(34)
@ PROW()+1,000 SAY ""
Return




