原創(chuàng)|使用教程|編輯:鄭恭琳|2015-11-16 11:34:18.000|閱讀 2261 次
概述:本篇文章主要給大家簡要介紹一下跨平臺的可視化Web報表設(shè)計器-FastReport Online Designer的工作原理,希望對大家進(jìn)一步了解FastReport Online Designer有幫助。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Online Designer可以與FastReport.Net的Win+Web版,專業(yè)版,企業(yè)版中的FastReport.Net WebReport對象一起使用。
在線設(shè)計器可以改變報表的報告和事件處理程序的腳本,但默認(rèn)情況下,出于安全原因,該選項被禁用。該功能可在WebReport對象的屬性中來啟用。當(dāng)這個選項在腳本內(nèi)容中被禁用,之后的設(shè)計將被忽略被原來的文本替換。此外,為了安全起見,我們不發(fā)送Designer中內(nèi)置的連接字符串。
WebReport對象存在服務(wù)器緩存中的時間有限,然后從存儲器中被刪除。對象在內(nèi)存中的保存時間由WebReport.CacheDelay屬性決定,以分鐘計算(默認(rèn)情況下是60)。
>>FastREport Online Designer立即在線體驗
1. 首先,從安裝路徑復(fù)制帶有在線設(shè)計器的文件夾(默認(rèn):WebReportDesigner)到Web應(yīng)用程序根的目錄。
2.然后檢查WebReport功能所需的處理程序設(shè)置文件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文件中的報表設(shè)計器的設(shè)置:
'getReportByUUIDFrom': '/FastReport.Export.axd?getReport=', 'saveReportByUUIDTo': '/FastReport.Export.axd?putReport=', 'makePreviewByUUID': '/FastReport.Export.axd?makePreview=',
這些參數(shù)應(yīng)包含F(xiàn)astReport處理器相對于網(wǎng)站的根目錄的路徑。如果路徑與所寫不同,必須要糾正,例如:
'getReportByUUIDFrom': '/oursite/FastReport.Export.axd?getReport=',
4. 當(dāng)WebReport用于ASPX標(biāo)記中,你需要將對象拖拽到頁面上并設(shè)置其屬性。對于MVC,你需要在控制器中寫入代碼:
4.1. 啟用報表的編輯功能:
webReport.DesignReport = true;
4.2. 設(shè)置的唯一對象名稱WebReport,必要時可以在回調(diào)頁面設(shè)置可進(jìn)一步可區(qū)分的對象名稱:
webReport.ID = "MyDesignReport1";
4.3. 在在線設(shè)計器中禁止報表的腳本編輯,或者如果你想啟用編輯功能 - 設(shè)置為true即可:
webReport.DesignScriptCode = false;
4.4. 指定報表設(shè)計器的主文件的路徑,將帶有設(shè)計器的文件夾復(fù)制到網(wǎng)頁應(yīng)用程序的適當(dāng)位置:
webReport.DesignerPath = "~/WebReportDesigner/index.html";
4.5. 設(shè)置網(wǎng)頁上的回調(diào)頁面路徑,該調(diào)用在報表被保存到臨時文件夾后執(zhí)行。例如:MVC的視圖路徑(你需要專門在控制器中創(chuàng)建一個新的相同名稱的空白視圖來執(zhí)行回調(diào)):
webReport.DesignerSaveCallBack = "~/Home/SaveDesignedReport";
或ASPX示例:
webReport.DesignerSaveCallBack = "~/DesignerCallBack.aspx";
下面是GET請求發(fā)送的參數(shù):
reportID="here is webReport.ID"&reportUUID="here is saved report file name"
在這兒的reportID對應(yīng)WebReport.ID對象,并且名為reportUUID的文件被存儲在臨時文件夾中。開發(fā)人員執(zhí)行進(jìn)一步的操作,將報表保存到磁盤,數(shù)據(jù)庫或云存儲中。在保存后,名為reportUUID的臨時文件必須從臨時文件夾刪除。也可以使用POST查詢來回調(diào)報表文件的回?fù)苻D(zhuǎn)移,性情見下面的4.6。
回調(diào)頁的示例代碼如下。
4.6設(shè)置在執(zhí)行回調(diào)前用來保存編輯后的報表的臨時文件夾的路徑,該文件夾必須設(shè)置寫入權(quán)限:
webReport.DesignerSavePath = "~/App_Data/DesignedReports";
你也可以設(shè)置屬性webReport.DesignerSavePath為空字符串以激活POST模式。
4.7. 在服務(wù)器緩存中設(shè)置WebReport對象的生命周期,以分為單位,默認(rèn)時間為60:
webReport.CacheDelay = 120;
5.創(chuàng)建一個回調(diào)頁面來保存編輯后的報表。
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標(biāo)記中,你需要在控制器和空視圖中創(chuàng)建一個方法??刂破髦械拇a如下:
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”屬性使用在線設(shè)計器的任何本地化版本; ("en" 可以更改為其它任何支持的語言,支持的語言的完整列表存放在設(shè)計器分發(fā)包中的文件中)。
當(dāng)創(chuàng)建回調(diào)頁保存報表的處理器時應(yīng)特別注意過濾和檢查收到的Get請求的參數(shù)。務(wù)必確認(rèn)它們?yōu)閚ull。
在線設(shè)計器對象的最好放置地方是在頁面的底部。推薦的寬度為100%或至少930px像素。對象的高度建議設(shè)置至少600px。
如有任何疑問請咨詢""。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn