Excel from Preview

Post Reply
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Excel from Preview

Post by TimStone »

My reports are all hand coded with tPrinter class. When I preview a report, the default display shows an Excel icon on the button bar. However, it does nothing.

1). Is there a way to activate the button so it sends the report to Excel ? ( I thought it used to work ).

2). If not, how do we remove the icon on system startup so it never shows, without having to modify the tPreview class ?

Yes ... I have the latest copy of Excel installed ( Office 365 ) and it is a default app.

Thanks ...
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Excel from Preview

Post by TimStone »

ANYONE ????

Seems like many questions about FWH go unanswered now ....
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Post by jvtecheto »

TimStone wrote:ANYONE ????

Seems like many questions about FWH go unanswered now ....
Hi Tim

Answer un Spanish forum


PREVIEW // TO PRINTER
oReport:oDevice:SetPage(15)
oReport:bInit := { || dbGoTop() } // add this.

Seems it works with this change.

Regards.

José.


Enviado desde mi POCOPHONE F1 mediante Tapatalk
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Post by jvtecheto »

TimStone wrote:ANYONE ????

Seems like many questions about FWH go unanswered now ....
This Is link Spanish forum

https://r.tapatalk.com/shareLink/topic? ... source=app

Enviado desde mi POCOPHONE F1 mediante Tapatalk
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Excel from Preview

Post by nageswaragunupudi »

Excel button works when
1) Report is generated from xbrowse, using oBrw:ToExcel()
2) Report is generated using TReport class, if oReport:bInit is assigned with a codeblock, typically { || dbgotop() }.
Or if the programmer provides his own custom oReport:bToExcel codeblock.
3) Report is generated using TPrinter class and the programmer provides his own custom oPrn:bToExcel codeblock

In all other cases and also if Excel is not installed, Excel button is diplayed as "DISABLED".

If a programmer chooses to have the buttonbar in a different way than is provided, he can substitute his own buttonbar globally with TReport():bButtonBar
Regards

G. N. Rao.
Hyderabad, India
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Excel from Preview

Post by TimStone »

Using option 3, can you provide an example of the custome codeblock ? Is there a sample ?
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Excel from Preview

Post by nageswaragunupudi »

TimStone wrote:Using option 3, can you provide an example of the custome codeblock ? Is there a sample ?
Sample:

Code: Select all

#include "fivewin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oPrn, oFont, nRow, nCol

   USE STATES NEW SHARED

   STATES->( StatesReport() )

   CLOSE STATES

return nil

//----------------------------------------------------------------------------//

static function StatesReport()

   local oPrn, oFont, nRow

   GO TOP

   PRINT oPrn PREVIEW
   oPrn:bToExcel  := { || ( Alias() )->( StatesToExcel() ) }

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-10 OF oPrn

   PAGE
   nRow  := 1
   do while !Eof()

      @ nRow, 5.0 PRINT TO oPrn TEXT FIELD->CODE SIZE  1, 0.4 CM FONT oFont
      @ nRow, 6.0 PRINT TO oPrn TEXT FIELD->NAME SIZE 10, 0.4 CM FONT oFont

      nRow  += 0.5

      SKIP
   enddo

   ENDPAGE
   ENDPRINT

   RELEASE FONT oFont

   GO TOP

return nil

//----------------------------------------------------------------------------//

static function StatesToExcel()

   local oExcel, oBook, oSheet, nRow

   oExcel   := ExcelObj()
   oExcel:ScreenUpdating := .f.
   oBook    := oExcel:WorkBooks:Add()
   oSheet   := oExcel:ActiveSheet

   GO TOP
   nRow  := 1
   do while !eof()
      oSheet:Cells( nRow, 1 ):Value := FIELD->CODE
      oSheet:Cells( nRow, 2 ):Value := FIELD->NAME
      nRow++
      SKIP
   enddo

   GO TOP

   oSheet:Columns( 1 ):AutoFit()
   oSheet:Columns( 2 ):AutoFit()

   oExcel:ScreenUpdating := .t.
   oExcel:Visible := .t.

return nil

//----------------------------------------------------------------------------//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Post by jvtecheto »

