Hello Otto;
With FastReports you can load the report and without having to "show" it, you can export to html. Like this:
:DoExport( <cExportObjectName> )
Where cExportObjectName can be: "PDFExport", "HTMLExport", "RTFExport", "CSVExport", "XLSExport", "DotMatrixExport", "BMPExport", "JPEGExport", "TXTExport", "TIFFExport", "GIFExport", "SimpleTextExport", "MailExport", "XMLExport", "ODSExport", "ODTExport", "BIFFExport"
You can also open the report preview (show it) and hide most buttons restricting the user ability to execute certain functions.
Here is some sample code that replaces what some preview buttons do:
*-------------------------------------------------------------------------------------
FUNCTION SetFrOptions( oFr, oDbf, oBrw )
LOCAL aPrinters := GetPrinters()
LOCAL nPos := ASCAN( aPrinters, { |e| "FORMS" $ UPPER( e ) } )
DEFAULT oBrw := NIL //avoid compiler warning. Not sure what I want to do with oBrw.
WITH OBJECT oFr
:PreviewOptions:SetOutlineWidth( 65 )
:PreviewOptions:SetMaximized( .F. )
:PreviewOptions:SetModal( .T. )
:PreviewOptions:SetBounds( 120, 120, 850, 600 )
:PreviewOptions:SetAllowEdit( .F. )
:ReportOptions:SetAuthor( "Reinaldo Crespo-Bazan" )
:ReportOptions:SetCompressed( .F. )
:SetEventHandler( "Report", "OnUserFunction", { |cFunc, aParms| CallUserFunc( cFunc, aParms ) } )
:SetObjProperty( "Report", "ShowProgress", .T. )
:SetIcon( "Icon_0" )
IF nPos > 0
:PrintOptions:SetPrinter( aPrinters[ nPos ] )
ENDIF
:SetEventHandler( "MailExport", "OnSendMail", { |a| SendReportViaeMail( a, oFr ) } )
//:PreviewOptions:SetRemoveReportOnClose( .T. )
//:SetEventHandler( "Report", "OnClosePreview", { || oFr:ClearDataSets() } )
IF oDbf != NIL
/*:SetEventHandler( "Report", "OnClosePreview", ;
{ |x| oDbf:GoTop(), iif( oBrw != NIL, oBrw:Refresh(), ) } ) */
ENDIF
END
RETURN NIL
Here is an example of an export to excel:
METHOD ExportASXLS() CLASS TMpReports
WITH OBJECT ::oFr
:SetProperty( "BIFFExport", "DeleteEmptyRows", .T. )
:SetProperty( "BIFFExport", "FileName", ::cxlsFileName )
:SetProperty( "BIFFExport", "Author", "Structured Systems Corp" )
:SetProperty( "BIFFExport", "Subject", ::cRepName )
:SetProperty( "BIFFExport", "Company", "www.structuredsystems.com" )
:SetProperty( "BIFFExport", "ShowDialog", .F. )
:SetProperty( "BIFFExport", "FitPages", .F. )
:SetProperty( "BIFFExport", "SingleSheet", .T. )
:SetProperty( "BIFFExport", "ShowProgress", .T. )
:SetProperty( "BIFFExport", "WysIwyG", .F. )
:SetProperty( "BIFFExport", "GridLines", .F. )
:SetProperty( "BIFFExport", "Pictures", .T.)
:SetProperty( "BIFFExport", "OpenAfterExport", .F. )
:SetProperty( "BIFFExport", "Password", ALLTRIM( ::cPassword ) )
:SetProperty( "BIFFExport", "Application", "Auto-Tasks Ver 0.10 Generated Report" )
TRY
:DoExport( "BIFFExport" )
CATCH
END
END WITH
RETURN NIL
Maybe this helps.