zoukankan      html  css  js  c++  java
  • Stimulsoft_Report纯代码实现数据绑定

    Stimulsoft_Report纯代码实现数据绑定

    根据穿的参数动态绑定显示报表,涉及多表查询。

    一、前台代码:


    [code]  <%@ Page Title="" Language="C#" MasterPageFile="~/WebMaster/OpenWin_FixHead.Master" AutoEventWireup="true" CodeBehind="ProjectReport.aspx.cs" Inherits="HuaiNanSys.Page.ProjectInformation.ProjectReport" %>

    <%@ register Namespace="Stimulsoft.Report.Web" TagPrefix="cc1"   Assembly="Stimulsoft.Report.Web"%>

    <%@ register Namespace="Stimulsoft.Report.Web" TagPrefix="cc2" Assembly="Stimulsoft.Report.WebDesign"%>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    </asp:Content>

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">

         <cc1:StiWebViewer ID="StiWebViewer1" runat="server" GlobalizationFile="/Content/page/reports/Localization/zh-CHS.xml" ShowDesignButton="False" onreportdesign="StiWebViewer1_ReportDesign" Theme="Office2010" BackColor="#e8e8e8"/>

         <cc2:StiWebDesigner ID="StiWebDesigner1" runat="server" LocalizationDirectory="/Content/page/reports/Localization/" Localization="zh-CHS"  onsavereport="StiWebDesigner1_SaveReport" />

     

    </asp:Content>



    二、后台代码:

    using Stimulsoft.Report; 

    using Stimulsoft.Report.Components; 

    using System; 

    using System.Collections.Generic; 

    using System.Data; 

    using System.Linq; 

    using System.Web; 

    using System.Web.UI; 

    using System.Web.UI.WebControls;

    namespace Page.ProjectInformation 



    public partial class ProjectReport : BaseContentPage_UsingMaster 



    protected void Page_Load(object sender, EventArgs e) 



    string RowGuid = Request.QueryString[“RowGuid”];


    [code]        ShowReport(RowGuid);

        }

        public void ShowReport(string rowGuid)

        {

            DataSet ds = new DataSet();

            MisGuidRow mis = new MisGuidRow("View_ProjectInformation");

            DataView dv = mis.Select("*", "RowGuid='" + rowGuid + "'");

            ds.Tables.Add(dv.ToTable());

            string filepath = Server.MapPath("~/Report.mrt");

            StiReport stireport = new StiReport();

            stireport.Load(filepath);

     

            stireport.RegData("datasource", ds);

     

            DataTable dt = ds.Tables[0];

            StiDataBand D = stireport.Pages[0].Components["DataBand1"] as StiDataBand;

            StiText ProjectName = D.Components["ProjectName"] as StiText;

            ProjectName.Text = Convert.ToString(dt.Rows[0]["ProjectName"]);

     

            stireport.Compile();

            StiWebViewer1.Report = stireport;

     

        }

     

        protected void StiWebViewer1_ReportDesign(object sender, Stimulsoft.Report.Web.StiReportDesignEventArgs e)

        {

            string filepath = Server.MapPath("~/Report.mrt");

            StiReport stireport = new StiReport();

            stireport.Load(filepath);

            stireport.Compile();

            StiWebDesigner1.Design(stireport);

        }

     

        protected void StiWebDesigner1_SaveReport(object sender, Stimulsoft.Report.Web.StiWebDesigner.StiSaveReportEventArgs e)

        {

            var report = e.Report;

            string filepath = Server.MapPath("~/Report.mrt");

            report.Save(filepath);

        }

    }



    }

    三、引用dll 



    四、在designer.exe中设计报表,只需要画出样式,不需要连接和绑定数据源 

    报表树结构如下:用的是text 

  • 相关阅读:
    mysql性能优化
    pymysql模块
    mysql数据表约束
    MySQL数据库
    IO模型
    8451
    8946531
    6783
    256213
    27822
  • 原文地址:https://www.cnblogs.com/Jeely/p/10967755.html
Copyright © 2011-2022 走看看