nageswaragunupudi wrote:Excel button works when
1) Report is generated from xbrowse, using oBrw:ToExcel()
2) Report is generated using TReport class, if oReport:bInit is assigned with a codeblock, typically { || dbgotop() }.
Or if the programmer provides his own custom oReport:bToExcel codeblock.
3) Report is generated using TPrinter class and the programmer provides his own custom oPrn:bToExcel codeblock

In all other cases and also if Excel is not installed, Excel button is diplayed as "DISABLED".

If a programmer chooses to have the buttonbar in a different way than is provided, he can substitute his own buttonbar globally with TReport():bButtonBar
Hi Mr. Rao Using option 2 it shows excell button and opens excell 2019 but when i return the xbrowse is totally empty

look at small video for demostrate it behaovior


Image

Thanks in advance

Jose
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Excel from Preview

Post by nageswaragunupudi »

You need to make the report re-entrant.
Depends on how you program.

Please try to make a small program and post here please.
Regards

G. N. Rao.
Hyderabad, India
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Post by jvtecheto »

nageswaragunupudi wrote:You need to make the report re-entrant.
Depends on how you program.

Please try to make a small program and post here please.
Yes mr. Rao but the movie demostrades When opens excell the xbrowse is Empty and if we not click excell button when exit preview it returns without problem.

Jose

Enviado desde mi POCOPHONE F1 mediante Tapatalk
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Post by jvtecheto »

here is the code of the report

Code: Select all


DEFINE FONT oFont NAME "Courier New" SIZE 0, - 12
      oDevice := TPrinter():NEW( cCaption, .F., IF( nRdest == 1, .T., .F. ) ) 
REPORT oRepAp TITLE "OBRA : " + ApupObr->Codigo + " - " + aPupObr->Nombre, ;
         Replicate ( "_", 77 ), "", Space( 26 ) + cHeader1, Replicate ( "_", 77 ), ;
         cHeader2 , "FECHAS : " + DToC( dInicio ) + " Hasta " + DToC( dFinal ), Chr( 13 ) Left ;
         Header "Pag. " + Str( oRepAp:nPage, 3 ) Right ;
         FOOTER aEmpresa[ 1 ] + " - " + aEmpresa[ 2 ] + " (" + aEmpresa[ 11 ] + ")" ;
         TO DEVICE oDevice FONT oFont


         COLUMN TITLE "Fecha"  DATA DToC( Apup->Fecha )
         COLUMN TITLE "Factura"  DATA Apup->Factura
         IF nRfil == 2
            COLUMN TITLE "Proveedor" DATA ApupProv->Nombre
         ENDIF
         COLUMN TITLE "Importe"  DATA Apup->Importe TOTAL PICTURE "@E 999,999,999.99"
      END REPORT

      oRepAp:bInit := {|| (cAlias)->(dbGoTop()) }  // For activate excell Button
      oRepAp:nTotalline := 1
      oRepAp:nTitleUpline := 0  
      oRepAp:MARGIN( 4, 5, 2 )
      ACTIVATE REPORT oRepAp FOR Apup->Fecha <= dFinal WHILE ! Apup->( Eof() )
      oFont:END()
 
Regards

Jose.
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Excel from Preview

Post by nageswaragunupudi »

This is because you are using the same alias as xbrowse to run your report. Your report after execution, moves the record pointer of the same alias to end of file and when you get back to xbrowse, the dbf is at eof.

One way is to use oBrw:Report(...)

If you want to continue your program the same way, then you please do this:

1. nSaveRec := RECNO()
DEFINE REPORT AND ACTIVATE
after that
2. DBGOTO( nSaveRec )
oBrw:Refresh()

OR

Run the report by opening the same DBF with a different Alias, run report and close that alias.
Regards

G. N. Rao.
Hyderabad, India
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Post by jvtecheto »

Thanks for your help Mr. Rao

the first option I'm already doing it like this and it gives me an error

The second option is complicated to implement by a single report since it has several set Relations .

Note that if I don't press the Excell button I have no problem when I return to xbrowse

Regards

Jose.
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
Post Reply