• 在 ActiveReports 中嵌入 Spread 控件


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

    下面我们就进行一个快速展示:
    一、    为了给大家一个直观的影响,我们先给出应用到的控件截图:

    1.        Spread,ActiveReports 中使用 Spread for WinForm 截图展示。

    2. NewActiveReport,我们就是在它上面添加 Spread 控件。

    3. Viewer,我们会在 viewer 上面调用我们的 NewActiveReport。

    二、 有了上面的零部件,下面我们就开始组装了~

    1. 为了美观,我们对NewActiveReport做了一些加工,这里不详细介绍。从工具箱中拖拽 Spread 到 NewActiveReport实例中,Spread 对象会作为一个自定义控件添加到报表中,ActiveReports 把 Spread 当作自定义控件,所以目前 Spread 为灰色。(红色矩形内部即为 Spread )

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

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

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

    1 fpSpread1 = (FarPoint.Win.Spread.FpSpread)customControl1.Control;
    2 FarPoint.Win.Spread.SheetView newsheet = new FarPoint.Win.Spread.SheetView();
    3 newsheet.SheetName = "Active Reports";
    4 newsheet.ColumnCount =4;
    5 newsheet.RowCount = 5;
    6 fpSpread1.Sheets.Add(newsheet);


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

    1 NewActiveReport1 rpt = new NewActiveReport1();
    2 rpt.Run();
    3 viewer1.Document = rpt.Document;


    就这样,我们成功的在在 ActiveReports 中使用 Spread for WinForm,效果图: 

    你也试一试吧?

    Demo 下载:

    FarpointSpread_ActiveReports.zip



    本文是由葡萄城技术开发团队发布,转载请注明出处:葡萄城官网


  • 相关阅读:
    学习笔记—Node之读取流的使用与实现
    macbook双系统用U盘离线安装 win10
    CF1634E Fair Share
    CF1632E Distance Tree
    CF1630D Flipping Range
    K8S部署之VMWare网络拓扑踩坑
    ArrayList中的遍历删除
    postgresql提权
    Sqlite数据库的Update知多少?
    C#屏蔽系统热键Ctrl+Alt+Delete的代码尝试。(已修改bug)
  • 原文地址:https://www.cnblogs.com/powertoolsteam/p/2320562.html
Copyright © 2020-2023  润新知