Getting started with Crystal Reports...little help in the far court.

Brian almondb at gmail.com
Tue Jan 9 00:09:41 EST 2007


Mudcat wrote:
> I am not that familiar with Crystal Reports, but having read some other
> posts I know that the way to integrate the API with Python is through
> the COM interface provide by win32all.
....
> Any pointers in the right direction would be helpful.

Like Armury, I worked on Crystal stuff quite a long time ago.  Here's a
script I was able to dig up.  Edited to protect the innocent.  ;-)

import sys
from win32com.client import Dispatch

app = Dispatch('CrystalRunTime.Application')
rep = app.OpenReport('foo.rpt')
tbl = rep.Database.Tables.Item(1)

prop = tbl.ConnectionProperties('Password')
prop.Value = sys.argv[1]

prop = tbl.ConnectionProperties('Data Source')
prop.Value = 'server'

# tbl.TestConnectivity() should return 1

# clear and set 3 parameters
params = rep.ParameterFields
p1 = params(1)
p2 = params(2)
p3 = params(3)

for param in (p1,p2,p3): param.ClearCurrentValueAndRange()

p1.AddCurrentValue(123)
p2.AddCurrentValue(456)
p3.AddCurrentValue('12/31/99')

rep.PrintOut(promptUser=False)




More information about the Python-list mailing list