彩票走势图

【Stimulsoft Reports.WinForms教程】在报表中使用Business Objects

翻译|使用教程|编辑:王香|2018-08-31 11:17:06.000|阅读 341 次

概述:本文主要讲解在Stimulsoft中使用Business Objects。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

【下载Stimulsoft Reports.Ultimate最新版本】

此示例显示如何使用Business Objects集合创建报表。Business Objects:一个对象类数据,使用它可以以不同的结构呈现数据:表,列表,数组等。此示例使用Business Objects的两个变体:IEnumerable和ITypedList:

private void btPreviewIEnumerable_Click(object sender, System.EventArgs e)
{
    StiReport report = new StiReport();
    report.RegData("EmployeeIEnumerable", CreateBusinessObjectsIEnumerable.GetEmployees());
    report.Load("..\\BusinessObjects_IEnumerable.mrt");
    report.Show();
}
 
private void btPreviewITypedList_Click(object sender, System.EventArgs e)
{
    StiReport report = new StiReport();
    report.RegData("EmployeeITypedList", CreateBusinessObjectsITypedList.GetEmployees());
    report.Load("..\\BusinessObjects_ITypedList.mrt");
    report.Show();
}

作为IEnumerable对象使用EmployeeIEnumerable模型,为了填充数据,使用CreateBusinessObjectsIEnumerable类的GetEmployees()方法:

public static EmployeeIEnumerableCollection GetEmployees()
{
    EmployeeIEnumerableCollection employees = new EmployeeIEnumerableCollection();
    Company company = new Company("Company1");
    Department storeDepartment = new Department(company, "Store Department");
    Department salesDepartment = new Department(company, "Sales Department");
 
    EmployeeIEnumerable emp = new EmployeeIEnumerable(storeDepartment, "Nicholas", "Nicholas@company1.com");
    emp.Phones.Add(new Phone("(206) 555-9857"));
    emp.Phones.Add(new Phone("(206) 555-6546"));
    emp.Phones.Add(new Phone("(206) 555-7651"));
    employees.Add(emp);
 
    emp = new EmployeeIEnumerable(storeDepartment, "Margaret", "Margaret@company1.com");
    emp.Phones.Add(new Phone("(206) 555-4546"));
    emp.Phones.Add(new Phone("(206) 555-0110"));
    employees.Add(emp);
 
    emp = new EmployeeIEnumerable(storeDepartment, "Janet", "Janet@company1.com");
    emp.Phones.Add(new Phone("(206) 555-5462"));
    emp.Phones.Add(new Phone("(206) 555-8400"));
    emp.Phones.Add(new Phone("(206) 555-9842"));
    employees.Add(emp);
 
    emp = new EmployeeIEnumerable(salesDepartment, "Laura", "Laura@company1.com");
    emp.Phones.Add(new Phone("(206) 555-0022"));
    employees.Add(emp);
 
    emp = new EmployeeIEnumerable(salesDepartment, "Mark", "Mark@company1.com");
    emp.Phones.Add(new Phone("(206) 555-9980"));
    emp.Phones.Add(new Phone("(206) 555-5567"));
    employees.Add(emp);
 
    emp = new EmployeeIEnumerable(salesDepartment, "Michael", "Michael@company1.com");
    emp.Phones.Add(new Phone("(206) 555-5642"));
    employees.Add(emp);
 
    emp = new EmployeeIEnumerable(salesDepartment, "Thomas", "Thomas@company1.com");
    emp.Phones.Add(new Phone("(206) 555-8949"));
    employees.Add(emp);
 
    return employees;
}

作为ITypedList对象使用EmployeeITypedList模型,为了填充数据,使用CreateBusinessObjectsITypedList类的GetEmployees()方法:

public static EmployeeITypedListCollection GetEmployees()
{
    EmployeeITypedListCollection employees = new EmployeeITypedListCollection();
    Company company = new Company("Company1");
    Department storeDepartment = new Department(company, "Store Department");
    Department salesDepartment = new Department(company, "Sales Department");
 
    EmployeeITypedList emp = new EmployeeITypedList(storeDepartment, "Nicholas", "Nicholas@company1.com");
    emp.Phones.Add(new Phone("(206) 555-9857"));
    emp.Phones.Add(new Phone("(206) 555-6546"));
    emp.Phones.Add(new Phone("(206) 555-7651"));
    employees.Add(emp);
 
    emp = new EmployeeITypedList(storeDepartment, "Margaret", "Margaret@company1.com");
    emp.Phones.Add(new Phone("(206) 555-4546"));
    emp.Phones.Add(new Phone("(206) 555-0110"));
    employees.Add(emp);
 
    emp = new EmployeeITypedList(storeDepartment, "Janet", "Janet@company1.com");
    emp.Phones.Add(new Phone("(206) 555-5462"));
    emp.Phones.Add(new Phone("(206) 555-8400"));
    emp.Phones.Add(new Phone("(206) 555-9842"));
    employees.Add(emp);
 
    emp = new EmployeeITypedList(salesDepartment, "Laura", "Laura@company1.com");
    emp.Phones.Add(new Phone("(206) 555-0022"));
    employees.Add(emp);
 
    emp = new EmployeeITypedList(salesDepartment, "Mark", "Mark@company1.com");
    emp.Phones.Add(new Phone("(206) 555-9980"));
    emp.Phones.Add(new Phone("(206) 555-5567"));
    employees.Add(emp);
 
    emp = new EmployeeITypedList(salesDepartment, "Michael", "Michael@company1.com");
    emp.Phones.Add(new Phone("(206) 555-5642"));
    employees.Add(emp);
 
    emp = new EmployeeITypedList(salesDepartment, "Thomas", "Thomas@company1.com");
    emp.Phones.Add(new Phone("(206) 555-8949"));
    employees.Add(emp);
 
    return employees;
}

示例代码的结果如下图所示:

Stimulsoft


标签:报表报表控件StimulsoftWinForms

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@capbkgr.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP