on ‎2008 Apr 22 5:39 PM
Post Author: pward@unmc.edu
CA Forum: Other
I am relatively new to Python, and found sample code that I have, to some degree, successfully implemented. I am using the RDC and can open a report, but am having difficulties supplying connection data. If anyone else has automated Crystal in Python, either through the RDC or some other method I'd like to hear about your experience. Thanks in advance.
Request clarification before answering.
Post Author: Ted Ueda
CA Forum: Other
You might not get help specifically using Python with the Report Designer Component (RDC) - it's not something that's tested or supported.But since what you're doing is invoking COM via Python, it might be helpful to look at some working code that uses VBScript (in an ASP page):http://support.businessobjects.com/communityCS/FilesAndUpdates/aspxmps115.zip.aspThe SimpleTableLocation sample shows how to specify connection info.Sincerely,Ted Ueda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Post Author: Ted Ueda
CA Forum: Other
Thanks for your post!I should mention that the RDC is deprecated, and won't appear in CR 2008 - the newest version. I've not tried using .NET Python with Crystal Reports .NET SDK - but that may be a way foward.Sincerely,Ted Ueda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Post Author: pward
CA Forum: Other
Thanks Ted for the useful link, as promised, here's an update. The following sample code works using COM via the RDC and win32com (the excellent extensions by Mark Hammond):#open a report, set the logon info and logon to the report's server, fill the parameter using a dictionary, print the report and finally export it to PDFimport sysfrom win32com.client import Dispatchapp = Dispatch('CrystalRunTime.Application')rep = app.OpenReport('c:/TempRep/foo2.rpt')prmDict = {"p1":10, "p2":"Company Name", "p3":"Address", "p4":"Address2", "p5":"City", "p6":"Policy#", "p7":942, "p8":1, "p9":"Some Parameter 1", "p10":"Some Parameter 2", "p11":1, "p12":1, "p13":"Some Parameter 3", "p14":"Contact name" }# iterate through the tables collection, set the logon info and then logontbls = rep.Database.Tablesfor tbl in tbls: tbl.SetLogOnInfo('DSN', 'DB', 'UID', 'PWD') # use your own ODBC DSN, Databasename, UserID and Passwordapp.LogOnServertest = tbl.TestConnectivityprint test # Debug statementrep.ReadRecords # this wasn't necessary in my environment, but I've had to do this on past project (not Python)#Fill report parameters with a parameter dictionaryi = 0 #Debug iteratorfor prm in rep.ParameterFields: i = i + 1 print 'Parameter ', i, ' = ', prm.ParameterFieldName, ' = ', prmDict[prm.ParameterFieldName] #Debug statement prm.AddCurrentValue(prmDict[prm.ParameterFieldName])#Print the Report, prompting the userrep.PrintOut(promptUser=True)#Set the export options and export the reportcrExportOptions = rep.ExportOptionscrExportOptions.FormatType = 0x1f #'crEFTPortableDocFormat'crExportOptions.DestinationType = 0x1 #'crEDTDiskFile'crExportOptions.DiskFileName = 'c:/TempRep/ExportFoo2.pdf' crExportOptions.PDFExportAllPagesrep.Export(False) There really isn't much to it, of course this is just sample code so your implementation will vary (I've built a class that gets, sets and executes all the RDC methods our app could possibly use). Since you have to use win32com, you might as well download PythonWin which comes with the COM MakePy utility. The MakePy utility will wrap the COM API in Python code so you can see everything you will have at your disposal, which you could either incorporate or import into you module/class. Overall, the RDC works just as well in Python as it does in VB.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Post Author: pward
CA Forum: Other
Thanks Ted, This is helping get me further along. I have been using other tools and methods to browse the COM interface of the RDC as well as studying sample code like that in the link you provided. While it may be environmental, the RDC does not behave like other COM interfaces I have called from Python. I will post findings as they develop. Thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.