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老版本不支持,需要新版本
本文介绍了如何在MVC应用中安装和使用FastReport。主要内容包括在web.config文件中添加特定配置,特别是对于IIS6环境下需要注意的版本兼容问题。


被折叠的 条评论
为什么被折叠?



