ExecuteReport( )

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: ExecuteReport( )

Post by Amarante »

Esta es tu ejemplo y para mí funciona normalidad ... ver imagen PDF adjunto. Puse una imagen con un archivo con el mismo nombre que utiliza en su programa.
No entiendo su problema? :?:

Code: Select all

#include <hmg.ch>
#include "fileio.ch"

Function Main()
   dbCreate( "Clientes", { { "CODE", "C", 16, 0 }, { "TITLE", "C", 80, 0 }, { "PRICE", "N", 9, 2 } }, , .T., "Ctes" )
   dbAppend()
   Ctes->CODE  := "0001"
   Ctes->TITLE := "El Título   áéíóú"
   Ctes->PRICE := 123.45
   
   DEFINE WINDOW FORM_1 AT 0,0 WIDTH 500 HEIGHT 300 MAIN TITLE "HMG Report Writer"
   
      @ 050,100 BUTTON Button_1 CAPTION "Make Report" ACTION ImpClientes()
            
   END WINDOW
   
   CENTER WINDOW Form_1
   ACTIVATE WINDOW Form_1
Return Nil

FUNCTION ImpClientes()
   LOCAL CRaiz   := HB_CurDrive()+':\'+CurDir()+'\'
   
   cpso1:= "[ La Empresa ] "
   cpso2:= "Periodo del:  [  ]"
   cpso3:= cRaiz+'LOGOPSO.JPG'
   
   CreateReportCtes( cpso1, cpso2, cpso3, cRaiz+'LOGOPSO.JPG' )
   *MSGINFO( "En la siguiente pantalla de PREVIEW, si le damos Guardar como .PDF," + HB_OsNewLine() + " no guarda nada en el contenido del archivo" )
   MSGINFO( "In the next screen PREVIEW, if we give save as .PDF," + HB_OsNewLine () + "does not save anything in the file contents")
   
   ExecuteReport('Clientes1',.t.,.f. )
   *MSGINFO( "El mismo archivo anterior generado directamente como .PDF,"  + HB_OsNewLine() + ;
   *       "no despliega la imagen ni los acentos," + HB_OsNewLine() + ;
   *       "y en el texto no despliega las diagonales... " )
   MSGINFO("Same old file, generated directly as .PDF," + HB_OsNewLine () +;
         "does not display the image or accents," + HB_OsNewLine () +;
         "and the text does not display diagonal ...")

//<amarante>
/*
   ExecuteReport('Clientes1',.t.,.t., cRaiz+"xxx.pdf" )
   SHELLEXECUTE( 0, "open" , "AcroRd32.exe", 'xxx.pdf' )
*/
Run_MyProcess( CRaiz + [SumatraPDF.exe "] + cRaiz + [Clientes.pdf"], .t. )
//<amarante>
   
RETURN( Nil )

