Lorem Ipsum/DOL Differet Solmena

Separat existentie 2010 Unee MYT por scientie, musica, sport etc, litot Europa usa li sam Vocabular Lingues, differe solmen in li grammatica, li pronunciation. Delete this widget in Dashboard and add yours. This is just an example. Read More

ERROR EXCEL CON POWERBUILDER 12.5

martes, 23 de septiembre de 2014

Amigos buen día.
Tengo un problema con el código que muestro abajo referente a enviar información a un archivo de excel. Cuandolo ejecuto con los pbls todo bien, pero cuando compilo y ejecuto el exe de mi sistema al finalizar en las 2 últimas líneas sale la ventana de error que envío como archivo adjunto.
Espero haya alguna solución.
Saludos

Código :

// Exportar formato de documento a EXCEL

INT li_fila, li_filas, li_conexion, li_rpta
OLEObject xlapp, xlsub
STRING ls_objdw, ls_nomtipdoc, ls_ruta, ls_archivo
 
 ls_objdw = gf_empresa_tipo_documento_validar ( "dwrep", gi_codemp, 10, il_valordw1 )
IF ls_objdw = "" THEN RETURN FALSE

ls_nomtipdoc = TRIM ( gf_tabla_condicion_select ( "nombre", "Tabla_Sunat_Detalle", "cod_tab", "10", "cod_ent", STRING ( il_valordw1 ) ) )
IF ls_nomtipdoc = "" THEN RETURN FALSE

// Creamos el OLEObject y Conectamos Excel y verificamos código de retorno
xlApp = CREATE OLEOBJECT
 
li_conexion = xlApp.CONNECTTONEWOBJECT ( "Excel.Application" )
IF li_conexion < 0 THEN
    DESTROY xlApp
    gf_mensaje_error ( "Error Conectando a Excel", STRING ( li_conexion ), FALSE )
    RETURN FALSE
END IF

