FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour como EXPORTO a Excel usando PRINTER.PRG?
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
como EXPORTO a Excel usando PRINTER.PRG?
Posted: Thu Dec 08, 2022 06:02 PM
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 (fw): Select all Collapse
      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



Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: como EXPORTO a Excel usando PRINTER.PRG?
Posted: Fri Dec 09, 2022 06:43 PM
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 (fw): Select all Collapse
oPrn:bToExcel := { |oPreview| MyExportToExcel( oPreview ) }
In such cases, preview enables the excel button and oPrn:bExcel is executed.
Regards



G. N. Rao.

Hyderabad, India
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: como EXPORTO a Excel usando PRINTER.PRG?
Posted: Fri Dec 09, 2022 09:33 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion