FastReport在MVC中安装使用

本文介绍了如何在MVC应用中安装和使用FastReport。主要内容包括在web.config文件中添加特定配置,特别是对于IIS6环境下需要注意的版本兼容问题。

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老版本不支持,需要新版本



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值