xbrowse to csv

xbrowse to csv

Postby Patricio Avalos Aguirre » Thu Apr 21, 2016 12:01 am

Estimados

alguien abra hecho para xbrowse la exportacion a csv como el toexcel

ya que he visto que el exportacion es mucho mas rapido que excel
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
User avatar
Patricio Avalos Aguirre
 
Posts: 1058
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: xbrowse to csv

Postby nanoespinoza » Sun Jan 21, 2018 6:45 pm

Estimados;

Alguien le dio una solución a este tema? (de xBrowse con Arrays a CSV).

Saludos

Fernando Espinoza A.
nanoespinoza
 
Posts: 135
Joined: Thu Mar 16, 2017 4:08 pm
Location: Ecuador

Re: xbrowse to csv

Postby Patricio Avalos Aguirre » Mon Jan 22, 2018 2:58 pm

Hola no hubo respuesta

si que la hice favor revisar y comentar

Code: Select all  Expand view
  METHOD SetoDbf( oDbf, aCols, lAutoSort, lAutoCols, aRows )
   METHOD ToCsv( cFile, bProgress, aCols )
 



Code: Select all  Expand view
METHOD ToCsv( cFile, bProgress, aCols ) CLASS TXBrowse

   local nKeyNo   := ::KeyNo
   local nRowPos  := ::nRowSel
   local n, uVal := "", c, oCol, nCols
   local nSelect, nInd := 0, nHandle, cPic, nDec, i, cType

   if ::nLen < 1
      return nil
   endif

    //DEFAULT cFile := cNewFileName( ViewUsu():cPathTmp + "\TEMPO", "CSV" )
       cFile := ".\archivo.CSV"

    if (nHandle := FCREATE( cFile, 0 )) == -1
        MsgInfo( "Error al crear el archivo csv","Usuario" )
        return nil
    endif

   if aCols == nil
      aCols    := ::GetVisibleCols()
   endif

   ::GoTop()
   nCols       := Len( aCols )

   for each oCol in aCols
        uVal += ";" + StrTran(cValtochar(oCol:cHeader), CRLF, " " )
   next
    uVal := subst( uVal, 2 ) + CRLF

   nSelect  := Select()

   if bProgress == nil
      if ::oWnd:oMsgBar == nil
         bProgress := { || nil }
      else
         bProgress := { | n, t | ::oWnd:SetMsg( FWString( "To csv" ) + " : " + ;
                                 Ltrim( Str( n ) ) + "/" + Ltrim( Str( t ) ) ), .t. }
      endif
   endif

   REPEAT
      for n := 1 to nCols
            cType := valtype(aCols[n]:value)
            do case
                case cType = "N"
                    cPic := "9999999999"
                    nDec := CuantosDecimales(aCols[n]:value )
                    if nDec > 0
                        cPic += ","
                        for i:= 1 to nDec
                            cPic += "9"
                        next i
                    endif
                    uVal  += iif( n=1, "", ";" )+strtran(ltrim(str(aCols[n]:value,12,nDec )), ".", ",")

                case cType = "D"
                    uVal  += iif( n=1, "", ";" )+dtoc(aCols[n]:Value)

                case cType = "L"
                    uVal  += iif( n=1, "", ";" )+iif( aCols[n]:Value, "SI", "NO" )

                otherwise
                    uVal  += iif( n=1, "", ";" )+strtran(cValtochar(aCols[ n ]:Value), ";","" )
            endcase
        next
        uVal += CRLF

      if !Eval( bProgress, ++nInd, ::nLen )
            exit
        endif

    UNTIL ::Skip( 1 ) == 0

   ::KeyNo     := nKeyNo
   ::nRowSel   := nRowPos
   ::Refresh()
   ::SetFocus()

    FWRITE( nHandle, uVal )
    FCLOSE( nHandle )

    //MsgInfo( "Fue creado el archivo en temporal, debera guardarlo.."+CRLF+"proceder abrir el archivo","Usuario" )
    ShellExecute( WinMain():hWnd, "open", cFile )

return nil

FUNCTION CuantosDecimales(tn )
LOCAL ln := 0
DO WHILE  ln <=2
    IF INT(tn * 10 ^ ln) = tn * 10 ^ ln
        EXIT
    ENDIF
    ln ++
ENDDO

RETURN ln

 
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
User avatar
Patricio Avalos Aguirre
 
Posts: 1058
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: xbrowse to csv

Postby nanoespinoza » Wed Jan 24, 2018 3:43 am

Estimado Patricio

Gracias por compartir. Estoy en las pruebas; me sale error, porque me pide la función WinMain().

Estoy usando el xBrowse de la FWH1709 y xHarbour.

Saludos

Fernando Espinoza A.
nanoespinoza
 
Posts: 135
Joined: Thu Mar 16, 2017 4:08 pm
Location: Ecuador

Re: xbrowse to csv

Postby nageswaragunupudi » Wed Jan 24, 2018 3:37 pm

WndMain()
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10170
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse to csv

Postby nanoespinoza » Thu Jan 25, 2018 1:03 am

Estimado Patrico, Mr. Rao

Con sus aportes funciona bien; únicamente me tocó comentar estas tres líneas, que provocan un error.

//If !Eval( bProgress, ++nInd, ::nLen )
// EXIT
//Endif

Saludos

Fernando Espinoza A.
nanoespinoza
 
Posts: 135
Joined: Thu Mar 16, 2017 4:08 pm
Location: Ecuador


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 2 guests