搜索
首页php教程php手册.NET 使用 水晶报表

.NET 使用 水晶报表

Jun 06, 2016 pm 08:01 PM
.netphp使用命名报表空间

需要的命名空间 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 = "";

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具