reporte a html

426 views
Skip to first unread message

extremo

unread,
Jan 30, 2013, 7:58:39 AM1/30/13
to publice...@googlegroups.com
Hola amigos

Alguno de ustedes sabe como pasar un informe a html, esta exportacion debe ser limpia, es decir, debe exportar el informe tal cual se ve desde la vista previa del sistema en fox ,con sus imagenes ,lineas de division y sus totales por grupos. Alguien a hecho algo asi. Haaaa sin el foxypreview ya que no lo uso.

Bendiciones

Víctor Hugo Espínola Domínguez

unread,
Jan 30, 2013, 8:27:23 AM1/30/13
to publicesvfoxpro
Víctor.

Cesar VfpImaging

unread,
Jan 30, 2013, 8:32:08 AM1/30/13
to Comunidad de Visual Foxpro en Español
Buque por HTMLLISTENER en VFP9 HELP in en Google


2013/1/30 Víctor Hugo Espínola Domínguez <vich...@gmail.com>

gonzal...@hotmail.com

unread,
Jan 30, 2013, 8:39:01 AM1/30/13
to publice...@googlegroups.com
Aqui tienes un ejemplo, en este caso usa una tabla llamada "mi" que es una lista de facturas, te puede servir como referencia para que uses con otro tipo de tablas.

g = FCREATE("c:\ventas.htm")
loTherm = NewObject("_thermometer","_therm","","Facturas")
ch=1
loTherm.show()
=FWRITE(g,'<html>'+CHR(13)+CHR(10))
=FWRITE(g,'<head>'+CHR(13)+CHR(10))
=FWRITE(g,'<meta content="text/html">'+CHR(13)+CHR(10))
=FWRITE(g,'</head>'+CHR(13)+CHR(10))
=FWRITE(g,'<body>'+CHR(13)+CHR(10))
=FWRITE(g,'<table border="3" style="border-collapse: separate;">'+CHR(13)+CHR(10))
=FWRITE(g,'<col width=51>'+CHR(13)+CHR(10))
=FWRITE(g,'<col width=57>'+CHR(13)+CHR(10))
=FWRITE(g,'<col width=193>'+CHR(13)+CHR(10))
=FWRITE(g,'<col width=74>'+CHR(13)+CHR(10))
=FWRITE(g,'<col width=78>'+CHR(13)+CHR(10))
=FWRITE(g,'<col width=78>'+CHR(13)+CHR(10))
=FWRITE(g,'<col width=61 span=5 >'+CHR(13)+CHR(10))
if !empty(re)
    =FWRITE(g,'<tr>'+CHR(13)+CHR(10))
    =FWRITE(g,'<td colspan=11 height=17 align=center style="font-weight:bold;font-size:8.0pt">'+re+'</td>'+CHR(13)+CHR(10))
    =FWRITE(g,'</td>'+CHR(13)+CHR(10))
