python 调用 fastreport.dll

       前文说到了python调用c#的dll,fastreport在c#报表中很好使用,那么是否可以通过python直接调用fastreport.dll出报告那,答案是肯定的。

具体代码如下:

import  clr

clr.FindAssembly("FastReport.dll")
from FastReport import *
report=Report()
report.Load("test.frx")
report.Show();

但是这样写会在弹出fastreport页面前报.net程序的一个错误:

经过查找原因:说是.net程序多线程的一个问题,尝试通过在Python中开启一个 线程去单独执行这段代码就不会报错了。具体代码如下:

import  clr
import  threading

def fastRepot_run():
    report = Report()
    report.Load("test.frx")
    report.Show();
clr.FindAssembly("FastReport.dll")
from FastReport import *
threading.Thread(target=fastRepot_run).start()

猜你喜欢

转载自blog.csdn.net/zhuoyue008/article/details/82178182