//------------------------------------------------------------------------------
Function CreateReportCtes( cpso1, cpso2, clogo )
   *msginfo(cpso2)
    DEFINE REPORT Clientes1

        * Report Layout ***********************************************
        BEGIN LAYOUT
            PAPERSIZE    PRINTER_PAPER_LETTER
            ORIENTATION  PRINTER_ORIENT_PORTRAIT
        END LAYOUT
        * Header Band *************************************************
        BEGIN HEADER
            BANDHEIGHT        25
            BEGIN LINE
                FROMROW 23 ; FROMCOL 10 ; TOROW 23 ; TOCOL 200 ; PENWIDTH 0.1 ; PENCOLOR BLACK
            END LINE
            BEGIN TEXT
                EXPRESSION    'REPORTE DE CLIENTES  '
                ROW 7 ; COL 10 ; WIDTH 100 ; HEIGHT 20 ; FONTNAME 'Helvetica' ; FONTSIZE 13 ; FONTCOLOR BLUE ; ALIGNMENT Left
            END TEXT
            BEGIN TEXT
                EXPRESSION    cpso1
                ROW 12  ; COL 10 ; WIDTH 100 ; HEIGHT 15 ; FONTNAME 'Helvetica' ; FONTSIZE 11 ; FONTBOLD .F.
                FONTITALIC .T. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR BLACK ; ALIGNMENT Left
            END TEXT
            BEGIN TEXT
                EXPRESSION    cpso2
                ROW 17  ; COL 10 ; WIDTH 100 ; HEIGHT 15 ; FONTNAME 'Helvetica' ; FONTSIZE 11 ; FONTBOLD .F.
                FONTITALIC .T. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR BLACK ; ALIGNMENT Left
            END TEXT
            BEGIN TEXT
                EXPRESSION    cpso3
                ROW 17  ; COL 80 ; WIDTH 100 ; HEIGHT 15 ; FONTNAME 'Helvetica' ; FONTSIZE 11 ; FONTBOLD .T.
                FONTITALIC .T. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR RED ; ALIGNMENT Left
            END TEXT         
            BEGIN PICTURE
                VALUE clogo ; ROW 5 ; COL 160 ; WIDTH 47 ; HEIGHT 16 ; STRETCH .T.
                *VALUE cpso3 ; ROW 5 ; COL 160 ; WIDTH 47 ; HEIGHT 16 ; STRETCH .T.
            END PICTURE
        END HEADER
        * Detail Band *************************************************
        BEGIN DETAIL
            BANDHEIGHT        6
            BEGIN TEXT
                EXPRESSION   Ctes->CODE
                ROW 2 ; COL 10 ; WIDTH 20 ; HEIGHT 10 ; FONTNAME 'Helvetica' ; FONTSIZE 9 ; FONTBOLD .F.
                FONTITALIC .F. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR BLACK ; ALIGNMENT Left
            END TEXT
            BEGIN TEXT
                EXPRESSION   Ctes->TITLE
                ROW 2 ; COL 25 ; WIDTH 60 ; HEIGHT 10 ; FONTNAME 'Helvetica' ; FONTSIZE 9 ; FONTBOLD .T.
                FONTITALIC .F. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR RED ; ALIGNMENT Left
            END TEXT
            BEGIN TEXT
                EXPRESSION   Ctes->PRICE
                ROW 2 ; COL 65 ; WIDTH 20 ; HEIGHT 10 ; FONTNAME 'Helvetica' ; FONTSIZE 9 ; FONTBOLD .F.
                FONTITALIC .F. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR BLACK ; ALIGNMENT Left
            END TEXT         
        END DETAIL
        * Footer Band *************************************************
        BEGIN FOOTER
            BANDHEIGHT        27
            BEGIN LINE
                FROMROW 4 ; FROMCOL 10 ; TOROW 4 ; TOCOL 200 ; PENWIDTH 0.1 ; PENCOLOR BLACK
            END LINE
            BEGIN TEXT
                EXPRESSION    'Página #: '
                ROW 7 ; COL 11 ; WIDTH 100 ; HEIGHT 10 ; FONTNAME 'Helvetica' ; FONTSIZE 12 ; FONTBOLD .F.
                FONTITALIC .F. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR BLACK ; ALIGNMENT Left
            END TEXT
            BEGIN TEXT
                EXPRESSION    Date()
                ROW 7 ; COL 177 ; WIDTH 30 ; HEIGHT 10 ; FONTNAME 'Helvetica' ; FONTSIZE 12 ; FONTBOLD .F.
                FONTITALIC .F. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR BLACK ; ALIGNMENT Left
            END TEXT
        END FOOTER
        * Summary Band ************************************************
        BEGIN SUMMARY
            BANDHEIGHT        50
            BEGIN TEXT
                EXPRESSION    'Total Registros: '
                ROW 10 ; COL 20 ; WIDTH 100 ; HEIGHT 30 ; FONTNAME 'Helvetica' ; FONTSIZE 12 ; FONTBOLD .T.
                FONTITALIC .F. ; FONTUNDERLINE .F. ; FONTSTRIKEOUT .F. ; FONTCOLOR BLACK ; ALIGNMENT Left
            END TEXT
        END SUMMARY
    END REPORT
   *msgdebug(_HMG_SYSDATA[434])
   *msgdebug(_HMG_SYSDATA[116])
Return


