Barra de progreso

110 views
Skip to first unread message

Enrique

unread,
Oct 10, 2017, 4:27:13 PM10/10/17
to Comunidad de Visual Foxpro en Español

Hola Grupo: Tengo el siguiente problema y no puedo darle solución. Estoy intentando implementar una barra de progreso y no entiendo la rutina que encontré investigando,  La he puesto de muchas formas y no encuentro la solución. A continuación el código marcado donde esta mi problema;


store 0 to tot,tot1,tot2,tot3,tot4,tot5,tot6,tot7,tot8,tot9

select muni.corr,cta,compro,fecha,nombre,ndoc,rut,ndec,bruto,retenido,liquido FROM muni ;
 where fecha >= mdia1  AND  fecha <= mdia2 ;
       into cursor micursor

messagebox("Hay " + transform(_tally) + " Registros Localizados")
SELECT micursor

wait'Espere Un Momento, Exportando Datos' window nowait

_screen.mousepointer=14
TmpSheet=GetObject('','Excel.Sheet')
XLApp=TmpSheet.Application
XLApp.visible=.T.
XLApp.workbooks.add()
XLSheet=XLApp.ActiveSheet

XLSheet.Cells(1,1)="Resumen del Libro"
XLSheet.Cells(1,1).font.bold=.T.
XLSheet.Cells(1,1).font.size="10"
XLSheet.Cells(1,1).font.name="Arial"

XLSheet.Cells(1,11)="Usuario;" + mNombre
XLSheet.Cells(1,11).font.bold=.T.
XLSheet.Cells(1,11).font.size="07"
XLSheet.Cells(1,11).font.name="Arial"

XLSheet.Cells(2,4)="Del " + dtoc(mdia1)+ " Al " +DTOC(mdia2)
XLSheet.Cells(2,4).font.bold=.T.
XLSheet.Cells(2,4).font.size="08"
XLSheet.Cells(2,4).font.name="Arial"

XLSheet.Cells(3,1)="Corr"
XLSheet.Cells(3,1).font.bold=.T.
XLSheet.Cells(3,1).font.size="08"
XLSheet.Cells(3,1).font.name="Arial"

XLSheet.Cells(3,2)="Cuenta"
XLSheet.Cells(3,2).font.bold=.T.
XLSheet.Cells(3,2).font.size="08"
XLSheet.Cells(3,2).font.name="Arial"

XLSheet.Cells(3,3)="Comprobante"
XLSheet.Cells(3,3).font.bold=.T.
XLSheet.Cells(3,3).font.size="08"
XLSheet.Cells(3,3).font.name="Arial"

XLSheet.Cells(3,4)="Fecha"
XLSheet.Cells(3,4).font.bold=.T.
XLSheet.Cells(3,4).font.size="08"
XLSheet.Cells(3,4).font.name="Arial"

XLSheet.Cells(3,5)="Nombre"
XLSheet.Cells(3,5).font.bold=.T.
XLSheet.Cells(3,5).font.size="08"
XLSheet.Cells(3,5).font.name="Arial"

XLSheet.Cells(3,6)="Boleta"
XLSheet.Cells(3,6).font.bold=.T.
XLSheet.Cells(3,6).font.size="08"
XLSheet.Cells(3,6).font.name="Arial"

XLSheet.Cells(3,7)="Rut"
XLSheet.Cells(3,7).font.bold=.T.
XLSheet.Cells(3,7).font.size="08"
XLSheet.Cells(3,7).font.name="Arial"

XLSheet.Cells(3,8)="Decreto"
XLSheet.Cells(3,8).font.bold=.T.
XLSheet.Cells(3,8).font.size="08"
XLSheet.Cells(3,8).font.name="Arial"

XLSheet.Cells(3,9)="Bruto"
XLSheet.Cells(3,9).font.bold=.T.
XLSheet.Cells(3,9).font.size="08"
XLSheet.Cells(3,9).font.name="Arial"

XLSheet.Cells(3,10)="Retención"
XLSheet.Cells(3,10).font.bold=.T.
XLSheet.Cells(3,10).font.size="08"
XLSheet.Cells(3,10).font.name="Arial"

XLSheet.Cells(3,11)="Liquido"
XLSheet.Cells(3,11).font.bold=.T.
XLSheet.Cells(3,11).font.size="08"
XLSheet.Cells(3,11).font.name="Arial"


sele micursor

Fila=4

l=100     && de barra progreso
c=1        && de barra progreso

