• 在报表控件 FastReport .NET 中使用 PageCreate 事件


    FastReport Business Graphics .NET,是一款基于fastreport报表开发控件的商业图形库,借助 FastReport 商业图形库,您可以可视化不同的分层数据,构建业务图表以进行进一步分析和决策。利用数据呈现领域专家针对 .NET 7、.NET Core、Blazor、ASP.NET、MVC、Windows Forms 和 Mono 提供的完整的产品

    FastReport .NET 是适用于.NET Core 3,ASP.NET,MVC和Windows窗体的全功能报告库。使用FastReport .NET,您可以创建独立于应用程序的.NET报告。

        FastReport .net下载(qun:278631305)icon-default.png?t=N7T8https://www.evget.com/product/1861/download

    新事件 PageCreate 在 FastReport .NET 引擎中创建新页面时发生。在此阶段,您可以更改页面的属性。 StartPage、FinishPage 和 ManualBuild 等其他事件在构建页面模板开始/结束之前触发。

    例如,您可以在横向和纵向页面方向之间交替。或者,借助此事件,您可以创建一个单独的数据源,其中包含有关 ExportAlias 或其他页面属性的信息。在事件执行过程中,您可以设置参数,并在下一页的开头迭代数据源。

    以下示例描述了使用 PageCreate 事件定义 ExportAlias 的修改后的演示报告。

    
    
    
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Drawing;
    using System.Data;
    using FastReport;
    using FastReport.Data;
    using FastReport.Dialog;
    using FastReport.Barcode;
    using FastReport.Table;
    using FastReport.Utils;
    
    namespace FastReport
    {
    public class ReportScript
    {
    private void Page1_CreatePage(object sender, EventArgs e)
    {
    if(Data1.DataSource.RowCount == 0)
    Data1.InitDataSource();
    Page1.ExportAlias = Data1.DataSource["ProductName"].ToString().Substring(0,1);
    }
    }
    }