/**
*
* Run_MyProcess
*
* Description: Executes an external process
* Syntax.....: Run_MyProcess( <expC1>, [expL1], [expB1], [expN1], [expN2] )
* Parameters.: <expC1> - Expression of process running
*              [expL1] - Wait on process (default .T.)
*              [expB1] - Block-function to be performed during the process
*              [expN1] - Time (default 1)
*              [expN2] - Number of times to perform the block-function (default 0)
* Return.....: expN - Result of the process
* Example....:
*   Run_MyProcess( "SumatraPDF.exe " + "Certidao.PDF", .T. )
*   ------ other sample -----
*   hb_memowrit( "test.txt", "Test File..." )
*   ? "Retorno:", Run_MyProcess( "notepad test.txt", .T., { || QOUT( "Waiting Notepad close..." ) }, 1 )
*   WAIT "When you get here notepad already ended. press ENTER..."
*   ? "Retorno:", Run_MyProcess( "notepad test.txt", .F. )
*   WAIT "When you get here notepad is still running. press ENTER..."
*   ? "Retorno:", Run_MyProcess( "notepad test.txt",, { | nCtd | QOUT( "Waiting Notepad close (" + hb_ntos( 5 - nCtd ) + ")..." ) },, 5 )
*   WAIT "The Loop was closed after in 5 seconds..."
*   ? "Retorno:", Run_MyProcess( "notepad test.txt",, { | nCtd | QOUT( "Forcing the closure of Notepad by returning the codeblock..." ), IIF( nCtd = 2, .F., .T. ) } )
*   WAIT "The Loop was closed..."
*
*/
FUNCTION Run_MyProcess( cExecute, lWait, bBlock, nTime, nOccurs )

  #define LWA_ALPHA    0x02

  LOCAL cWin_ := _HMG_SYSDATA[ 316 ]                      // Name of the current window
  LOCAL hProcess
  LOCAL nCtd := 0
  LOCAL nResult
  LOCAL lRet

  __DefaultNIL( @lWait, .T. )
  __DefaultNIL( @nTime, 1 )
  __DefaultNIL( @nOccurs, 0 )

  hProcess := HB_ProcessOpen( cExecute )
  IF hProcess <> F_ERROR
    SetLayeredWindowAttributes( GetFormHandle( cWin_ ), 0, 180, LWA_ALPHA )
    DO WHILE ( nResult := HB_ProcessValue( hProcess, .F. ) ) == - 1
      DO EVENTS
      IF .NOT. lWait
        EXIT
      ENDIF
      nCtd += 1
      IF HB_IsBlock( bBlock )
        lRet := EVAL( bBlock, nCtd )
        IF HB_IsLogical( lRet ) .AND. .NOT. lRet
          HB_ProcessClose( hProcess, .T. )
          EXIT
        ENDIF
      ENDIF
      IF nTime > 0
        HB_IdleSleep( nTime )
      ENDIF
      IF nCtd == nOccurs
        HB_ProcessClose( hProcess, .T. )
        EXIT
      ENDIF
    ENDDO
    SetLayeredWindowAttributes( GetFormHandle( cWin_ ), 0, 255, LWA_ALPHA )
  ELSE
    MsgInfo( "Error Open Process" )
  ENDIF
  RETURN nResult
Attachments
exemplo.jpg
exemplo.jpg (49.26 KiB) Viewed 4945 times
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: ExecuteReport( )

Post by Pablo César »

andyglezl wrote:Voy de acuerdo con lo que dice Amarante:
I do not know why this !

Daniel says not agree when need to reinvent the wheel. Upto this, ok for me, each one has their own opinion and has the same right to express it.

But before agreeing to what others say and also mention the person's name as if it were the most important thing.
The important Andrés, are the ideas that everyone has, the reasons behind there.

Everything must be analyzed before posting: I'm with this person (citing name) and it is very frustrating when is not mentioning their reasons.

I'm not here to compete with anyone. I'm just giving my contribution and learning from others. Every kind of allusion being to my person or to any other despising opinions, I consider it very unpleasant.

And unfortunately, this kind of practice here is very often. Especially when I spent a lot of time helping you Andrés, the least you had to do is be more friendly.

When at your argument in ExecuteReport for PREVIEW, IMHO HMG should do the preview and to make thru EMF file is the way we do. Otherwise there is non sense to require PREVIEW even in PDFs files, right ?

