edutraini Posted February 1, 2017 Report Share Posted February 1, 2017 Pessoal existe alguma forma de jogar um arquivo excell para dentro de um dbf Quote Link to comment Share on other sites More sharing options...
kapiaba Posted February 1, 2017 Report Share Posted February 1, 2017 Claro. Quote Link to comment Share on other sites More sharing options...
evandro Posted February 1, 2017 Report Share Posted February 1, 2017 Olá, Isto é que é clareza na resposta! Luiz Fernando and kapiaba 2 Quote Link to comment Share on other sites More sharing options...
Jorge Andrade Posted February 2, 2017 Report Share Posted February 2, 2017 Claro. Olá, Isto é que é clareza na resposta! Nem titubeou, foi mais rápido do que tomar um gole da loira nervosa. ahauhauahua kapiaba 1 Quote Link to comment Share on other sites More sharing options...
joaosolution Posted February 2, 2017 Report Share Posted February 2, 2017 Bom dia Segue Exemplo!! // Arquivo base cFile := "Consu.xls" If !File(cDirExcel+"\"+cFile) MsgAlert("Arquivo não econtrado : "+cDirExcel+"\"+cFile,"Verifique") Return .T. Endif oExcel:= TOleauto():New( "Excel.Application") If Ole2TxtError() # "S_OK" MsgInfo("EXCEL não está instalado nesta máquina."+CRLF+" Impossível gerar planilha","ATENÇÃO") Return nil Endif oExcel:Workbooks:Open( cDirExcel+"\"+cFile ) aDados:={} nCol := 1 nLin := 1 oFolha := oExcel:Get( "ActiveSheet") While .T. If Empty(oFolha:Cells(nLin, 1):Value) Exit Endif cColA := oFolha:Cells(nLin, 1):Value cColB := oFolha:Cells(nLin, 2):Value cColC := oFolha:Cells(nLin, 3):Value AADD( aDados, {cColA, cColB, cColC}) nLin++ End oExcel:AlertBeforeOverwriting = .F. oExcel:DisplayAlerts = .F. oExcel:Visible = .T. xBrowse(aDados) Att João Bosco kapiaba and jfaguiar 2 Quote Link to comment Share on other sites More sharing options...
edutraini Posted February 2, 2017 Author Report Share Posted February 2, 2017 Bom dia, Joao Muito obrigado vou testar abraco Quote Link to comment Share on other sites More sharing options...
rubensma Posted February 2, 2017 Report Share Posted February 2, 2017 Bom-dia Outro exemplo testando formatações function gerarlote(vTot,oMeter,oText,nOption,numlote) LOCAL oExcel, oHoja dbSelectArea( "con" ) // seleciona arquivo contábil con->( dbGoTop() ) vNomenum := "Lote_"+"&numlote."+".txt" // usando macro precisa por ponto if nOption = 2 // foi selecionado arquivo texto copy to &vNomenum delimited // separado por virgula WinExec("Notepad &vNomenum",1) // 1 = diretorio corrente return nil endif nRow := 1 // reinicia a linha da planilha nCount := 0 // Zerar o total do meter oExcel := TOleAuto():New( "Excel.Application" ) oExcel:WorkBooks:Add() oHoja := oExcel:Get( "ActiveSheet" ) *::: Seleciona a guia BOLETINS para preenchimento oExcel:Sheets("Plan1"):Name := "Boletins" // nomear a 1ª guia oExcel:Sheets("Boletins"):Select() // selecionar a guia nomeada oMeter:cCaption := "Lote dos Boletins" oHoja := oExcel:Get( "ActiveSheet" ) FOR nCol := 1 TO FCOUNT() // percorrer todas as colunas oHoja:Cells( nRow, nCol ):Value := FieldName( nCol ) // linhadegrade(oHoja,nRow,nCol) // contorno da célula NEXT DO WHILE .NOT. EOF() nRow++ FOR nCol := 1 TO FCOUNT() if ValType( FieldGet( nCol ) ) = "D" // se for campo data converte p/string oHoja:Cells( nRow, nCol ):Value := dtoc(FieldGet( nCol )) else if ValType( FieldGet( nCol ) ) = "N" // se for campo numérico com valor oHoja:Cells( nRow, 4 ):NumberFormat = "###.##0,00" // Formata numerico valor oHoja:Cells( nRow, 28 ):NumberFormat = "###.##0,00" // Formata numerico oHoja:Cells( nRow, nCol ):Value := FieldGet( nCol ) else if ValType( FieldGet( nCol ) ) = "L" // se for campo lógico oHoja:Cells( nRow, nCol ):Value := FieldGet( nCol ) else oHoja:Cells( nRow, nCol ):NumberFormat = "@" // FORMATAR TEXTO oHoja:Cells( nRow, nCol ):Value := alltrim(FieldGet( nCol )) endif endif endif // linhadegrade(oHoja,nRow,nCol) NEXT oMeter:Set(++nCount) oMeter:nTotal := con->( RecCount()*1 ) oText:SetText("Exportando a Guia Boletins!"+chr(13)+; "Processando Registro : "+str(nCount,6)+"/"+str(oMeter:nTotal,6) ) con->( DBSKIP(1) ) ENDDO FOR nCol := 1 TO FCOUNT() oHoja:Columns( nCol ):AutoFit() // ajusta o tamanho das colunas NEXT cPath := CURDRIVE() + ":\" + GETCURDIR() // caminho do diretorio corrente cFilexls := cPath //+"\"+cFile vNomenum := "Lote_"+"&numlote."+".xls" // nome do arquivo a gravar cArqui := cPath + "\" + vNomenum // caminho do diretorio corrente oExcel:ActiveWorkBook:SaveAs( cArqui ) // salva como o arquivo msginfo( "O arquivo foi gerado e gravado com sucesso."+chr(13)+; "Será aberto no Excel.","Informação") cMod := "LOTE GERADO" cSer := "Foi gerado o arquivo nome: &vNomenum - Lote: &numlote" registra( cMod , cSer ) oExcel:Visible := .T. hWnd:=oExcel:hWnd ShowWindow(hWnd, 3) //3 = Maximizada, 1=Normal e 6 = Minimizada BringWindowToTop(hWnd) con->( dbZap() ) return nil kapiaba 1 Quote Link to comment Share on other sites More sharing options...
edutraini Posted February 2, 2017 Author Report Share Posted February 2, 2017 Obrigado a todos. Deu tudo certo kapiaba 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.