原創|使用教程|編輯:鄭恭琳|2015-11-16 11:34:18.000|閱讀 2261 次
概述:本篇文章主要給大家簡要介紹一下跨平臺的可視化Web報表設計器-FastReport Online Designer的工作原理,希望對大家進一步了解FastReport Online Designer有幫助。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Online Designer可以與FastReport.Net的Win+Web版,專業版,企業版中的FastReport.Net WebReport對象一起使用。
在線設計器可以改變報表的報告和事件處理程序的腳本,但默認情況下,出于安全原因,該選項被禁用。該功能可在WebReport對象的屬性中來啟用。當這個選項在腳本內容中被禁用,之后的設計將被忽略被原來的文本替換。此外,為了安全起見,我們不發送Designer中內置的連接字符串。
WebReport對象存在服務器緩存中的時間有限,然后從存儲器中被刪除。對象在內存中的保存時間由WebReport.CacheDelay屬性決定,以分鐘計算(默認情況下是60)。
>>FastREport Online Designer立即在線體驗
1. 首先,從安裝路徑復制帶有在線設計器的文件夾(默認:WebReportDesigner)到Web應用程序根的目錄。
2.然后檢查WebReport功能所需的處理程序設置文件web.config:
IIS6:
< system.web> … < httpHandlers> < add path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport"/> < /httpHandlers> < /system.web>
IIS7:
< system.webServer> < handlers> < add name="FastReportHandler" path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport"/> < /handlers> < /system.webServer>
3.然后檢查Web/ ReportDesigner/scripts/ cofig-data.js文件中的報表設計器的設置:
'getReportByUUIDFrom': '/FastReport.Export.axd?getReport=', 'saveReportByUUIDTo': '/FastReport.Export.axd?putReport=', 'makePreviewByUUID': '/FastReport.Export.axd?makePreview=',
這些參數應包含FastReport處理器相對于網站的根目錄的路徑。如果路徑與所寫不同,必須要糾正,例如:
'getReportByUUIDFrom': '/oursite/FastReport.Export.axd?getReport=',
4. 當WebReport用于ASPX標記中,你需要將對象拖拽到頁面上并設置其屬性。對于MVC,你需要在控制器中寫入代碼:
4.1. 啟用報表的編輯功能:
webReport.DesignReport = true;
4.2. 設置的唯一對象名稱WebReport,必要時可以在回調頁面設置可進一步可區分的對象名稱:
webReport.ID = "MyDesignReport1";
4.3. 在在線設計器中禁止報表的腳本編輯,或者如果你想啟用編輯功能 - 設置為true即可:
webReport.DesignScriptCode = false;
4.4. 指定報表設計器的主文件的路徑,將帶有設計器的文件夾復制到網頁應用程序的適當位置:
webReport.DesignerPath = "~/WebReportDesigner/index.html";
4.5. 設置網頁上的回調頁面路徑,該調用在報表被保存到臨時文件夾后執行。例如:MVC的視圖路徑(你需要專門在控制器中創建一個新的相同名稱的空白視圖來執行回調):
webReport.DesignerSaveCallBack = "~/Home/SaveDesignedReport";
或ASPX示例:
webReport.DesignerSaveCallBack = "~/DesignerCallBack.aspx";
下面是GET請求發送的參數:
reportID="here is webReport.ID"&reportUUID="here is saved report file name"
在這兒的reportID對應WebReport.ID對象,并且名為reportUUID的文件被存儲在臨時文件夾中。開發人員執行進一步的操作,將報表保存到磁盤,數據庫或云存儲中。在保存后,名為reportUUID的臨時文件必須從臨時文件夾刪除。也可以使用POST查詢來回調報表文件的回撥轉移,性情見下面的4.6。
回調頁的示例代碼如下。
4.6設置在執行回調前用來保存編輯后的報表的臨時文件夾的路徑,該文件夾必須設置寫入權限:
webReport.DesignerSavePath = "~/App_Data/DesignedReports";
你也可以設置屬性webReport.DesignerSavePath為空字符串以激活POST模式。
4.7. 在服務器緩存中設置WebReport對象的生命周期,以分為單位,默認時間為60:
webReport.CacheDelay = 120;
5.創建一個回調頁面來保存編輯后的報表。
5.1. 如果你使用的是ASPX布局,你需要在Page_Load事件處理程序添加以下代碼:
protected void Page_Load(object sender, EventArgs e) { string reportID = Request.QueryString["reportID"]; string reportUUID = Request.QueryString["reportUUID"]; // 1. ReportID value identifies the object that caused the designer. The value corresponds to the property webReport.ID, which was filled by a call of the designer. // 2. Combining the path that we have filled in the property webReport.DesignerSavePath, and the resulting reportUUID, we get the path to the temporary file with edited report. // 3. This file can be opened and saved in the right place for us to drive or the cloud or in a database. // 4. The temporary file must be deleted after saving. }
5.2. 在MVC標記中,你需要在控制器和空視圖中創建一個方法。控制器中的代碼如下:
public ActionResult SaveDesignedReport(string reportID, string reportUUID) { // 1. ReportID value identifies the object that caused the designer. The value corresponds to the property webReport.ID, which was filled by a call of the designer. // 2. Combining the path that we have filled in the property webReport.DesignerSavePath, and the resulting reportUUID, we get the path to the temporary file with edited report. // 3. This file can be opened and saved in the right place for us to drive or the cloud or in a database. // 4. The temporary file must be deleted after saving. return View(); }
在處理POST傳送時需要在控制器前添加[HttpPost] ,如下:
[HttpPost] public ActionResult SaveDesignedReport(string reportID, string reportUUID) { ... }
5.3. 你可以通過webReport.DesignerLocale=“EN”屬性使用在線設計器的任何本地化版本; ("en" 可以更改為其它任何支持的語言,支持的語言的完整列表存放在設計器分發包中的文件中)。
當創建回調頁保存報表的處理器時應特別注意過濾和檢查收到的Get請求的參數。務必確認它們為null。
在線設計器對象的最好放置地方是在頁面的底部。推薦的寬度為100%或至少930px像素。對象的高度建議設置至少600px。
如有任何疑問請咨詢""。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn