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

本文介绍如何利用Stimulsoft Reports Silverlight的BusinessObjects集合来创建和预览报表。通过示例代码展示了如何加载报表模板,注册业务对象,并呈现数据。BusinessObjects允许以不同结构展示数据,如表、列表和数组。

下载Stimulsoft Reports Silverlight最新版本

此示例显示如何使用Business Objects集合创建报表。Business Objects是一个对象类数据,使用它可以以不同的结构呈现数据:表,列表,数组等。要使用Bisiness对象,您可以使用报表对象的RegBusinessObject()方法:

private void btDesign_Click(object sender, RoutedEventArgs e)
{
    var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(
        "UsingBusinessObjects.SimpleList.mrt");
 
    StiReport report = new StiReport();
    report.Load(stream);
 
    stream.Close();
    stream.Dispose();
    stream = null;
    report.CalculationMode = StiCalculationMode.Interpretation;
    report.RegBusinessObject("Data", "Data", new Data());
 
    report.Design();
}
 
private void btPreview_Click(object sender, RoutedEventArgs e)
{
    var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(
        "UsingBusinessObjects.SimpleList.mrt");
 
    StiReport report = new StiReport();
    report.Load(stream);
 
    stream.Close();
    stream.Dispose();
    stream = null;
 
    report.CalculationMode = StiCalculationMode.Interpretation;
    report.RegBusinessObject("Data", "Data", new Data());
    report.Render();
 
    report.Show();
}

Data()对象包含报表所需的数据结构和数据行:

public class Data
{
    private List<CategoriesItem> categoriesItems = new List<CategoriesItem>();
    public List<CategoriesItem> Categories
    {
        get
        {
            return categoriesItems;
        }
        set
        {
            categoriesItems = value;
        }
    }
 
    public class CategoriesItem
    {
        private List<ProductsItem> products;
        public List<ProductsItem> Products
        {
            get
            {
                return products;
            }
            set
            {
                products = value;
            }
        }
 
        private System.Int32? categoryID;
        public System.Int32? CategoryID
        {
            get
            {
                return categoryID;
            }
            set
            {
                categoryID = value;
            }
        }
 
...

下面的屏幕截图中,您可以看到示例代码的结果。

Stimulsoft

下载示例

GrapeCity年末福利大放送

转载于:https://my.oschina.net/u/3905944/blog/2986097

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值