FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Error Excel
Posts: 149
Joined: Thu Jun 21, 2007 03:26 PM
Error Excel
Posted: Wed Jun 15, 2011 06:03 PM

Hola, tengo una aplicacion en la cual recorro una dbf y armo excel, pintando de color el fondo y la fuente de cada celda, segun un valor de la tabla. Si corro con una dbf de entre 80 y 150 registros, anda todo OK. Si corro con mas, aparece el error que pego debajo.
Puse un log para ver si el error aparecía en el mismo lugar, o alte algun valor en particular, no. Es al azar. Siempre se da que la dbf supera los 150 registros, promedio. Cuando pasa eso siempre da error. Ni siquiera el error (aca es en la linea 13543 de mi prg) es en el mismo lugar.

Uso Fivewin for harbour 10.04

Application

Path and name: c:\FW192\SAROSSX\REP_ART.EXE (32 bits)
Size: 2,060,800 bytes
Time from start: 0 hours 4 mins 59 secs
Error occurred at: 15-06-2011, 14:54:17
Error description: Error BASE/1005 No exported variable: COLOR
Args:
[ 1] = L .F.
[ 2] = N 16777215

Stack Calls

Called from: => _COLOR(0)
Called from: REP_ART.prg => IM_TABLE(13543)
Called from: REP_ART.prg => (b)ART_TABLERO(13269)
Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK(176)
Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT(1446)
Called from: .\source\classes\WINDOW.PRG => _FWH(3378)
Called from: => SENDMESSAGE(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND(408)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT(944)
Called from: => DIALOGBOX(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
Called from: REP_ART.prg => ART_TABLERO(13271)
Called from: REP_ART.prg => REPST(157)
Called from: REP_ART.prg => MAIN(80)

pego el codigo; gracias desde ya.

//*****
//aca creo el excel

Function creatabla(cTabla, Xlistad, xlistah)
local aEstructura
local nveces, N, oExcel, oWorkBook, xatt, oSheet

oExcel := CREATEOBJECT( "Excel.Application" )
OEXCEL:DISPLAYALERTS=.F.

oWorkBook := oExcel:WorkBooks:Add()

oSheet := oExcel:ActiveSheet

aEstructura:={}

aadd(aEstructura,{"ART_CODIG","C",16,0})
aadd(aEstructura,{"ART_DESCR","C",40,0})

oSheet:Cells( 1, 1 ):Value = "CODIGO"
oSheet:Cells( 1, 2 ):Value = "DESCRIPCION"

N:=3
sele 99
use &empre\lispre.sx shared
INDEX ON LISPRE->CLI_LISPR TO C:\TEMPO\TMPPAAA5F
go top
do while !eof()

    if lispre->cli_lispr>=RIGHT(xlistad,5) .and. lispre->cli_lispr<=RIGHT(xlistah,5)
            aadd(aEstructura,{alltrim(lispre->cli_lispr)+"DES","C",40,0})
            aadd(aEstructura,{alltrim(lispre->cli_lispr)+"PRE","N",19,4})
            aadd(aEstructura,{alltrim(lispre->cli_lispr)+"MGL","N",19,4})
            aadd(aEstructura,{alltrim(lispre->cli_lispr)+"COS","N",19,4})
            aadd(aEstructura,{alltrim(lispre->cli_lispr)+"MGC","N",19,4})

            oSheet:Cells( 1, N ):Value = alltrim(lispre->cli_lispr)+"DES"
            N:=N+1
            oSheet:Cells( 1, N ):Value = alltrim(lispre->cli_lispr)+"PRE"
            N:=N+1
            oSheet:Cells( 1, N ):Value = alltrim(lispre->cli_lispr)+"MGL"
            N:=N+1
            oSheet:Cells( 1, N ):Value = alltrim(lispre->cli_lispr)+"COS"
            N:=N+1
            oSheet:Cells( 1, N ):Value = alltrim(lispre->cli_lispr)+"MGC"
            N:=N+1

    endif

    SKIP

enddo

IF XLISTAH="Precio de venta Maestro de Productos - ZZZZZ"

            aadd(aEstructura,{"PRMAEDES","C",40,0})
            aadd(aEstructura,{"PRMAE"+"PRE","N",19,4})
            aadd(aEstructura,{"PRMAE"+"MGL","N",19,4})
            aadd(aEstructura,{"PRMAE"+"COS","N",19,4})
            aadd(aEstructura,{"PRMAE"+"MGC","N",19,4})

            oSheet:Cells( 1, N ):Value = "PRMAE"+"DES"
            N:=N+1
            oSheet:Cells( 1, N ):Value = "PRMAE"+"PRE"
            N:=N+1
            oSheet:Cells( 1, N ):Value = "PRMAE"+"MGL"
            N:=N+1
            oSheet:Cells( 1, N ):Value = "PRMAE"+"COS"
            N:=N+1
            oSheet:Cells( 1, N ):Value = "PRMAE"+"MGC"
            N:=N+1

ENDIF

aadd(aEstructura,{"MARCA","C",1,0})
aadd(aEstructura,{"ART_PREVT","N",19,4})
aadd(aEstructura,{"ART_PRECR","N",19,4})
aadd(aEstructura,{"ART_PREUCO","N",19,4})
aadd(aEstructura,{"ART_AUMEN","N",19,4})
aadd(aEstructura,{"DIFE","N",19,4})
aadd(aEstructura,{"ART_IVA","N",19,4})

dbcreate(ctabla,aEstructura)

xatt:=array(3)
xatt[1]:=oExcel
xatt[2]:=oWorkBook
xatt[3]:=oSheet

return xatt

//*****

este es el while

sele 90
go top
do while !eof()
xart_codig:=r_a_ta->art_codig
XART_DESCR:=R_A_TA->ART_DESCR

    oSheet:Cells( XFILA, 1 ):Value = XART_CODIG
    oSheet:Cells( XFILA, 2 ):Value = XART_DESCR

    xnt:=3
    FWRITE( NOME_ARQ, "Fila:"+str(xfila)+chr(13)+chr(10)+"N:"+str(xnt)+chr(13)+chr(10)+xart_codig+chr(13)+chr(10)+"**************"+chr(13)+chr(10) )
    sele 99
    go top
    do while !eof()
            xcli_lispr:=lispre->cli_lispr
            xdescrip:=lispre->descrip
            xinclui:=lispre->iniva

            sele 98
            set softseek off
            seek xcli_lispr+xart_codig
            if !eof()
                    xprecio:=precio->precio
                    xmargen:=precio->margen
            else
                    xprecio:=0
                    xmargen:=0
            endif

            sele 90
            fieldput(n,xdescrip)

            if xinclui=.t.
                    xprecio:=xprecio/(1+r_a_ta->art_iva/100)
            endif
            fieldput(xnt+1,xprecio)

            fieldput(xnt+2,xmargen)

            xcosto1:=costo(xcosto,xcostoru,xart_codig,xmci)
            sele 90
            fieldput(xnt+3,xcosto1)

            fieldput(xnt+4,(xprecio/xcosto1-1)*100)

            FWRITE( NOME_ARQ, "Fila:"+str(xfila)+chr(13)+chr(10)+"N:"+str(xnt)+chr(13)+chr(10)+xart_codig+chr(13)+chr(10)+"**************"+chr(13)+chr(10) )
            oSheet:Cells( XFILA, xnt ):Value = alltrim(xcli_lispr)+" - "+XDESCRIP
            oSheet:Cells( XFILA, xnt+1 ):Value = XPRECIO
            oSheet:Cells( XFILA, xnt+2 ):Value = XMARGEN
            oSheet:Cells( XFILA, xnt+3 ):Value = XCOSTO1
            oSheet:Cells( XFILA, xnt+4 ):Value = (xprecio/xcosto1-1)*100

            xescriti:=.f.

            if (xprecio/xcosto1-1)*100<=xalerta*xmargen/100 .and. (xprecio/xcosto1-1)*100>xcritico*xmargen/100
                    xescriti:=.t.
                    xalgun_c:=.t.
                    sele 90
                    r_a_ta->marca:="A"
                    FWRITE( NOME_ARQ, "Fila:"+str(xfila)+chr(13)+chr(10)+"N:"+str(xnt)+chr(13)+chr(10)+xart_codig+chr(13)+chr(10)+"**************"+chr(13)+chr(10) )
                    oSheet:Cells( XFILA, xnt ):interior:Color = RGB(255,255,0)
                    oSheet:Cells( XFILA, xnt+1 ):interior:Color = RGB(255,255,0)
                    oSheet:Cells( XFILA, xnt+2 ):interior:Color = RGB(255,255,0)
                    oSheet:Cells( XFILA, xnt+3 ):interior:Color = RGB(255,255,0)
                    oSheet:Cells( XFILA, xnt+4 ):interior:Color = RGB(255,255,0)

                    oSheet:Cells( XFILA, xnt ):Font:Color = rgb(0,0,0)
                    oSheet:Cells( XFILA, xnt+1 ):Font:Color = rgb(0,0,0)
                    oSheet:Cells( XFILA, xnt+2 ):Font:Color = rgb(0,0,0)
                    oSheet:Cells( XFILA, xnt+3 ):Font:Color = rgb(0,0,0)
                    oSheet:Cells( XFILA, xnt+4 ):Font:Color = rgb(0,0,0)
            endif

            if (xprecio/xcosto1-1)*100<=xcritico*xmargen/100
                    xescriti:=.t.
                    xalgun_c:=.t.
                    sele 90
                    r_a_ta->marca:="C"
                    FWRITE( NOME_ARQ, "Fila:"+str(xfila)+chr(13)+chr(10)+"N:"+str(xnt)+chr(13)+chr(10)+xart_codig+chr(13)+chr(10)+"**************"+chr(13)+chr(10) )
                    /*
                    oSheet:Cells( XFILA, xnt ):interior:Color = 255
                    oSheet:Cells( XFILA, xnt+1 ):interior:Color = 255
                    oSheet:Cells( XFILA, xnt+2 ):interior:Color = 255
                    oSheet:Cells( XFILA, xnt+3 ):interior:Color = 255
                    oSheet:Cells( XFILA, xnt+4 ):interior:Color = 255
                    */
                    oSheet:Cells( XFILA, xnt ):interior:Color = RGB(255,0,0)
                    oSheet:Cells( XFILA, xnt+1 ):interior:Color = RGB(255,0,0)
                    oSheet:Cells( XFILA, xnt+2 ):interior:Color = RGB(255,0,0)
                    oSheet:Cells( XFILA, xnt+3 ):interior:Color = RGB(255,0,0)
                    oSheet:Cells( XFILA, xnt+4 ):interior:Color = RGB(255,0,0)


                    oSheet:Cells( XFILA, xnt ):Font:Color = rgb(255,255,255)
                    oSheet:Cells( XFILA, xnt+1 ):Font:Color = rgb(255,255,255)
                    oSheet:Cells( XFILA, xnt+2 ):Font:Color = rgb(255,255,255)
                    oSheet:Cells( XFILA, xnt+3 ):Font:Color = rgb(255,255,255)
                    oSheet:Cells( XFILA, xnt+4 ):Font:Color = rgb(255,255,255)

            endif


            SELE 90
            IF xescriti=.f. .AND. XSOLOC=.T.
                    FWRITE( NOME_ARQ, "Fila:"+str(xfila)+chr(13)+chr(10)+"N:"+str(xnt)+chr(13)+chr(10)+xart_codig+chr(13)+chr(10)+"**************"+chr(13)+chr(10) )
                    oSheet:Cells( XFILA, xnt ):Value = " "
                    oSheet:Cells( XFILA, xnt+1 ):Value = " "
                    oSheet:Cells( XFILA, xnt+2 ):Value = " "
                    oSheet:Cells( XFILA, xnt+3 ):Value = " "
                    oSheet:Cells( XFILA, xnt+4 ):Value = " "

            ENDIF

            xnt:=xnt+5

            sele 99
            skip
    enddo

    IF XLISTAH="Precio de venta Maestro de Productos - ZZZZZ"

            SELE 90
            XPRECIO:=R_A_TA->ART_PREVT
            XMARGEN:=R_A_TA->ART_AUMEN

            fieldput(xnt,"MAESTRO ARTICULOS")

            fieldput(xnt+1,xprecio)

            fieldput(xnt+2,xmargen)

            xcosto1:=costo(xcosto,xcostoru,xart_codig,xmci)
            sele 90
            fieldput(xnt+3,xcosto1)

            fieldput(xnt+4,(xprecio/xcosto1-1)*100)

            oSheet:Cells( XFILA, xnt ):Value = "MAESTRO DE ARTICULOS"
            if xmvi=.t.
                    xprecio:=xprecio/(1+r_a_ta->art_iva/100)
            endif
            FWRITE( NOME_ARQ, "Fila:"+str(xfila)+chr(13)+chr(10)+"N:"+str(xnt)+chr(13)+chr(10)+xart_codig+chr(13)+chr(10)+"**************"+chr(13)+chr(10) )
            oSheet:Cells( XFILA, xnt+1 ):Value = XPRECIO
            oSheet:Cells( XFILA, xnt+2 ):Value = XMARGEN
            oSheet:Cells( XFILA, xnt+3 ):Value = XCOSTO1
            oSheet:Cells( XFILA, xnt+4 ):Value = (xprecio/xcosto1-1)*100

            xescriti:=.f.

            if (xprecio/xcosto1-1)*100<=xalerta*xmargen/100 .and. (xprecio/xcosto1-1)*100>xcritico*xmargen/100
                    xescriti:=.t.
                    xalgun_c:=.t.
                    sele 90
                    r_a_ta->marca:="A"

                    FWRITE( NOME_ARQ, "Fila:"+str(xfila)+chr(13)+chr(10)+"N:"+str(xnt)+chr(13)+chr(10)+xart_codig+chr(13)+chr(10)+"**************"+chr(13)+chr(10) )
                    oSheet:Cells( XFILA, xnt ):interior:Color = RGB(255,255,0)
                    oSheet:Cells( XFILA, xnt+1 ):interior:Color = RGB(255,255,0)
                    oSheet:Cells( XFILA, xnt+2 ):interior:Color = RGB(255,255,0)
                    oSheet:Cells( XFILA, xnt+3 ):interior:Color = RGB(255,255,0)
                    oSheet:Cells( XFILA, xnt+4 ):interior:Color = RGB(255,255,0)

                    oSheet:Cells( XFILA, xnt ):Font:Color = rgb(0,0,0)
                    oSheet:Cells( XFILA, xnt+1 ):Font:Color = rgb(0,0,0)
                    oSheet:Cells( XFILA, xnt+2 ):Font:Color = rgb(0,0,0)
                    oSheet:Cells( XFILA, xnt+3 ):Font:Color = rgb(0,0,0)
                    oSheet:Cells( XFILA, xnt+4 ):Font:Color = rgb(0,0,0)

            endif

            if (xprecio/xcosto1-1)*100<=xcritico*xmargen/100
                    xescriti:=.t.
                    xalgun_c:=.t.
                    sele 90
                    r_a_ta->marca:="C"

                    FWRITE( NOME_ARQ, "Fila:"+str(xfila)+chr(13)+chr(10)+"N:"+str(xnt)+chr(13)+chr(10)+xart_codig+chr(13)+chr(10)+"**************"+chr(13)+chr(10) )
                    /*
                    oSheet:Cells( XFILA, xnt ):interior:Color = 255
                    oSheet:Cells( XFILA, xnt+1 ):interior:Color = 255
                    oSheet:Cells( XFILA, xnt+2 ):interior:Color = 255
                    oSheet:Cells( XFILA, xnt+3 ):interior:Color = 255
                    oSheet:Cells( XFILA, xnt+4 ):interior:Color = 255
                    */
                    oSheet:Cells( XFILA, xnt ):interior:Color = RGB(255,0,0)
                    oSheet:Cells( XFILA, xnt+1 ):interior:Color = RGB(255,0,0)
                    oSheet:Cells( XFILA, xnt+2 ):interior:Color = RGB(255,0,0)
                    oSheet:Cells( XFILA, xnt+3 ):interior:Color = RGB(255,0,0)
                    oSheet:Cells( XFILA, xnt+4 ):interior:Color = RGB(255,0,0)


                    oSheet:Cells( XFILA, xnt ):Font:Color = rgb(255,255,255)
                    oSheet:Cells( XFILA, xnt+1 ):Font:Color = rgb(255,255,255)
                    oSheet:Cells( XFILA, xnt+2 ):Font:Color = rgb(255,255,255)
                    oSheet:Cells( XFILA, xnt+3 ):Font:Color = rgb(255,255,255)
                    oSheet:Cells( XFILA, xnt+4 ):Font:Color = rgb(255,255,255)

            endif

            SELE 90
            IF xescriti=.f. .AND. XSOLOC=.T.
                    oSheet:Cells( XFILA, xnt ):Value = " "
                    oSheet:Cells( XFILA, xnt+1 ):Value = " "
                    oSheet:Cells( XFILA, xnt+2 ):Value = " "
                    oSheet:Cells( XFILA, xnt+3 ):Value = " "
                    oSheet:Cells( XFILA, xnt+4 ):Value = " "

            ENDIF


            sele 90
            r_a_ta->dife:=abs(xmargen-(xprecio/xcosto1-1)*100)

    ENDIF

    if xsoloc=.t.
            if xalgun_c=.t.
                    XFILA:=XFILA+1
            else
                    oSheet:Cells( XFILA, 1 ):Value = " "
                    oSheet:Cells( XFILA, 2 ):Value = " "
            endif
    else
            XFILA:=XFILA+1
    endif
    xalgun_c:=.f.

    sele 90
    skip

enddo

Continue the discussion