endif   
=FWRITE(g,'</tr>'+CHR(13)+CHR(10))
=FWRITE(g,'<tr height=17>'+CHR(13)+CHR(10))
=fwrite(g,'</tr>'+chr(13)+chr(10))
ch=1
select mi
go top
tf=0
ti=0
te=0
tn=0
tv=0
do while !eof()
    =FWRITE(g,'<tr>'+CHR(13)+CHR(10))
    =FWRITE(g,'<td colspan=9 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial">'+"LIBRO DE VENTAS DEL PERIODO:"+gestion+'</td>'+CHR(13)+CHR(10))
    =FWRITE(g,'</tr>'+CHR(13)+CHR(10))
    =FWRITE(g,'<tr>'+CHR(13)+CHR(10))
    =FWRITE(g,'<td colspan=6 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial">'+"NOMBRE O RAZÓN SOCIAL:  "+alltrim(razons)+'</td>'+CHR(13)+CHR(10))
    =FWRITE(g,'<td colspan=3 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial">'+"NIT: "+nit+'</td>'+CHR(13)+CHR(10))
    =FWRITE(g,'</tr>'+CHR(13)+CHR(10))
    =FWRITE(g,'<tr>'+CHR(13)+CHR(10))
    =FWRITE(g,'<td colspan=3 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial">'+"Nº. SUCURSAL: "+_conf.sucur+'</td>'+CHR(13)+CHR(10))
    =FWRITE(g,'<td colspan=6 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial">'+"DIRECCIÓN:  "+alltrim(_conf.direccio)+'</td>'+CHR(13)+CHR(10))
    =FWRITE(g,'</tr>'+CHR(13)+CHR(10))
    =fwrite(g,'<tr>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Fecha</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">NIT</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Razón Social</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Factura</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Autorización</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Codigo de Control</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Total Factura</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Total I.C.E.</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Impuestos Excentos</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">Importe Neto</td>'+chr(13)+chr(10))
    =fwrite(g,'<td align=center style="font-weight:bold;font-size:8.0pt;background:rgb(255,255,204);font-family:Arial">'+"Débito Fiscal"+'</td>'+chr(13)+chr(10))
    =fwrite(g,'</tr>'+chr(13)+chr(10))
    stf=0
    sti=0
    ste=0
    stn=0
    stv=0
    do while !eof()
            =fwrite(g,'<tr>'+chr(13)+chr(10))
            =fwrite(g,'<td align=left style="font-size:7.0pt;font-family:Arial">'+dtoc(mi.fecha)+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=left style="font-size:7.0pt;font-family:Arial;">'+iif(!empty(mi.ruc),alltrim(mi.ruc),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=left style="font-size:7.0pt;font-family:Arial;">'+iif(!empty(mi.razon_soci),alltrim(mi.razon_soci),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=left style="font-size:7.0pt;font-family:Arial;">'+iif(!empty(mi.num_factur),alltrim(mi.num_factur),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=left style="font-size:7.0pt;font-family:Arial;">'+iif(!empty(mi.f_300),alltrim(mi.f_300),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=left style="font-size:7.0pt;font-family:Arial;">'+iif(!empty(mi.codigo),alltrim(mi.codigo),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=right style="font-size:7.0pt;font-family:Arial;">'+iif(mi.total>0,transform(mi.total,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=right style="font-size:7.0pt;font-family:Arial;">'+iif(mi.ice>0,transform(mi.ice,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=right style="font-size:7.0pt;font-family:Arial;">'+iif(mi.i_exento>0,transform(mi.i_exento,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=right style="font-size:7.0pt;font-family:Arial;">'+iif(mi.neto>0,transform(mi.neto,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'<td align=right style="font-size:7.0pt;font-family:Arial;">'+iif(mi.iva>0,transform(mi.iva,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
            =fwrite(g,'</tr>'+chr(13)+chr(10))
            tf=tf+mi.total
            ti=ti+mi.ice
            te=te+mi.i_exento
            tn=tn+mi.neto
            tv=tv+mi.iva
            stf=stf+mi.total
            sti=sti+mi.ice
            ste=ste+mi.i_exento
            stn=stn+mi.neto
            stv=stv+mi.iva
            skip
            loTherm.Update(ch/RECCOUNT()*100,mi.razon_soci)
            ch=ch+1   
    enddo
     =fwrite(g,'<tr>'+chr(13)+chr(10)) &&
     =fwrite(g,'<td align=center colspan=5 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial;border:none">&nbsp;</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=center colspan=1 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial;">PARCIALES</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(stf>0,transform(stf,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(sti>0,transform(sti,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(ste>0,transform(ste,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(stn>0,transform(stn,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(stv>0,transform(stv,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'</tr>'+chr(13)+chr(10))
     =fwrite(g,'<tr>'+chr(13)+chr(10))
     =fwrite(g,'<td align=center colspan=5 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial;border:none">&nbsp;</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=center colspan=1 height=17 style="font-weight:bold;font-size:9.0pt;font-family:Arial;">TOTALES</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(tf>0,transform(tf,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(ti>0,transform(ti,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(te>0,transform(te,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(tn>0,transform(tn,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'<td align=right style="font-size:7.0pt;background:rgb(204,255,204);font-family:Arial;">'+iif(tv>0,transform(tv,"@(R 999,999,999.99"),"&nbsp;")+'</td>'+chr(13)+chr(10))
     =fwrite(g,'</tr>'+chr(13)+chr(10))
enddo
=FWRITE(g,'</html>'+CHR(13)+CHR(10))
=FCLOSE(g)
loTherm.complete("Final")
DECLARE INTEGER ShellExecute ;
        IN SHELL32.DLL ;
        INTEGER nWinHandle,;
        STRING cOperation,;  
        STRING cFileName,;
        STRING cParameters,;
        STRING cDirectory,;
        INTEGER nShowWindow
ShellExecute(0,"open",uni+"ventas.htm","","c\",2)

Luis Maria Guayan

unread,
Jan 30, 2013, 9:11:00 AM1/30/13
to publice...@googlegroups.com
Mira si esto te ayuda

-- Los detalles que tu mamá no te conto sobre HTMLListener --

-- ReportListener HTML Foundation Class --


 
Luis María Guayán
Tucumán, Argentina
_________________________
http://www.PortalFox.com
Nada corre como un zorro
_________________________

extremo

unread,
Jan 30, 2013, 11:42:52 AM1/30/13
to publice...@googlegroups.com
Gracias amigos,

Revisare sus auyudas, la idea que tengo es enviar reportes por mail, como no veo ninguna solucion por parte de fox para hacerlo en PDF sin tener que instalar algun software adicional al sistema (foxypreview me obliga a tener su libreria fisicamente en el PC y eso es lo que quiero evitar por un tema de portabilidad del software), se me ocurrio la idea de pasar el informe a html y enviar el codigo html completo por el correo, algo asi como enviar una pagina web por correo.

Daniel Sánchez

unread,
Jan 30, 2013, 12:02:08 PM1/30/13
to Comunidad de Visual Foxpro en Español
Hola Extremo, en mi caso incluyo dos archivos en la carpeta del sistema para poder generar reportes a formato PDF, estos son libhpdf.dll y reportdpf.app para generar un pdf del reporte solo pongo este código

DO REPORTPDF WITH cnombrereporteFRX, crutadestinodePDF, .F., .T., .T., ''

y nada más sin usar el foxypreview.

Saludos

--
Daniel Sánchez Escobar
Investigación y Desarrollo
Reset Software & Sistemas
Móvil +051-949398047
Trujillo - Perú

Luis Maria Guayan

unread,
Jan 30, 2013, 1:08:59 PM1/30/13
to publice...@googlegroups.com
En tu caso quizás te convenga generar directamente un correo en formato HTML personalizado para cada cliente, 100% VFP y 100% portable

-- Expandiendo expresiones con TextMerge() --
http://www.portalfox.com/article.php?sid=2615


Luis María Guayán
Tucumán, Argentina
_________________________
http://www.PortalFox.com
Nada corre como un zorro
_________________________

extremo

unread,
Jan 30, 2013, 3:35:41 PM1/30/13
to publice...@googlegroups.com
Son buenos sus aportes, gracias

el TEXTMERGE() se ve interesante pero trabajoso ya que me obligaria a realizar los informes de nuevo al estilo HTML y realizando cortes de control para realizar las sumatorias por grupos con sus respectivos encabezados, cosa que el reporte me lo hacia sin ningun esfuerzo por parte mia.

Por otro lado estaba viendo la clase que viene en el vfp9 que se llama _ReportListener. Esta clase hace lo que yo necesito y aparentemente funciona, pero me obliga a crear un archivo fisicamente en el PC, lo cual no quiero, eso si una vez creado el archivo se puede manejar con FOPEN() y FCLOSE() para cerrarlo y con ello obtener el codigo fuente. Una vez obtenido el codigo lo incrusto en el cuerpo del mensaje del correo. Una vez terminada le coloco ERASE.

Se ve facil pero no me gusta eso de crear un archivo... estuve buscando haber si esa clase _ReportListener era capaz de hacer un precomplilado del resultado, es decir, que me entregara de alguna forma el resultado que iba a tener el archivo resuultante, ejemplo output.htm antes de crearlo, asi capturaba el HTML que se iba a generar, luego de eso, en vez de grabarlo, solo utilizaria el codigo analizado y listo, pero no encontre nada asi.


Seguire buscando mas soluciones ya que por el momento tengo tiempo para investigar al respecto.

Bendiciones



El miércoles, 30 de enero de 2013 09:58:39 UTC-3, extremo escribió:

extremo

unread,
Jan 30, 2013, 3:40:38 PM1/30/13
to publice...@googlegroups.com
haaaaaaaa

despues que lei lo que escribi, se me ocurrio hacerle seguimiento a esa clase y ver en que momento genera el codigo html.... tal vez pueda interrumpir el proceso y dejarlo hasta ese punto. Si funciona el tema estaria solucionado. A jugar un rato con esa clase.


Bendiciones

El miércoles, 30 de enero de 2013 09:58:39 UTC-3, extremo escribió:

Daniel Sánchez

unread,
Jan 31, 2013, 8:59:28 AM1/31/13
to Comunidad de Visual Foxpro en Español
La creación de un archivo físico en disco no le veo ningún inconveniente, yo muchas veces creo archivo de imágenes temporales en disco para ciertos reportes y con las mismas las elimino y todo queda como si no hubieran existido, no creo que eso sea mayor problema.

Saludos

Luis Maria Guayan

unread,
Jan 31, 2013, 9:10:55 AM1/31/13
to publice...@googlegroups.com
Exactamente es muy extraño que no desees escribir archivos en disco, hasta los mismos cursores de VFP se escriben en el disco y se eliminan al cerrarlos.

La clase FoxBarcode genera todas las imágenes grabandolas en disco en una carpeta especial en los archivos temporales de Windows que luego se borran. Puedes copiar esas rutinas de creación y eliminación de archivos temporales que funciona muy bien (http://www.foxbarcode.com.ar)



Luis María Guayán
Tucumán, Argentina
_________________________
http://www.PortalFox.com
Nada corre como un zorro
_________________________

HernanCano

unread,
Jan 31, 2013, 11:01:49 AM1/31/13
to publice...@googlegroups.com

1.
VFP no tiene de forma nativa lo que necesitas: tienes que programarlo. La búsqueda que estás haciendo es un buen camino.

2.
Lo más fácil es usar FoxyPreviewer.

3.
No entiendo tu "problema" de portabilidad: ¿no puedes tener FoxyPreviewer junto a tu app?
En VFP se pueden hacer aplicaciones portables (no porque yo lo diga se puede, ¿bien?; creo que por lo que mencionas sabes que pueden hacerse, y tú ya sabes hacerlo) ¿Con FoxyPreviewer qué es lo que tú ves --o crees-- que no?
Reply all
Reply to author
Forward
0 new messages