Python - Problema con Cristal Report y Python.

 
Vista:
sin imagen de perfil
Val: 246
Ha disminuido 1 puesto en Python (en relación al último mes)
Gráfica de Python

Problema con Cristal Report y Python.

Publicado por Roberto Matarrita (106 intervenciones) el 17/10/2017 09:42:20
Buenas noches. Instalé Sap Cristal Report versión 14.2. Al igual que instalé un ODBC para postgresql. Hasta aquí todo bien.
Luego traté de correr el reporte que hice desde python, pero no lo he podido lugar porque me da algunos errores y desconozco que puede ser. El error es el siguiente.

Traceback (most recent call last):
File "C:\Python35\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221005, 'Cadena clase no válida', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "primerreporte", line 53, in <module>
_ventana = Ventana()
File "primerreporte", line 34, in __init__
aplicacion = Dispatch('CrystalRunTime.Application')
File "C:\Python35\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python35\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python35\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'Cadena clase no válida', None, None)

***Repl Closed***

Este es el código.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
from PyQt5.QtWidgets import QApplication,QMainWindow, QDialog, QMessageBox, QWidget,QVBoxLayout,QAction
from PyQt5 import uic
import win32com.client as componenteCOM
from win32com.client import constants
from win32com.client import Dispatch
import os
import traceback
import types
 
import pythoncom
import winerror
#from import build
 
from pywintypes import IIDType
 
import win32com.client # Needed as code we eval() references it.
 
 
 
class Ventana(QMainWindow):
   def __init__(self):
    QMainWindow.__init__(self)
    try:
      objeto = componenteCOM.Dispatch('CrystalRuntime.Application')
      QMessageBox.information(self, "Correcto...","Proceso Correcto..")
 
    except:
      QMessageBox.information(self, "Error...","Error en Proceso..")
 
    nom_fich_rpt = os.path.realpath('c:\serviur\primerreporte.rpt')
    nom_fich_pdf = os.path.realpath('c:\serviur\primerreporte2.pdf')
 
    aplicacion = Dispatch('CrystalRunTime.Application')
    informe = aplicacion.OpenReport(miprimerreporte)
 
 
 
 
    if informe.HasSavedData: informe.DiscardSavedData()
 
    informe.PrintOut(promptUser=False)
 
    informe.ExportOptions.DiskFileName = primerreporte
    informe.ExportOptions.DestinationType = '1'
    informe.ExportOptions.FormatType = '31'
 
    os.startfile(nom_fich_pdf)
 
 
app = QApplication(sys.argv)
#Crear un objeto de la clase
_ventana = Ventana()
#Mostra la ventana
_ventana.show()
#Ejecutar la aplicación
app.exec_()

Espero me pueda ayudar.

Roberto
Costa Rica.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder