Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Crystal reports RDC
Message
De
22/04/2000 03:05:33
Walter Meester
HoogkarspelPays-Bas
 
 
À
21/04/2000 16:27:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00362345
Message ID:
00362470
Vues:
29
Hi ken,

>I trying to get started with the Crystal Reports RDC way of
>doing a report. Would anybody have a VFP6 example ?


Make a new form, drop the crystal smartviewer control on it, name it crviewer and use the following code to display the report.
oEngine = createobject("CrystalRuntime.application")
oReport = oEngine.openreport(cReport,1)
oReport.EnableParameterPrompting=.F.
THISFORM.Report=oReport

* for parameters to CR you can use the following mechanism to pass the values
* to the report. Note that this asumes that the parameternames in the report 
* match the VFP variabele name to pass.

WITH oReport.ParameterFields
	FOR nT= 1 TO .Count
		cName=.Item(nT).ParameterFieldName
		IF TYPE(cName) # "U"
			.item(nT).SetDefaultValue(EVAL(cName))
		ENDIF
	ENDFOR
ENDWITH

THISFORM.CrViewer.ReportSource=oReport
THISFORM.CrViewer.Viewreport()
Some other tips:
- use FOX2X tables as basis for reporting, it's the fastest and easiest way.
- Write the tables to your temp dir and delete them when you're done. You can change the location of tables with:
- oReport.Database.Tables.item[nT].location = cLocation
For subreports, you'll first have to open the subreport (opensubreport method)
- Use the FOCUS.FLL library to retrieve printer information for setting the destination printer other than the default (Focus.fll is available in the files section or via WWW.fastwrite.com):
DECLARE _fpreset IN msvcrt20.dll

SET LIBRARY TO FOCUS.FLL 
* This method set the printer where the report is going to be printed on.
* For more information about the functions used in this method I refer to the Focus.fll 
* Documentation.
* The _fpreset is used to reset the numeric coprocessor to prevent errors (despite SP3) when using certain HP printerdrivers.

=_fpreset()
cToken= PRN_GetPrnData(ALLTRIM(cPrintername),5001)
=_fpreset()

cOldSep= STR_setsep(",")  
nTokens= STR_numtok(cToken)

=_fpreset()
THIS.Report.Selectprinter(STR_ntoken(6,cToken), STR_ntoken(3,cToken), STR_ntoken(5,cToken))
=_fpreset()
IF PRN_GetPrnData(ALLTRIM(cPrintername),7) # nOrientation
	=_fpreset()
	oReport.paperorientation=nOrientation
ENDIF
=_fpreset()
- Use the printout method (oReport.printout(.F.)) to actually print the report.
- You can customize your preview by setting the Has.....button properties of the CR smart viewer control.
- the oEventinfo object used in the smartviewer (e.g. Clicked event) is not usable with VFP. I've reported this issue to Seagate, they confirmed it to be a bug (in both CR 7,8).
- Use a SYS(2333,1) before instantiating the smartviewer control or else it will give you an OLE error.

Succes,

Walter,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform