將 fastreport 封裝為 ocx 控制元件

zqycn發表於2019-01-15

將 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='設計' onclick='DesignReport()'/>
<input type='button' value='預覽' onclick='ShowReport()'/>
<input type='button' value='列印' onclick='PrintReport()'/>
<input type='button' value='匯出' onclick='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='PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiIHN0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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>

 

相關文章