FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Mensaje Error importando SLK
Posts: 428
Joined: Thu Oct 19, 2006 12:28 PM
Mensaje Error importando SLK
Posted: Sat Jul 25, 2020 08:15 AM
Buenas

Tengo el siguiente codigo;

Code (fw): Select all Collapse
Function Recalvi()
聽 聽 聽 LOCAL oExcel, oHoja, nRows, nCols,nRow, nCol,nmanejador,a,numero,numeroa
聽 聽 聽 local nempresa:="R"
聽 聽 聽 local ldrive:=Publicas:cUnidad+"\ficheros\"
聽 聽 聽 local expedi,consigna,albaran,domicilio,cp,pobla,peso,bultos,reembo,tipo
聽 聽 聽 local edisco :='01481000.txt'
聽 聽 聽 local cFile := cGetFile( "Excel (*.slk)| *.slk|" + 聽 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Excel 聽 聽(*.xls)| *.xls|" + 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Excel 聽 聽(*.xlsx)| *.xlsx|" 聽 聽 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽,"Selecciona un formato de Excel", 4 )

聽 聽 聽 oExcel:= TOleAuto():New( "Excel.Application" )
* 聽 聽 cfile :=cGetFile("C:\*.Slk", "Seleccione Fichero")
聽 聽 聽 If empty( cfile )
聽 聽 聽 聽 msgwait("Fichero no valido",3)
聽 聽 聽 聽 Retur nil
聽 聽 聽 Endif
聽 聽 聽 聽 oExcel:WorkBooks:Open(cfile) 
聽 聽 聽 聽 oHoja=oExcel:ActiveSheet 
聽 聽 聽 聽 nRows := oHoja:UsedRange:Count()
聽 聽 聽 聽 nCols := oHoja:UsedRange:Count()
聽 聽 聽 聽 if (nManejador:=fCreate(lDrive + edisco))<>-1
聽 聽 聽 聽 msgwait("Importando Fichero","ESPERA")
聽 聽 聽 聽 For nRow := 4 TO nRows 
聽 聽 聽 聽 聽 聽 if (oHoja:Cells(nRow,1):Value)<> Nil
聽 聽 聽 聽 聽 聽 聽 聽 numeroa:=substr(oHoja:Cells(nRow,8):Value,6)
聽 聽 聽 聽 聽 聽 聽 聽 consigna:= oHoja:Cells(nRow,2):Value
聽 聽 聽 聽 聽 聽 聽 聽 domicilio:= oHoja:Cells(nRow,3):Value
聽 聽 聽 聽 聽 聽 聽 聽 cp:= substr(oHoja:Cells(nRow,4):Value,1,5)
聽 聽 聽 聽 聽 聽 聽 聽 pobla:= substr(oHoja:Cells(nRow,4):Value,9)
聽 聽 聽 聽 聽 聽 聽 聽 peso:= 1
聽 聽 聽 聽 聽 聽 聽 聽 if valtype(oHoja:Cells(nRow,6):Value) = 'C'
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 bultos:=val(oHoja:Cells(nRow,6):Value)
聽 聽 聽 聽 聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 bultos:= oHoja:Cells(nRow,6):Value
聽 聽 聽 聽 聽 聽 聽 聽 endif
聽 聽聽聽 聽 聽 聽 聽 聽 reembo:= "0,00"
聽 聽 聽 聽 聽 聽 聽 聽 reembo:= strtran(reembo,",",".")
聽 聽 聽 聽 聽 聽 聽 聽 tipo:= "1"
聽 聽 聽 聽 聽 聽 聽 聽 expedi := nempresa+numeroa
聽 聽 聽 聽 聽 聽 聽 聽 fwrite(nManejador,expedi+;聽 聽 聽 聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 space(9)+;聽 聽 聽 聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 padr(alltrim(consigna),32)+;聽 聽 聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 padr(alltrim(domicilio),32)+; 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 padr(alltrim(cp),5)+;聽 聽聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 padr(alltrim(pobla),27)+;聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 strzero(bultos,4)+;
聽 聽 聽 聽 聽 聽 聽 聽 strzero(peso,5)+;聽 聽聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 "000.00"+;
聽 聽 聽 聽 聽 聽 聽 聽 "1"+;
聽 聽 聽 聽 聽 聽 聽 聽 strzero(val(reembo),7,2)+;
聽 聽 聽 聽 聽 聽 聽 聽 space(1)+;
聽 聽 聽 聽 聽 聽 聽 聽 space(35)+;
聽 聽 聽 聽 聽 聽 聽 聽 padr(alltrim(numeroa),12," ")+;聽聽 聽 
聽 聽 聽 聽 聽 聽 聽 聽 chr(13)+chr(10) )
聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 Next nRow
聽 聽 聽 聽 fclose(nManejador)
聽 聽 聽 聽 msgwait("IMPORTACION REALIZADA","ATENCION",2)
聽 聽 else
聽 聽 聽 聽 msgalert("ERROR EN LA IMPORTACION","ATENCION")
聽 聽 聽 聽 endif
聽 聽 聽 聽 oExcel:Quit()
Retu Nil


Cuando importo ficheros slk me da el siguiente error:


Si pincho en No, todo funciona correctamente y continua la ejecuci贸n.
Si pincho en Si, sigue reportandome infinidad de errores hasta que ya no hay mas y continua perfectamente.

La aplicaci贸n es un poco antigua y creo que esta compilada con xharbour y fw en una versi贸n sobre 2015 o as铆, ya que no he podido actualizar a ninguna versi贸n mas actual porque ser铆a muy engorroso.

Habr铆a alguna opci贸n de que no apareciera 茅ste error?

Saludos
--------------------------

Saludos



Jose Luis
Posts: 428
Joined: Thu Oct 19, 2006 12:28 PM
Re: Mensaje Error importando SLK
Posted: Sat Jul 25, 2020 10:25 AM

Buenas de nuevo

Ya esta solucionado

No localizo donde puede estar el error pero eliminado el mensaje, como dije anteriormente todo va perfectamente.

oExcel:DisplayAlerts:=.F.

Saludos

--------------------------

Saludos



Jose Luis

Continue the discussion