Returning to the subject of why I like to reinvent the wheel ...
is the simple reason of not dependent on any third party in my applications (when is it posible, of course.

I believe If I think like this I would tie or to limit myself to do something new, it will surely be to improve or be independent in my development programming with reference to external utilities to HMG.

I think differently, not wanting to put on the idea of someone.

I just see that Adobe has been losing customers, many hates it on their PCs and I'd love to leave it.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: ExecuteReport( )

Post by Amarante »

Oops ...
I did not want to cause any stir when I explained my opinion on report viewing .... As exemplified the way I work.
How to reinvent the wheel, I meant that he saw no need for another pdf reader, as there are in torrents. Can you imagine if HMG were to create a routine equal to Microsoft Office? I think half clueless. As for learning, I like, of course you could dedicate myself to learn how to create a PDF reader, learning is always good, and encourage those who want to do it.
Many times, and the world is full of problems therefore not well express our opniões and just being misinterpreted.
I just hope expose my experiences do not cause trouble, for I can not agree with the opnion of all, but I will fight for the right to expose all the your opinions.
In this forum I have found only people of good faith who try to help others and have learned a lot.
Thank you all.
-----------------------
Ops...
Eu não queria causar nenhum celeuma quando expus minha opinião sobre visualização de relatórios.... Apenas exemplifiquei a maneira que trabalho.
Quanto a reinventar a roda, eu quis dizer que não via necessidade em um outro leitor de pdf, já que existem aos borbotões. Já imaginou se HMG fosse criar uma rotina igual ao Microsoft Office? Eu acho meio sem noção. Quanto a aprendizagem, eu gosto, é claro que se pudesse me dedicaria a aprender como criar um leitor de PDF, aprender é sempre bom, e incentivo quem queira faze-lo.
Muitas vezes, e o mundo está cheio de problemas por isso, não expressamos bem nossas opniões e acabamos sendo mal interpretados.
Eu só espero que expor minhas experiências não causem problemas, pois posso não concordar com a opnião de todos, mas lutarei pelo direito de todos exporem as suas opniões.
Neste fórum tenho encontrado só gente de boa fé que tentam ajudar ao próximo e tenho aprendido muito.
Obrigado a todos.
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: ExecuteReport( )

Post by Amarante »

Andy,
Ejemplos HMG realmente no se muestran las imágenes ... no sé lo que podría ser.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

ExecuteReport( )

Post by Pablo César »

Da minha parte, sem problemas Daniel. Sério !

Fiquei incomodado em ver a falta de tato do colega, como se isto fosse: a ver quem tem razão ??

Depois de tentar ajudá-lo, recebo isso... pode ver que tudo muito confuso o que ele diz: eu desisto ! :evil:
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: ExecuteReport( )

Post by Amarante »

Pablo,
Talvez meu espanhol seja muito curto para entender nas entrelinhas, mas creio que você interpretou mal o Andy, não sei.
De qualquer forma, isso aqui não é uma competição, mesmo porque estamos entre amigos e eu nunca disse que sou o dono da verdade, muito pelo contrário.
Não foi a toa que lhe falei daquela proposta. Notei a sua boa indole e seu espirito autruista. Continue assim.
E sempre defenda suas idéias.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: ExecuteReport( )

Post by Pablo César »

Tranquilo Daniel, está tudo bem. Mas se quiser falar mais a respeito prefiro MP. Já não tenho mais vontade de escrever neste tópico.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: ExecuteReport( )

Post by andyglezl »

Pablo Cesar
Yo en ningún momento tuve la intención de ofender, si el estar de acuerdo con una persona es ofender a otra,
pues limitare mis comentarios a solo el problema expuesto y nada mas.

Aunque para mi, si alguien hace un comentario y otra persona contesta con +1, es porque está de acuerdo con
esa pesona y ese comentario y no veo algún reclamo por eso.

Esto solo lo hago para aclarar el punto, no para seguir en una discusión que nos nos lleva a nada.

Yo en lo personal, te estoy muy agradecido por toda la ayuda que nos has ofrecido.
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

ExecuteReport( )

Post by Pablo César »

andyglezl wrote:Esto solo lo hago para aclarar el punto, no para seguir en una discusión que nos nos lleva a nada.
+1 :D
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: ExecuteReport( )

Post by Amarante »

Pablo César wrote:Tenho curiosidade e a título de aprendizado, gostaria de poder dar uma olhadinha nesse visualizador. Quem sabe podemos implementar no nosso PREVIEW ?
Pablo,
Esta é para você que conhece C. 8-) O projeto SumatraPDF é livre. :o Você pode baixar e modifica-lo para que funcione em HMG. :!: Se você começar, é claro que eu te ajudo nesse projeto. :D
Post Reply