SCAN

   XLSheet.Cells(FILA,01).font.size="09"
   XLSheet.Cells(Fila,01)=corr
  
   XLSheet.Cells(FILA,02).font.size="09"
   XLSheet.Cells(Fila,02)=cta
  
   XLSheet.Cells(FILA,03).font.size="09"
   XLSheet.Cells(Fila,03)=compro
  
   IF fecha=ctod(" ") then
    ELSE
      XLSheet.Cells(FILA,04).font.size="09"
      XLSheet.Cells(Fila,04)=fecha
   ENDIF
  
   XLSheet.Cells(FILA,05).font.size="09"
   XLSheet.Cells(Fila,05)=nombre
  
   XLSheet.Cells(FILA,06).font.size="09"
   XLSheet.Cells(Fila,06)=ndoc
  
   XLSheet.Cells(FILA,07).font.size="09"
   XLSheet.Cells(Fila,07)=rut
  
   XLSheet.Cells(FILA,08).font.size="09"
   XLSheet.Cells(Fila,08)=ndec
     
   XLSheet.Cells(FILA,09).font.size="09"
   XLSheet.Cells(Fila,09)=bruto
  
   XLSheet.Cells(FILA,10).font.size="09"
   XLSheet.Cells(Fila,10)=retenido
  
   XLSheet.Cells(FILA,11).font.size="09"
   XLSheet.Cells(Fila,11)=liquido
 
  tot=tot+1
  Fila=Fila+1
  tot1=tot1+fila
  tot3=tot3+bruto
  tot4=tot4+retenido
  tot5=tot5+liquido
  tot8=tot8
   
  DO WHILE l>vimp                       && Aquí tengo el problema
           vimp=vimp+5
           c=c+1   
             THISFORM.ProgressBarXP1.Graficar(vimp)
            THISFORM.ProgressBarXP2.Graficar(vimp)
            THISFORM.ProgressBarXP3.Graficar(vimp)
            vmira=""
            vmira=STR(vimp,3)+"%"
            thisform.label10.Caption=vmira 
  ENDDO                                 &&

 
ENDSCAN   

_screen.mousepointer=0
Thisform.refresh

Les agradecería mucho si me pueden orientar o dar solución a la barra de progreso, ya que nunca la he realizado.


Saludos cordiales

Dsan

unread,
Oct 11, 2017, 2:10:23 AM10/11/17
to publice...@googlegroups.com

Hola Enrique hace algun tiempo hice algo para alguien, le puse barra 1 con objecto, antes lo tenia solo el ejemplo dos ya que no queria el solicitante crear objecto en este caso medidor.

te lo adjunto, cambiar la ext. txt por rar, sino tiene habilitado ver tus extensiones de archivo ve al explorador quita ocultar en opciones de carpetas y busquedas...

Saludes

Dsanchez


Ejemplo Barra.txt

Enrique

unread,
Oct 11, 2017, 9:18:26 AM10/11/17
to Comunidad de Visual Foxpro en Español

Hola  D Sánchez: Muchas gracias por responder y mandar el formulario de ejemplo.

Estoy dándole una mirada y observando cómo poder implementarlo en mí código. Lo que veo es que según creo estas líneas:


Select tmpExcel
For i=1 To 400
    Append Blank
    Rlock()
    Replace codigo With i, Descrip With 'Codigo N°. '+ Padl(Alltrim(Str(i)),3,'0')
Endfor


Entonces estas líneas seleccionan 400 registros y yo realizo una consulta que puede traer 300 y/o más de 4.000 registros según el rango de fechas que seleccione el usuario. ¿Cómo le doy entonces si yo tengo ésta consulta?


select muni.corr,cta,compro,fecha,nombre,ndoc,rut,ndec,bruto,retenido,liquido FROM muni ;
 where fecha >= mdia1  AND  fecha <= mdia2 ;
       into cursor micursor

Nuevamente muchas gracias por tu respuesta y ayuda.

Saludos cordiales.

Dsan

unread,
Oct 11, 2017, 10:50:52 AM10/11/17
to publice...@googlegroups.com
esas líneas representan  tu información la lleno sólo para tener datos que mostrar eso no iría en tu adaptación.

Saludes


Enrique

unread,
Oct 11, 2017, 10:56:01 AM10/11/17
to Comunidad de Visual Foxpro en Español

Listo, Resulto: Dejo la rutina por si algún novato lo necesita. Muchas gracias D Sánchez.
Exportar a Excel desde VFP

&& Autor: D Sanchez
set safety off
mDia1=THISFORM.mDia1.Value
mDia2=THISFORM.mDia2.Value
mNombre=THISFORM.mNombre.Value

IF empty(thisform.mdia1.Value)
     wait wind chr(13)+"Defina Fechas..."+chr(13) time 1
     thisform.mdia1.SetFocus
     RETURN
ENDIF
IF empty(thisform.mdia2.Value)
     wait wind chr(13)+"Defina Fecha de Corte..."+chr(13) time 1
     thisform.mdia2.SetFocus
     RETURN
ENDIF

set century on
THISFORM.mdia1.Value=mdia1
THISFORM.mdia2.Value=mdia2


store 0 to tot,tot1,tot2,tot3,tot4,tot5,tot6,tot7,tot8,tot9

select muni.corr,cta,compro,fecha,nombre,ndoc,rut,ndec,bruto,retenido,liquido FROM muni ;
 where fecha >= mdia1  AND  fecha <= mdia2 ;
       into cursor micursor

