翻譯|使用教程|編輯:李顯亮|2021-08-19 10:51:28.343|閱讀 491 次
概述:FastReport Online Designer 是一個跨平臺的報表設計器,允許通過任何平臺移動設備創建和編輯報表。本文是設置在線設計器的分步手冊。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
沒有報表,就不可能在任何生活領域開展業務。無論是鋼廠還是學校的院系人員——到處都需要報表:會計、統計、運營等等。由于現代世界高度計算機化,報表也以電子方式進行。如果沒有特殊程序——報表生成器,創建大量報表將非常困難。
FastReport報表生成器出現在此類軟件的早期,并在Delphi程序員中大受歡迎。隨著.Net Framework版本的出現——它也已在Microsoft平臺的擁護者中廣泛傳播。
隨著信息時代的深入,web在線操作的時代已經來臨,Fastreport也順應時代的變化,推出了可視化在線報表設計器——FastReport Online Designer。
設置在線設計器的分步手冊。
1. 首先,讓我們從安裝路徑中復制一個包含在線設計器(默認為:WebReportDesigner)的文件夾到Web應用程序根目錄。
2. 然后檢查web.config文件,查看WebReport功能所需的處理程序設置。
for IIS6:
<system.web> … <httpHandlers> <addpath="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport"/> </httpHandlers> </system.web> for IIS7: <system.webServer> <handlers> <addname="FastReportHandler" path="FastReport.Export.axd" verb="*" type="FastReport.Web. Handlers.WebExport"/> </handlers> </system.webServer>
3. 然后檢查WebReportDesigner/scripts/configdata.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. 指定報告設計器主文件的路徑,帶有設計器的文件夾應被復制到Web-Application的適當位置:
webReport.DesignerPath = "~/WebReportDesigner/index.html";
4.5. 在網站上設置回調頁面的路徑,在報告被保存到臨時文件夾后執行調用。例如,MVC的視圖路徑(你必須在控制器中創建新的空白視圖,專門用于同名的回調):
webReport.DesignerSaveCallBack = "~/Home/SaveDesignedReport";
or, for 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 resaved in the appropriate place (another file, cloud, a database, etc). // 4. The temporary file must be deleted after saving. }
5.2. 在MVC標記中,你需要在控制器中創建一個方法和一個空的視圖。控制器中的代碼:
{ // 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 resaved in the appropriate place (another file, cloud, a database, etc). // 4. The temporary file must be deleted after saving. return View(); }
5.3. 你可以為在線設計器使用任何本地化:
webReport.DesignerLocale = "en";
("en "可以改成任何其他支持的語言,支持的語言的完整列表類似于設計器發布包中 "locales "文件夾中的文件)。
當在回調頁面創建處理程序時,注意過濾和檢查Get/POST請求中的參數。一定要檢查它們是否為空值。
使用On-line Designer的最佳位置是在頁面的底部。建議寬度為100%或至少930px。建議對象的高度至少是600px。
還想要更多嗎?您可以點擊閱讀【FastReport 報表2020最新資源盤點】,查找需要的教程資源。讓人興奮的是FastReport .NET正在慧都網火熱銷售中,低至3701元起!>>查看價格詳情
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn