FastReport报表MVC显示步骤

FastReport报表MVC使用步骤如下:

1、创建MVC网站项目

最终DEMO如下图所示

2、引用相关DLL

FastReport.dll

FastReport.Web.dll

3、Web.config中增加配置

1<system.webServer> 2 <handlers> 3 <add name="FastReport-Export" path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport" /> 4 </handlers> 5</system.webServer>

4、Action代码

1 1 public class HomeController : Controller 2 2 { 3 3 public ActionResult Index() 4 4 { 5 5 var webReport = new WebReport(); 6 6 7 7 var dataPath= Server.MapPath("~/frAssets/Reports/nwind.xml"); 8 8 var dataSet = new System.Data.DataSet(); 9 9 dataSet.ReadXml(dataPath); 1010 webReport.Report.RegisterData(dataSet, "NorthWind"); 1111 1212 var reportPath = Server.MapPath("~/frAssets/Reports/SimpleList.frx"); 1313 webReport.Report.Load(reportPath); 1414 1515 webReport.Width = Unit.Percentage(100); 1616 webReport.Height = Unit.Percentage(100); 1717 //设置Toobar图标样式 1818 webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;//ToolbarIconsStyle.Custom; 1919 //设置Background样式 2020 webReport.ToolbarBackgroundStyle = ToolbarBackgroundStyle.Medium; 2121 //设置自定义按钮图片路径 2222 webReport.ButtonsPath = "/frAssets/Buttons/"; 2323 //本地化文件 2424 webReport.LocalizationFile = "/frAssets/Localization/Chinese (Simplified).frl"; 2525 webReport.PrintInPdf = false; 2626 ViewBag.WebReport = webReport; 2727 return View(); 2828 } 2929 3030 }

5、View中引入样式

11 @WebReportGlobals.Scripts() 22 @WebReportGlobals.Styles()

6、View中添加报表呈现代码

11 <div id="report-wrapper"> 22 @ViewBag.WebReport.GetHtml() 33 </div>

7、报表居中样式处理

1 <style type="text/css"> 2 html > /**/ body .container { 3 margin: 0; 4 max-width: 100%; 5 } 6 7 #report-wrapper .frtoolbar { 8 width: 100%; 9 } 10 11 #report-wrapper #frbody { 12 text-align: center; 13 } 14 15 #report-wrapper #frbody > div { 16 margin: 0 auto; 17 } 18 19 html > /**/ body #report-wrapper span > div > div { 20 display: block; 21 text-align: center; 22 } 23 </style>

8、项目Demo源码

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


文章作者:花生(OutMan)

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

发布时间:2018年3月15日

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

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

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

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )