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
  • 相关阅读:
    element-ui的table表格控件表头与内容列不对齐问题
    uniapp 调用手机相机拍照实现图片上传
    配置Git忽略文件
    【转载】Java的几种常见排序算法
    httpclient封装
    idea 启动springboot项目时报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource
    shell脚本监控网站,异常则进行邮件报警
    nginx配置图片跨域访问
    Nginx基于多端口、多域名配置
    docker部署Nginx项目dockerfile
  • 原文地址:https://www.cnblogs.com/liandy0906/p/7936524.html
Copyright © 2011-2022 走看看