Page 1 of 1

como EXPORTO a Excel usando PRINTER.PRG?

PostPosted: Thu Dec 08, 2022 6:02 pm
by karinha
Buenas tardes señores, como EXPORTO a Excel usando PRINTER.PRG? Usando REPORT, funciona bien, pero con PRINTER.PRG incluso si apago WHEN() del Botón Exportar de la clase RPREVIEW.PRG, no funciona.


Code: Select all  Expand view

      DEFINE TBBUTTON OF oBar ;
         ACTION  ::ExportToMSExcel() ;
         TOOLTIP FWString( "Export to Excel" ) ;
         MESSAGE FWString( "Export to Excel" ) /* ;
         WHEN ::CanExportToExcel */


         DEFINE BUTTON oBtn OF oBar ;
            MESSAGE FWString( "Export to Excel" ) ;
            ACTION ::ExportToMSExcel() ;
            TOOLTIP FWString( "Export to Excel" ) /* ;
            WHEN ::CanExportToExcel */

 


Imagen:

https://imgur.com/5ioRsJc

Image

Regards, saludos.

Re: como EXPORTO a Excel usando PRINTER.PRG?

PostPosted: Fri Dec 09, 2022 6:43 pm
by nageswaragunupudi
Because TReport deals with tables, it knows to export the contents of the table to Excel and has a built in ToExcel method. When the user clicks Excel button, this method is invoked.

In case of TPrinter, programmer can print anything anywhere on the page. Printer class does not know how to export to excel.
If the data is suital

Unlike TReport, TPrinter can not export to excel by itself. In suitable cases, programmer can write his own function and assign it oPrn:bToExcel.
Eg
Code: Select all  Expand view

oPrn:bToExcel := { |oPreview| MyExportToExcel( oPreview ) }
 

In such cases, preview enables the excel button and oPrn:bExcel is executed.

Re: como EXPORTO a Excel usando PRINTER.PRG?

PostPosted: Fri Dec 09, 2022 9:33 pm
by karinha