翻譯|使用教程|編輯:王香|2018-11-14 10:03:47.000|閱讀 901 次
概述:本文介紹了用戶可以以fpx格式顯示報表,即預(yù)先準(zhǔn)備好的報表。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
FastReport.Net 2018.4版本涉及到網(wǎng)絡(luò)報表。現(xiàn)在,用戶可以以fpx格式顯示報表,即預(yù)先準(zhǔn)備好的報表。fpx格式非常便于交換報表,因為它包含模板之外的數(shù)據(jù)。因此,要以fpx格式顯示報表,您根本不需要連接到數(shù)據(jù)源,這樣就消除了數(shù)據(jù)庫位于遠(yuǎn)程服務(wù)器上時的問題。與收到數(shù)據(jù)有關(guān)的報表的編制不會有任何延誤。擁有此格式的報表,您可能希望在網(wǎng)頁上顯示它們。
讓我們創(chuàng)建一個空的ASP.Net MVC項目。 在Reference中,我們添加了FastReport.dll和FastReport.Web.dll庫,可在此處獲取: C:\ Program Files(x86)\ FastReports \ FastReport.Net \ Framework 4.0。 添加MVC 5 ViewPage(Razor)視圖。我們稱之為索引。這是它的默認(rèn)內(nèi)容:
@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title></title> </head> <body> <div> </div> </body> </html>
添加WebReport對象。當(dāng)然,我們可以在控制器中創(chuàng)建它。但是,您可以在視圖中創(chuàng)建它。
@{ 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格式添加了報表的標(biāo)題和輸出,讓我們仔細(xì)看看我們創(chuàng)建的webReport對象的設(shè)置:
要顯示W(wǎng)eb響應(yīng),我們需要導(dǎo)出到html。因此,在Web.config中我們添加處理程序:
<system.webServer> <handlers> <add name="FastReportHandler" path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport"/> </handlers> </system.webServer>
讓我們運行應(yīng)用程序:
它看起來像一個常規(guī)的網(wǎng)絡(luò)報表,這是一份fpx格式的預(yù)先準(zhǔn)備的報表,現(xiàn)在我們可以使用frx和fpx報表。
上面的示例顯示了如何直接從視圖中使用fpx報表,但如果您更習(xí)慣于在控制器中使用邏輯,則使用ViewBag將報表從控制器傳輸?shù)揭晥D。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn