Home > php教程 > php手册 > .NET 使用 水晶报表

.NET 使用 水晶报表

WBOY
Release: 2016-06-06 20:01:00
Original
1843 people have browsed it

需要的命名空间 using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Web; using CrystalDecisions.Shared; ---------------------------------------------------- 建一个数据集文件 *.xsd -------------------------------------------

 

需要的命名空间

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using CrystalDecisions.Shared;

----------------------------------------------------

建一个数据集文件

*.xsd

-----------------------------------------------------

在页面中加一个报表查看控件

CrystalReportViewer

--------------------------------------------------------

后台代码

        dsJob dsjob = new dsJob();

        SqlConnection scn = new SqlConnection("server=.;uid=sa;pwd=111111;database=pubs;");
        scn.Open();

        SqlDataAdapter sda = new SqlDataAdapter("select * from jobs", scn);
        DataSet ds = new DataSet();
        sda.Fill(ds);

        if (ds != null && ds.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                DataRow drjob = dsjob.Tables[0].NewRow();

                drjob["job_id"] = dr["job_id"];
                drjob["job_desc"] = dr["job_desc"];

                dsjob.Tables[0].Rows.Add(drjob);
            }
        }

        CrystalReportSource crysource = new CrystalReportSource();
        crysource.ReportDocument.Load(Server.MapPath("CryPort.rpt"));

 

//给水晶报表上的文本控件赋值

        TextObject textobj = (TextObject)crysource.ReportDocument.ReportDefinition.ReportObjects["Text3"];
        textobj.Text = "chen ping";

 

        crysource.ReportDocument.SetDataSource(dsjob);
        crysource.DataBind();

        cryview.ReportSource = crysource;
        cryview.DataBind();

 

 

//给报表上的 text 控件赋值

 

        TextObject txtname = (TextObject)crysource.ReportDocument.ReportDefinition.ReportObjects["控件Name"];
        txtname.Text = "";

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template