zoukankan      html  css  js  c++  java
  • ActiveReport之WebMVC打印报表

    开发插件 ActiveRepoert

    1.新建一个MVC的web项目

    2.新建项

     3.设置表格需要打印的字段

    4.新建aspx显示报表视图

    <body>
        <form id="form1" runat="server">
        
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
                </ContentTemplate>
            </asp:UpdatePanel>
        </form>
    </body>
    RdlcView.aspx
    public partial class RdlcView : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if(!IsPostBack)
                {
                    DbContextBase db = new DbContextBase();
                    var list = db.PurchaseOrderTBs.ToList();
                    this.ReportViewer1.Reset();
                    this.ReportViewer1.LocalReport.Dispose();
                    this.ReportViewer1.LocalReport.DataSources.Clear();
                    ReportDataSource ReportDataSource = new ReportDataSource();
                    ReportDataSource.Name = "DataSet1";
                    ReportDataSource.Value = list;
                    this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/Report1.rdlc");
                    this.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource);
                    this.ReportViewer1.LocalReport.Refresh();
                }
            }
    
    
        }
    RdlcView.aspx.cs

    5.MVC控制器中加载aspx视图文件

            public ActionResult Report()
            {
                string aspx = "/AspNets/RdlcView.aspx";
                using(var sw=new StringWriter())
                {
                    System.Web.HttpContext.Current.Server.Execute(aspx, sw, true);
                    return Content(sw.ToString());
                }
            }
    View Code

     6.Web.config增加配置节点ReportViewerWebControlHandler

      <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <handlers>
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
          <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFramework64v4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
          <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
    
    
            <add name="ReportViewerWebControlHandler" preCondition="integratedMode"
               verb="*" path="Reserved.ReportViewerWebControl.axd"
               type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
        </handlers>
      </system.webServer>
    View Code
  • 相关阅读:
    如何查看MySQL的当前存储引擎?
    避免生产环境执行更新删除语句忘记加where条件的解决方案
    物联网发展的现状
    目前行业内比较流行的开源时序数据库产品
    如何查看端口(3306)被那个程序占用
    MySQL数据库开发的36条军规
    介绍 MySQL 8 中值得关注的新特性和改进。
    IE浏览器 兼容性(IE9-11 差异说明)
    python3:(unicode error) 'utf-8' codec can't decode
    静态代码块
  • 原文地址:https://www.cnblogs.com/liandy0906/p/7936524.html
Copyright © 2011-2022 走看看