Printing using a Report Generator

How to print information stored in a database from within a wxPython application (actually any Python app)?

There are many solutions out there, but it seems to be a regular question and as I recently updated how I am doing it I thought this might be useful for others.

I'll create a section for Report Manager (which is the Generator I use), maybe others can expand this with information on other Report Generator tools.

Report Manager

Report Manager is a pretty powerful report generator and you can find it at http://reportman.sourceforge.net/.

There are different ways of integrating it with your Python application, I explain below just the option I have choosen.

Besides Report Manager you will also need to get these:

http://starship.python.net/crew/theller/ctypes/ - Python 2.5 already includes the ctypes module

http://groups.yahoo.com/group/reportman/files/PyReportManager-0.1.0.zip - a Python script wrappen ctypes and the Report Manager's ActiveX

After you installed the above and create a report you only need a few lines of code to run your report.

   1 # import the ActiveX wrapper code
   2 from reportman import ReportMan
   3 
   4 # define some values for report parameters
   5 # DRINKTYPE is used in the SQL where clause of the report and LANG defines what language to use (5 = German)
   6 params = (('DRINKTYPE_BEG', 1), ('DRINKTYPE_END', 2), ('LANG', 5))
   7 
   8 report = ReportMan(r"yourreportfile.rep")
   9 
  10 for param in params:
  11     report.set_param(param[0], param[1])
  12 
  13 report.preview('a title to be shown in the window title bar')

Comments

Any comments are welcome, please feel free to just add them to this page, or you can also send them to me werner.bruhin at free.fr

PrintingWithReportGenerators (last edited 2008-03-11 10:50:29 by localhost)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.