FastReport报表MVC显示步骤

FastReport报表MVC使用步骤如下:

1、创建MVC网站项目

最终DEMO如下图所示

 

2、引用相关DLL

FastReport.dll

FastReport.Web.dll

3、Web.config中增加配置
<system.webServer>
    <handlers>
        <add name="FastReport-Export" path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport" />
    </handlers>
</system.webServer>
4、Action代码
 1     public class HomeController : Controller
 2     {
 3         public ActionResult Index()
 4         {
 5             var webReport = new WebReport();
 6 
 7             var dataPath= Server.MapPath("~/frAssets/Reports/nwind.xml");
 8             var dataSet = new System.Data.DataSet();
 9             dataSet.ReadXml(dataPath);
10             webReport.Report.RegisterData(dataSet, "NorthWind");
11 
12             var reportPath = Server.MapPath("~/frAssets/Reports/SimpleList.frx");
13             webReport.Report.Load(reportPath);
14 
15             webReport.Width = Unit.Percentage(100);
16             webReport.Height = Unit.Percentage(100);
17             //设置Toobar图标样式
18             webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;//ToolbarIconsStyle.Custom;
19             //设置Background样式
20             webReport.ToolbarBackgroundStyle = ToolbarBackgroundStyle.Medium;
21             //设置自定义按钮图片路径
22             webReport.ButtonsPath = "/frAssets/Buttons/";
23             //本地化文件
24             webReport.LocalizationFile = "/frAssets/Localization/Chinese (Simplified).frl";
25             webReport.PrintInPdf = false;
26             ViewBag.WebReport = webReport;
27             return View();
28         }
29         
30     }
5、View中引入样式
1 @WebReportGlobals.Scripts()
2 @WebReportGlobals.Styles()

 

6、View中添加报表呈现代码
1 <div id="report-wrapper">
2     @ViewBag.WebReport.GetHtml()
3 </div>

 

7、报表居中样式处理
    <style type="text/css">
        html > /**/ body .container {
            margin: 0;
            max-width: 100%;
        }

        #report-wrapper .frtoolbar {
            width: 100%;
        }

        #report-wrapper #frbody {
            text-align: center;
        }

            #report-wrapper #frbody > div {
                margin: 0 auto;
            }

        html > /**/ body #report-wrapper span > div > div {
            display: block;
            text-align: center;
        }
    </style>

 

8、项目Demo源码

https://files.cnblogs.com/files/WangHuaiSheng/FastReportMvcDemo.7z

 

 


 文章作者:花生(OutMan)

发布地址:http://www.cnblogs.com/WangHuaiSheng/ 

发布时间:2018年3月15日

本文版权归作者和博客园共有,欢迎转载,

但未经作者同意必须保留此段声明,

且在文章页面明显位置给出原文连接。

 

转载于:https://www.cnblogs.com/WangHuaiSheng/p/8575293.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值