国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

水晶報(bào)表填充.Net Objects數(shù)據(jù)源

2019-11-17 01:30:30
字體:
供稿:網(wǎng)友

水晶報(bào)表填充.Net Objects數(shù)據(jù)源

Crystal Reports(水晶報(bào)表)是一款商務(wù)智能(BI)軟件,主要用于設(shè)計(jì)及產(chǎn)生報(bào)表。是業(yè)內(nèi)最專業(yè)、功能最強(qiáng)的報(bào)表系統(tǒng)。

查看網(wǎng)絡(luò)資料及課本圖書,鮮有介紹通過.NET Objects作為數(shù)據(jù)源填充水晶報(bào)表的示例。本文將通過兩個(gè)簡單的示例演示水晶報(bào)表填充.Net Objects數(shù)據(jù)源的過程。

示例一:打印學(xué)生信息(一個(gè).NET Objects數(shù)據(jù)源的填充)

示例效果:

image

Student.cs

using System;
using System.Collections.Generic;
using System.Web;
namespace CrystalReportsDemo
{
    public class Student
    {
        public Student(string studentNo,string studentName,string sex,int age)
        {
            this.StudentNo = studentNo;
            this.StudentName = studentName;
            this.Sex = sex;
            this.Age = age;
        }
        public string StudentNo
        { set; get; }
        public string StudentName
        { set; get; }
        public string Sex
        { get; PRivate set; }
        public int Age
        { get; private set; }
    }
}

將其編譯后,即可通過數(shù)據(jù)庫專家將其作為數(shù)據(jù)源導(dǎo)入到字段資源管理器。

image

繪制報(bào)表樣式并插入數(shù)據(jù)庫字段:

image

在Default.aspx頁面拖入CrystalReportViewer控件:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CrystalReportsDemo._Default" %>
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <CR:CrystalReportViewer ID="crvReport" runat="server" AutoDataBind="true" />
    
    </div>
    </form>
</body>
</html>

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CrystalReportsDemo
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FillReport();
        }
        private void FillReport()
        {
            List<Student> studentList = new List<Student>();
            studentList.Add(new Student("200901001", "學(xué)生一", "男", 23));
            studentList.Add(new Student("200901002", "學(xué)生二", "男", 24));
            studentList.Add(new Student("200901003", "學(xué)生三", "女", 22));
            studentList.Add(new Student("200901004", "學(xué)生四", "男", 23));
            studentList.Add(new Student("200901005", "學(xué)生五", "女", 25));
            studentList.Add(new Student("200901006", "學(xué)生六", "男", 23));
            CrStudents studentsReport = new CrStudents();
            studentsReport.SetDataSource(studentList);
            crvReport.ReportSource = studentsReport;
        }
    }
}

示例二:打印學(xué)生成績(多個(gè).NET Objects數(shù)據(jù)源的填充)

示例效果:

image

Subject.cs

using System;
using System.Collections.Generic;
using System.Web;
namespace CrystalReportsDemo
{
    public class Subject
    {
        public Subject(string subjectName,string subjectType,double result,string comment)
        {
            this.SubjectName = subjectName;
            this.SubjectType = subjectType;
            this.Result = result;
            this.Comment = comment;
        }
        public string SubjectName
        { set; get; }
        public string SubjectType
        { set; get; }
        public double Result
        { set; get; }
        public string Comment
        { set; get; }
    }
}

主報(bào)表:(CrSupReport.rpt)

image

子報(bào)表:(CrSubReport.rpt)

image

Default2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default2.aspx.cs" Inherits="CrystalReportsDemo.Default2" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <CR:CrystalReportViewer ID="crvReport2" runat="server" AutoDataBind="true" />
    </div>
    </form>
</body>
</html>

Default2.aspx.cs

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
namespace CrystalReportsDemo
{
    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FillReport();
        }
        private void FillReport()
        {
            List<Student> studentList = new List<Student>();
            studentList.Add(new Student("200901001", "學(xué)生一", "男", 23));
            ReportDocument supReport = new CrSupReport();
            supReport.SetDataSource(studentList);
            crvReport2.ReportSource = supReport;
            List<Subject> subjectList = new List<Subject>();
            subjectList.Add(new Subject("語文","文科",90,"評語"));
            subjectList.Add(new Subject("數(shù)學(xué)", "理科", 90, "評語"));
            subjectList.Add(new Subject("工程學(xué)", "工科", 80, "評語"));
            subjectList.Add(new Subject
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 富顺县| 玉龙| 乐昌市| 瑞安市| 乌海市| 海丰县| 临桂县| 全南县| 左云县| 靖江市| 南汇区| 吴忠市| 黎川县| 沈阳市| 景洪市| 乌拉特前旗| 团风县| 循化| 潼南县| 循化| 绍兴县| 益阳市| 紫金县| 湖州市| 和政县| 礼泉县| 天峨县| 奈曼旗| 隆子县| 江门市| 九龙城区| 曲靖市| 都昌县| 海南省| 义乌市| 莲花县| 宁晋县| 静海县| 格尔木市| 丹巴县| 庆云县|