Thisform.MousePointer = 11
Thisform.medidor.Visible = .t.
Local Oexcel As Excel.Application, vFila as Integer
m.Oexcel = Createobject("Excel.application")
If Vartype(Oexcel,.T.) != 'O'
    Messagebox("Microsoft Excel no esta instalado",0+16, "Alerta")
    m.Oexcel = Null
    Release Oexcel
    Thisform.MousePointer = 0
    Thisform.medidor.Visible = .F.
    Return .F.
Endif

m.Oexcel.Visible = .T.
m.Oexcel.Application.WindowState = -4137
m.Oexcel.Workbooks.Add
oexcel.activeworkbook.activesheet.name =  "Pagina1"

Create Cursor tmpExcel (codigo Int, Descrip c(20))
Select micursor

m.vFila = 1

m.oexcel.activeworkbook.activesheet.cells(m.vFila,3).value="Resumen del Libro"
m.oexcel.activeworkbook.activesheet.cells(m.vFila,3).FONT.NAME = "Arial"
m.oexcel.activeworkbook.activesheet.cells(m.vFila,3).FONT.Size = 16
m.oexcel.activeworkbook.activesheet.cells(m.vFila,3).FONT.Bold = .T.
m.vFila = m.vFila + 1

oexcel.range(oexcel.cells(1, 3), oexcel.cells(5,3)).HorizontalAlignment = 3  && 4 for Right Alignment, 3 for Center and 2 for Left
m.vFila = 4
m.oexcel.activeworkbook.activesheet.cells(m.vFila,1).value="Corr"
m.oexcel.activeworkbook.activesheet.Columns("A:A").ColumnWidth = 10

m.oexcel.activeworkbook.activesheet.cells(m.vFila,2).value="Cuenta"
m.oexcel.activeworkbook.activesheet.Columns("B:B").ColumnWidth = 24

m.oexcel.activeworkbook.activesheet.cells(m.vFila,3).value="Comprobante"
m.oexcel.activeworkbook.activesheet.Columns("C:C").ColumnWidth = 24

m.oexcel.activeworkbook.activesheet.cells(m.vFila,4).value="fecha"
m.oexcel.activeworkbook.activesheet.Columns("D:D").ColumnWidth = 24

m.oexcel.activeworkbook.activesheet.cells(m.vFila,5).value="Nombre"
m.oexcel.activeworkbook.activesheet.Columns("E:E").ColumnWidth = 24
 
m.oexcel.activeworkbook.activesheet.cells(m.vFila,6).value="Boleta"
m.oexcel.activeworkbook.activesheet.Columns("F:F").ColumnWidth = 24

m.oexcel.activeworkbook.activesheet.cells(m.vFila,7).value="Rut"
m.oexcel.activeworkbook.activesheet.Columns("G:G").ColumnWidth = 24

m.oexcel.activeworkbook.activesheet.cells(m.vFila,8).value="Decreto"
m.oexcel.activeworkbook.activesheet.Columns("H:H").ColumnWidth = 24

m.oexcel.activeworkbook.activesheet.cells(m.vFila,9).value="Bruto"
m.oexcel.activeworkbook.activesheet.Columns("I:I").ColumnWidth = 24

m.oexcel.activeworkbook.activesheet.cells(m.vFila,10).value="Retención"
m.oexcel.activeworkbook.activesheet.Columns("J:J").ColumnWidth = 24

m.oexcel.activeworkbook.activesheet.cells(m.vFila,11).value="Liquido"
m.oexcel.activeworkbook.activesheet.Columns("X:X").ColumnWidth = 24

thisform.Label7.VISIBLE=.T.

m.vFila = m.vFila + 1
Select micursor
Go Top &&& SI USAS ESCAN ESTO NO ES NECESARIO
vCont = Reccount()
Thisform.medidor.Total=0
Thisform.medidor.Total = vCont
Thisform.medidor.avance = 0
Do While !Eof()
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,1).value =  CORR             &&Padl(Alltrim(Str(CORR)),3,'0')
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,2).value =  CTA                &&RTRIM(descrip)
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,3).value =  ['] + compro
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,4).value =  FECHA
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,5).value =  ['] + NOMBRE
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,6).value =  ['] + NDOC
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,7).value =  ['] + RUT
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,8).value =  NDEC
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,9).value =  BRUTO
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,10).value = RETENIDO
     m.oexcel.activeworkbook.activesheet.cells(m.vFila,11).value = LIQUIDO
 
    m.vFila = m.vFila + 1
    Thisform.medidor.avance = Thisform.medidor.avance + 1
    Thisform.medidor.avanza()
    Skip
Enddo


m.Oexcel = Null
Release Oexcel
Thisform.MousePointer = 0

INKEY(.15) && quitar esto solo pa que veas el efecto que totaliza la barra a 100%
Thisform.medidor.Visible = .F.
thisform.Label7.VISIBLE=.F.






Reply all
Reply to author
Forward
0 new messages