在 ActiveReports 中嵌入 Spread 控件

Spread 是一款很出色的表格控件,Spread 可以使开发人员把具有兼容 Microsoft Excel 的电子表格添加到程序中。ActiveReports 提供了一个非常灵活的、简单的报表环境。下面将展示怎样在 ActiveReports 中使用 Spread for WinForm。和其他三方控件一样,Spread 控件也可以在 ActiveReports 中当作自定义控件使用,只是拖拖拽拽这么简单。但是怎样在 ActiveReports 中使用 Spread 全部的对象模型(例如方法、属性等)?不幸的是,因为 ActiveReports 仍然把 Spread 当作自定义控件,这样在设计时的 Spread 设计时功能的使用会受到很多限制(类似于标准控件)。那么该怎样解决这个问题呢?

下面我们就进行一个快速展示:
一、    为了给大家一个直观的影响,我们先给出应用到的控件截图:
1.        Spread,ActiveReports 中使用 Spread for WinForm 截图展示。
attachment.aspx?attachmentid=1824

2.        NewActiveReport,我们就是在它上面添加 Spread 控件。
attachment.aspx?attachmentid=1825

 

3.        Viewer,我们会在 viewer 上面调用我们的 NewActiveReport。
attachment.aspx?attachmentid=1826

 

二、 有了上面的零部件,下面我们就开始组装了~
1.        为了美观,我们对NewActiveReport做了一些加工,这里不详细介绍。从工具箱中拖拽 Spread 到 NewActiveReport实例中,Spread 对象会作为一个自定义控件添加到报表中,ActiveReports 把 Spread 当作自定义控件,所以目前 Spread 为灰色。(红色矩形内部即为 Spread )
attachment.aspx?attachmentid=1827

 

 

2.在报表的开始实践中转化自定义控件为 Spread 对象,代码如下:

fpSpread1=(FarPoint.Win.FpSpread)customControl.Control;

 

3.在报表开始事件 或 Spread 控件添加的区域的格式化事件中访问 Spread 对象的属性。你可以添加、删除、定制表单,单元格,行,甚至给 Spread 绑定数据源。

fpSpread1 = (FarPoint.Win.Spread.FpSpread)customControl1.Control;

            FarPoint.Win.Spread.SheetView newsheet = new FarPoint.Win.Spread.SheetView();

            newsheet.SheetName = "Active Reports";

            newsheet.ColumnCount =4;

            newsheet.RowCount = 5;

          fpSpread1.Sheets.Add(newsheet);

4.        现在创建一个 ActiveReports 实例,调用报表实例运行方法,在查看器中观察报表。

NewActiveReport1 rpt = new NewActiveReport1();

rpt.Run();

viewer1.Document = rpt.Document;

就这样,我们成功的在在 ActiveReports 中使用 Spread for WinForm,效果图:
attachment.aspx?attachmentid=1828

你也试一试吧?

Demo 下载:

FarpointSpread_ActiveReports.zip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值