xlApp.APPLICATION.WORKBOOKS.OPEN ( gf_carpeta_actual ( "" ) + "Formatos\" + ls_nomtipdoc + ".xls", 0, FALSE )
 
xlApp.Application.VISIBLE = FALSE
xlApp.Application.DISPLAYALERTS = FALSE
xlSub = xlApp.APPLICATION.ACTIVEWORKBOOK.WORKSHEETS [ 1 ]

// Recuperar documento a EXPORTAR
DATASTORE lds_documento
lds_documento = CREATE DATASTORE
lds_documento.DATAOBJECT = ls_objdw
lds_documento.SETTRANSOBJECT ( SQLCA )
li_filas = lds_documento.RETRIEVE ( gi_codemp, il_valordw1, il_valordw2, ill_valordw1, is_valordw1, il_clavedw )
IF li_filas <= 0 THEN RETURN FALSE

CHOOSE CASE il_valordw1
    CASE 1        // Factura
        // Cabecera
        xlSub.CELLS [ 8, 9 ] = lds_documento.object.mondoc [ 1 ]
        xlSub.CELLS [ 8, 3 ] = lds_documento.object.razper [ 1 ]
        xlSub.CELLS [ 8, 5 ] = lds_documento.object.c_dia [ 1 ]
        xlSub.CELLS [ 8, 6 ] = lds_documento.object.c_mes [ 1 ]
        xlSub.CELLS [ 8, 7 ] = lds_documento.object.c_anio [ 1 ]
        xlSub.CELLS [ 9, 3 ] = lds_documento.object.dirper [ 1 ] + " - " + lds_documento.object.ubiper [ 1 ]
        xlSub.CELLS [ 10, 3 ] = lds_documento.object.numdocide [ 1 ] + FILL ( " ", 42 ) + lds_documento.object.numdocgen [ 1 ]
       
        // Pie
        xlSub.CELLS [ 28, 4 ] = lds_documento.object.nomcon [ 1 ]
        xlSub.CELLS [ 30, 3 ] = lds_documento.object.c_totlet [ 1 ]
        xlSub.CELLS [ 30, 7 ] = lds_documento.object.c_subdoc [ 1 ]
        xlSub.CELLS [ 31, 6 ] = lds_documento.object.igvdoc [ 1 ]
        xlSub.CELLS [ 31, 7 ] = lds_documento.object.c_igvdoc [ 1 ]
        xlSub.CELLS [ 32, 7 ] = lds_documento.object.totdoc [ 1 ]

    CASE 9        // Guía de Remisión
        // Cabecera
        xlSub.CELLS [ 9, 3 ] = lds_documento.object.diremp [ 1 ]
        xlSub.CELLS [ 9, 6 ] = lds_documento.object.dirperlle [ 1 ]
        xlSub.CELLS [ 10, 6 ] = lds_documento.object.ubidirlle [ 1 ]
        xlSub.CELLS [ 11, 4 ] = lds_documento.object.fecdoc [ 1 ]
        xlSub.CELLS [ 11, 5 ] = lds_documento.object.razper [ 1 ]
        xlSub.CELLS [ 12, 5 ] = lds_documento.object.numdocide [ 1 ]

    CASE 101    // Cotización
        // Cabecera
        xlSub.CELLS [ 9, 2 ] = "COTIZACION " + STRING ( lds_documento.object.c_numdoc [ 1 ] ) + " " + STRING ( YEAR ( DATE ( lds_documento.object.fecdoc [ 1 ] ) ) ) + " - TRUJILLO"
        xlSub.CELLS [ 11, 3 ] = lds_documento.object.razper [ 1 ]
        xlSub.CELLS [ 11, 10 ] = lds_documento.object.fecdoc [ 1 ]
        xlSub.CELLS [ 12, 13 ] = lds_documento.object.mondoc [ 1 ]
        xlSub.CELLS [ 13, 10 ] = lds_documento.object.numdocide [ 1 ]
        xlSub.CELLS [ 14, 3 ] = lds_documento.object.dirper [ 1 ]
        xlSub.CELLS [ 15, 3 ] = lds_documento.object.ubiper [ 1 ]
       
        // Pie
        xlSub.CELLS [ 43, 6 ] = lds_documento.object.nomcon [ 1 ]
        xlSub.CELLS [ 45, 10 ] = lds_documento.object.c_subdoc [ 1 ]
        xlSub.CELLS [ 46, 9 ] = "I.G.V. " + STRING ( lds_documento.object.igvdoc [ 1 ] ) + " %"
        xlSub.CELLS [ 46, 10 ] = lds_documento.object.c_igvdoc [ 1 ]
        xlSub.CELLS [ 47, 10 ] = lds_documento.object.totdoc [ 1 ]
       
    CASE 99        // Pedido / Orden de compra
        // Cabecera
        xlSub.CELLS [ 5, 9 ] = lds_documento.object.fecdoc [ 1 ]
        xlSub.CELLS [ 11, 4 ] = lds_documento.object.razper [ 1 ]
        xlSub.CELLS [ 12, 4 ] = lds_documento.object.dirper [ 1 ] + " - " + lds_documento.object.ubiper [ 1 ]
        xlSub.CELLS [ 12, 13 ] = lds_documento.object.mondoc [ 1 ]
        xlSub.CELLS [ 14, 4 ] = lds_documento.object.numdocide [ 1 ]

        // Pie
        xlSub.CELLS [ 40, 8 ] = lds_documento.object.c_subdoc [ 1 ]
        xlSub.CELLS [ 41, 7 ] = "I.G.V. " + STRING ( lds_documento.object.igvdoc [ 1 ] ) + " %"
        xlSub.CELLS [ 41, 8 ] = lds_documento.object.c_igvdoc [ 1 ]
        xlSub.CELLS [ 42, 8 ] = lds_documento.object.totdoc [ 1 ]   
        xlSub.CELLS [ 43, 5 ] = lds_documento.object.nomcon [ 1 ]       
END CHOOSE

// Detalle
FOR li_fila = 1 to li_filas
    CHOOSE CASE il_valordw1
        CASE 1        // Factura
            xlSub.CELLS [ 11 + li_fila, 2 ] = lds_documento.object.canart [ li_fila ]
            xlSub.CELLS [ 11 + li_fila, 3 ] = lds_documento.object.iniuni [ li_fila ]
            xlSub.CELLS [ 11 + li_fila, 4 ] = lds_documento.object.nomart [ li_fila ]
            xlSub.CELLS [ 11 + li_fila, 6 ] = lds_documento.object.preart [ li_fila ]
            xlSub.CELLS [ 11 + li_fila, 7 ] = lds_documento.object.c_impart [ li_fila ]
           
        CASE 9        // Guía de Remisión
            xlSub.CELLS [ 15 + li_fila, 3 ] = lds_documento.object.nomart [ li_fila ]
            xlSub.CELLS [ 15 + li_fila, 6 ] = lds_documento.object.canart [ li_fila ]
            xlSub.CELLS [ 15 + li_fila, 7 ] = lds_documento.object.iniuni [ li_fila ]
           
        CASE 101    // Cotización
            xlSub.CELLS [ 18 + li_fila, 2 ] = lds_documento.object.codintart [ li_fila ]
            xlSub.CELLS [ 18 + li_fila, 3 ] = lds_documento.object.canart [ li_fila ]
            xlSub.CELLS [ 18 + li_fila, 4 ] = lds_documento.object.iniuni [ li_fila ]
            xlSub.CELLS [ 18 + li_fila, 5 ] = lds_documento.object.nomart [ li_fila ]
            xlSub.CELLS [ 18 + li_fila, 9 ] = lds_documento.object.preart [ li_fila ]
            xlSub.CELLS [ 18 + li_fila, 10 ] = lds_documento.object.c_impart [ li_fila ]
           
        CASE 99        // Pedido / Orden de compra
            xlSub.CELLS [ 21 + li_fila, 2 ] = li_fila
            xlSub.CELLS [ 21 + li_fila, 3 ] = lds_documento.object.canart [ li_fila ]
            xlSub.CELLS [ 21 + li_fila, 4 ] = lds_documento.object.iniuni [ li_fila ]
            xlSub.CELLS [ 21 + li_fila, 5 ] = lds_documento.object.nomart [ li_fila ]
            xlSub.CELLS [ 21 + li_fila, 7 ] = lds_documento.object.preart [ li_fila ]
            xlSub.CELLS [ 21 + li_fila, 9 ] = lds_documento.object.c_impart [ li_fila ]                       
        END CHOOSE
NEXT

DESTROY lds_documento

//li_rpta = GETFOLDER ( "Seleccione una Carpeta", ls_ruta )
//    ls_ruta = gf_carpeta_actual ( ls_ruta )
    ls_archivo = gf_carpeta_actual ( "" ) + "Formatos\" + ls_nomtipdoc + " " + STRING ( il_valordw2, "000" ) + "-" + STRING ( ill_valordw1 , "0000000000" ) + ".xls"

    xlApp.APPLICATION.ACTIVEWORKBOOK.SAVEAS ( ls_archivo )
   
//    gf_mensaje_ok ( "Exportar Documento", "El documento se EXPORTÓ CORRECTAMENTE en la siguiente ruta " + &
//        "~n" + ls_archivo )
       
xlApp.Application.VISIBLE = TRUE
xlApp.Application.WINDOWSTATE = 3 // 1 : Normal, 2 : Minimize, 3 : Maximize       

xlApp.DISCONNECTOBJECT ()

DESTROY xlApp





 



Fabio Pacheco Quiroz 
RUC. 10190996439
Movistar : 962621103
RPM : #0047115
Nextel :100*4885
Messenger : edwin_fabio@hotmail.com
edwin_fabio@yahoo.com
Web : www.nissi-ti.com
Trujillo - Perú

0 comentarios:

Publicar un comentario

Nota: solo los miembros de este blog pueden publicar comentarios.