Excel from Preview

Excel from Preview

Postby TimStone » Fri Jun 05, 2020 12:17 am

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Excel from Preview

Postby TimStone » Sun Jun 07, 2020 6:07 pm

ANYONE ????

Seems like many questions about FWH go unanswered now ....
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Excel from Preview

Postby jvtecheto » Sun Jun 07, 2020 7:48 pm

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 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
User avatar
jvtecheto
 
Posts: 600
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Postby jvtecheto » Sun Jun 07, 2020 7:50 pm

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 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
User avatar
jvtecheto
 
Posts: 600
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Postby nageswaragunupudi » Mon Jun 08, 2020 2:56 am

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
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Excel from Preview

Postby TimStone » Mon Jun 08, 2020 8:39 pm

Using option 3, can you provide an example of the custome codeblock ? Is there a sample ?
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Excel from Preview

Postby nageswaragunupudi » Tue Jun 09, 2020 3:43 pm

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


Sample:
Code: Select all  Expand view  RUN
#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
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Excel from Preview

Postby jvtecheto » Mon Jun 15, 2020 2:11 pm

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 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
User avatar
jvtecheto
 
Posts: 600
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Postby nageswaragunupudi » Mon Jun 15, 2020 2:42 pm

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
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Excel from Preview

Postby jvtecheto » Mon Jun 15, 2020 9:29 pm

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 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
User avatar
jvtecheto
 
Posts: 600
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Postby jvtecheto » Tue Jun 16, 2020 2:53 pm

here is the code of the report

Code: Select all  Expand view  RUN


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 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
User avatar
jvtecheto
 
Posts: 600
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: Excel from Preview

Postby nageswaragunupudi » Tue Jun 16, 2020 3:09 pm

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
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Excel from Preview

Postby jvtecheto » Tue Jun 16, 2020 5:19 pm

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 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
User avatar
jvtecheto
 
Posts: 600
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: TimStone, Willi Quintana and 49 guests