FastReport.Net在Rozor中的應用

來源:互聯網
上載者:User

標籤:

Webconfig中配置

IIS6.0 <system.web> <httpHandlers> 下增加

<httpHandlers>       <add path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport"/>  </httpHandlers>  

IIS7.0後  <system.webServer>  <handlers>

 <system.webServer>    <handlers>      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />      <remove name="OPTIONSVerbHandler" />      <remove name="TRACEVerbHandler" />      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />      <remove name="FastReportHandler"/>       <add name="FastReportHandler" path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport" />    </handlers>       <staticContent>        <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />        <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff" />    </staticContent>      </system.webServer>

 

<system.web.webPages.razor>中增加節點

<add namespace="FastReport" /><add namespace="FastReport.Web" />

 

 

在Rozor中代碼

@{    ViewBag.Title = "Index";}@FastReport.Web.WebReportGlobals.ScriptsWOjQuery()@FastReport.Web.WebReportGlobals.StylesWOjQuery()<style >    .frtoolbar{        height:40px !important;    }</style><div style="overflow:scroll;height:100%">    @ViewBag.WebReport.GetHtml()</div>

 

 

Action代碼

 public ActionResult Index()        {            SetReport();            webReport.Width = Unit.Percentage(100); //             webReport.Height = Unit.Percentage(100);// ;             webReport.ToolbarIconsStyle = ToolbarIconsStyle.Red;            webReport.ToolbarStyle = ToolbarStyle.Small;            webReport.ShowExports = true;            webReport.ShowToolbar = true;            webReport.ShowZoomButton = true;            webReport.ShowPrint = true;            webReport.AutoHeight = true;            ViewBag.WebReport = webReport;            return View();        }        private void SetReport()        {            string report_path = GetReportPath();            var user = (User)HttpContext.Session[Common.Constants.USER_KEY];            webReport.Report.Load(report_path + "test2.frx");            webReport.Report.Parameters.FindByName("工號").Value = user.SysOperator.LoginName;            webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;            webReport.ShowExports = true;            webReport.ShowPrint = true;            ViewBag.WebReport = webReport;        }        private string GetReportPath()        {            string report_path = Config.ApplicationFolder;            using (XmlDocument xml = new XmlDocument())            {                xml.Load(@Server.MapPath("../../App_Data/fastReport.config"));                foreach (XmlItem item in xml.Root.Items)                    if (item.Name == "Config")                        foreach (XmlItem configitem in item.Items)                            if (configitem.Name == "Reports")                                report_path += configitem.GetProp("Path");            }            return report_path;        }

fastReport.config

<?xml version="1.0" encoding="utf-8" ?><Test>         <Config>                    <Reports Path="\App_Data\report\"/>         </Config></Test>

FastReport設計

因為這裡的資料來源是預存程序並且用到了暫存資料表,所有預存程序中需要增加

IF 1=0 BEGIN      SET FMTONLY OFF  END  

否則提示#temp無效

 

這裡是通過程式後台傳遞參數,所以要注意一下

1.

2.

3.

 

PS:還有一點需要強調,FastReport資料來源可以直接載入,不需要後台傳遞DataSet也是可以載入的,但要保證預存程序的正確性

附上FastReport可用版本http://download.csdn.net/detail/anbylau2130/9608832

FastReport.Net在Rozor中的應用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.