FastReport在MVC中安装使用

来源:互联网 发布:淘宝联盟分享不了图片 编辑:程序博客网 时间:2024/05/18 00:50

1、在根文件webconfig中加入以下信息

iis6版本,在system.web中加入

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

ii7版本,在system.webServer中加入

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

2、在包含views的文件夹中webconfig中加入以下信息:引用命名空间

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

3、在_Layout.cshtml文件中<head>加入

@WebReportGlobals.Scripts()@WebReportGlobals.Styles()
4、在方法中写入调用方法

 var id=Request.Params["id"];            WebReport webReport = new WebReport(); // 创建报表对象            webReport.Width = 600;//设置报表宽度            webReport.Height = 800;//设置报表高度            webReport.Report.SetParameterValue("param", id);//传递报表参数             webReport.Report.RegisterData(dataSet, "AppData"); //传递数据             webReport.ReportFile = this.Server.MapPath("~/App_Data/report.frx");//调用报表            ViewBag.WebReport = webReport;//赋值报表给页面             return View();//返回页面

5、在view视图中加入

@ViewBag.WebReport.GetHtml()

找不到命名:原因fastreport老版本不支持,需要新版本



1 0
原创粉丝点击