将 fastreport 封装为 ocx 控件

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zqycn/article/details/86489758

将 fastreport 封装为 ocx 控件

webprint.htm


<OBJECT ID='WebPrint' name='WebPrint' CLASSID='CLSID:CD74E6C5-730C-4D5F-8AFE-DAE1C4FA0639' align=center hspace=0 vspace=0></OBJECT>

<hr />
<input type='button' value='设计' οnclick='DesignReport()'/>
<input type='button' value='预览' οnclick='ShowReport()'/>
<input type='button' value='打印' οnclick='PrintReport()'/>
<input type='button' value='导出' οnclick='ExportReport()'/>

<script type='text/javascript'>
    
/*
如果浏览器弹出警告,那么请您设置浏览器安全性[选择菜单]:工具==》Internet选项 弹出选项对话框,再选择 安全 面板点击 自定义级别
在弹出的安全设置框中设置 对没有标记为安全的ActiveX控件进行初始化和脚本运行


数据源说明:
1、var:这里放入的是变量 格式=变量名:值
2、表名+'_Field':需要显示的字段  格式= 字段名:类型
   支持类型:bit、string、dateTime、float、int

3、表名+'_Fieldcn':需要显示的字段转义中文名  格式= 字段名:中文名
4、表名+'_data':表记录

其中 2、3、4 为一组配套的,都要有正确的数据,可以添加任意多组 表数据

{'var':{'total':3,'per_page':3,'current_page':1,'last_page':1},
'tp_users_Field':{'_id':int,'nickname':string,'email':string,'birthday':datetime},
'tp_users_Fieldcn':{'_id':ID,'nickname':姓名,'email':邮箱,'birthday':生日},
'tp_users_data':[
{'_id':1,'nickname':'thinkphp22122','email':'thinkphp@qq.com22','birthday':'1922\/1\/2'},
{'_id':16,'nickname':'thinkphp22122','email':'thinkphp@qq.com22','birthday':'1989-05-05'},
{'_id':17,'nickname':'aaaaa','email':'aaaa@qq.com','birthday':'1989-05-05'}],

报表文件:由组进自动根据 内存流生成 base64 的字符串,用于保存在数据库中,当控制点击 保存 按钮时触发 OnSaveToStr 事件。

使用:
  传入两个参数
      Filest : 报表文件
      dataJson :数据源  
*/


//var Filest='PD94bWwgdmVyc2lvbj0iM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_page':1},'tp_users_Field':{'_id':int,'nickname':string,'email':string,'birthday':datetime},'tp_users_Fieldcn':{'_id':ID,'nickname':姓名,'email':邮箱,'birthday':生日},'tp_users_data':[{'_id':1,'nickname':'thinkphp22122','email':'thinkphp@qq.com22','birthday':'1922\/1\/2'},{'_id':16,'nickname':'thinkphp22122','email':'thinkphp@qq.com22','birthday':'1989-05-05'},{'_id':17,'nickname':'aaaaa','email':'aaaa@qq.com','birthday':'1989-05-05'}],'tp_users1_Field':{'_id':int,'nickname':string,'email':string,'birthday':datetime},'tp_users1_Fieldcn':{'_id':ID,'nickname':姓名,'email':邮箱,'birthday':生日},'tp_users1_data':[{'_id':1,'nickname':'aaaa','email':'aaaa@qq.com22','birthday':'1922\/1\/2'},{'_id':16,'nickname':'bbbb','email':'bbbb@qq.com22','birthday':'1989-05-05'},{'_id':17,'nickname':'cccc','email':'cccc@qq.com','birthday':'1989-05-05'}]}"

var WebPrint = document.getElementById("WebPrint");
var DesignReport = function(){
    WebPrint.DesignReport(Filest,dataJson);
}

var ShowReport = function(){
    WebPrint.ShowReport(Filest,dataJson);
}

var PrintReport = function(){
    WebPrint.PrintReport(Filest,dataJson);
}

var ExportReport = function(){
    WebPrint.ExportReport(Filest,dataJson);
}
</script>

 <script language="javascript" event="OnSaveToStr(aStr)" for="WebPrint">
        Filest = aStr;
     return 2;
 </script>

 

展开阅读全文

没有更多推荐了,返回首页