翻譯|使用教程|編輯:王香|2018-11-14 10:03:47.000|閱讀 901 次
概述:本文介紹了用戶可以以fpx格式顯示報表,即預先準備好的報表。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
FastReport.Net 2018.4版本涉及到網絡報表。現在,用戶可以以fpx格式顯示報表,即預先準備好的報表。fpx格式非常便于交換報表,因為它包含模板之外的數據。因此,要以fpx格式顯示報表,您根本不需要連接到數據源,這樣就消除了數據庫位于遠程服務器上時的問題。與收到數據有關的報表的編制不會有任何延誤。擁有此格式的報表,您可能希望在網頁上顯示它們。
讓我們創建一個空的ASP.Net MVC項目。 在Reference中,我們添加了FastReport.dll和FastReport.Web.dll庫,可在此處獲取: C:\ Program Files(x86)\ FastReports \ FastReport.Net \ Framework 4.0。 添加MVC 5 ViewPage(Razor)視圖。我們稱之為索引。這是它的默認內容:
@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title></title> </head> <body> <div> </div> </body> </html>
添加WebReport對象。當然,我們可以在控制器中創建它。但是,您可以在視圖中創建它。
@{ Layout = null; } @{ // FastReport .Net prepared report preview example. FastReport.Web.WebReport webReport = new FastReport.Web.WebReport(true, true); webReport.ToolbarIconsStyle = FastReport.Web.ToolbarIconsStyle.Black; webReport.ToolbarBackgroundStyle = FastReport.Web.ToolbarBackgroundStyle.None; webReport.ToolbarStyle = FastReport.Web.ToolbarStyle.Large; webReport.ToolbarColor = System.Drawing.Color.White; webReport.BorderWidth = 1; webReport.BorderColor = System.Drawing.Color.Black; webReport.ShowZoomButton = false; webReport.ShowExports = false; webReport.PrintInBrowser = false; webReport.XlsxPrintFitPage = true; webReport.LoadPrepared(Server.MapPath("~/App_Data/Prepared.fpx")); } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>FastReport Prepared Report Preview</title> </head> <body> @webReport.GetHtml() </body> </html>
此外,我們以HTML格式添加了報表的標題和輸出,讓我們仔細看看我們創建的webReport對象的設置:
要顯示Web響應,我們需要導出到html。因此,在Web.config中我們添加處理程序:
<system.webServer> <handlers> <add name="FastReportHandler" path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport"/> </handlers> </system.webServer>
讓我們運行應用程序:
它看起來像一個常規的網絡報表,這是一份fpx格式的預先準備的報表,現在我們可以使用frx和fpx報表。
上面的示例顯示了如何直接從視圖中使用fpx報表,但如果您更習慣于在控制器中使用邏輯,則使用ViewBag將報表從控制器傳輸到視圖。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn