Page 1 of 1
Excel from Preview
Posted: Fri Jun 05, 2020 12:17 am
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 ...
Re: Excel from Preview
Posted: Sun Jun 07, 2020 6:07 pm
by TimStone
ANYONE ????
Seems like many questions about FWH go unanswered now ....
Re: Excel from Preview
Posted: Sun Jun 07, 2020 7:48 pm
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
Re: Excel from Preview
Posted: Sun Jun 07, 2020 7:50 pm
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
Re: Excel from Preview
Posted: Mon Jun 08, 2020 2:56 am
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
Re: Excel from Preview
Posted: Mon Jun 08, 2020 8:39 pm
by TimStone
Using option 3, can you provide an example of the custome codeblock ? Is there a sample ?
Re: Excel from Preview
Posted: Tue Jun 09, 2020 3:43 pm
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
//----------------------------------------------------------------------------//
Re: Excel from Preview
Posted: Mon Jun 15, 2020 2:11 pm
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
Thanks in advance
Jose
Re: Excel from Preview
Posted: Mon Jun 15, 2020 2:42 pm
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.
Re: Excel from Preview
Posted: Mon Jun 15, 2020 9:29 pm
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
Re: Excel from Preview
Posted: Tue Jun 16, 2020 2:53 pm
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.
Re: Excel from Preview
Posted: Tue Jun 16, 2020 3:09 pm
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.
Re: Excel from Preview
Posted: Tue Jun 16, 2020 5:19 pm
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.