学习008-02-05-05 Create and Preview a Report(创建和预览报告)

Create and Preview a Report(创建和预览报告)

This lesson explains how to create reports in the integrated reporting system. This system is based on the DevExpress Reporting library.
本课介绍如何在集成报告系统中创建报告。该系统基于DevExpress报告库。

The instructions below show how to do the following:
以下说明显示了如何执行以下操作:

  • Add the Reports V2 Module to the application.(将Reports V2模块添加到应用程序。)
  • Create a report that displays a list of Employee objects with their names and email addresses.(创建一个报告,显示一个包含名称和电子邮件地址的员工对象列表。)

Add Reports V2 Module(添加 Reports V2模块)

1.Add the DevExpress.ExpressApp.ReportsV2 NuGet package to the MySolution.Module project. See the following topic for more information on how to install DevExpress NuGet packages: Choose Between Offline and Online DevExpress NuGet Feeds.
将DevExpress. ExpressApp.ReportsV2 NuGet包添加到MySolutions.Module项目。有关如何安装DevExpress NuGet包的更多信息,请参阅以下主题:在离线和在线DevExpress NuGet Feeds之间进行选择。

2.Add the DevExpress.ExpressApp.ReportsV2.Blazor NuGet package to the MySolution.Blazor.Server project and the DevExpress.ExpressApp.ReportsV2.Win NuGet package to the MySolution.Win project.
将DevExpress. ExpressApp.ReportsV2.Blazor NuGet包添加到MySolutions.Blazor.Server项目,将DevExpress.ExpressApp.ReportsV2.WinNuGet包添加到MySolution.Win项目。

3.Go to the MySolution.Module\MySolutionDbContext file and add a DbSet of ReportDataV2 type:
转到MySolutions. Module\MySolutionDbContext文件并添加ReportDataV2类型的DbSet:

C#

public class MySolutionEFCoreDbContext : DbContext {
    //...
    public DbSet<ReportDataV2> ReportData { get; set; }
}

4.Add a migration and update the database. See the following section for details: Use a DBMS: Setup Migrations.
添加迁移并更新数据库。有关详细信息,请参阅以下部分:使用DBMS:设置迁移。

5.In the MySolution.Blazor.Server project, open the Startup.cs file and add the Reports V2 module to the application builder. Do the same in the Startup.cs file in the MySolution.Win folder.
在MySolutions. Blazor.Server项目中,打开Startup.cs文件并将Reports V2模块添加到应用程序构建器。在MySolution.Win文件夹中的Startup.cs文件中执行相同操作。

C# (ASP.NET Core Blazor)

public class Startup {
    // ...
    public void ConfigureServices(IServiceCollection services) {
        // ...
        services.AddXaf(Configuration, builder => {
            builder.UseApplication<MySolutionBlazorApplication>();
            builder.Modules
                // ...
                .AddFileAttachments()
                .AddReports(options =>
                {
                    options.EnableInplaceReports = true;
                    options.ReportDataType = typeof(DevExpress.Persistent.BaseImpl.EF.ReportDataV2);
                    options.ReportStoreMode = DevExpress.ExpressApp.ReportsV2.ReportStoreModes.XML;
                });
            // ...
        });
        // ...
    }
}

C# (Windows Forms)

public class ApplicationBuilder : IDesignTimeApplicationFactory {
    public static WinApplication BuildApplication(string connectionString) {
    var builder = WinApplication.CreateBuilder();
    builder.UseApplication<MySolutionWindowsFormsApplication>();
    builder.Modules
    //...
         .AddFileAttachments()
         .AddReports(options =>
         {
             options.EnableInplaceReports = true;
             options.ReportDataType = typeof(DevExpress.Persistent.BaseImpl.EF.ReportDataV2);
             options.ReportStoreMode = DevExpress.ExpressApp.ReportsV2.ReportStoreModes.XML;
         });         


    }
}

If you add the Reports V2 module when you create an XAF application, the Solution Wizard generates the code used to add the Reports V2 module automatically.
如果您在创建XAF应用程序时添加报告V2模块,解决方案向导会自动生成用于添加报告V2模块的代码。

6.Run the application. In the navigation control, expand the Reports group and select the Reports item to invoke the Report List View.
运行应用程序。在导航控件中,展开报告组并选择报告项以调用报告列表视图。

ASP.NET Core Blazor
在这里插入图片描述

Windows Forms
在这里插入图片描述

Create a Report(创建报告)

In ASP.NET Core Blazor or Windows Forms runtime, the steps to create a report are the same. This lesson demonstrates these steps in the ASP.NET Core Blazor application.
在ASP.NETCore Blazor或Windows Forms运行时中,创建报表的步骤是相同的。

1.In the Report List View, click the New button to invoke the New Report Wizard Parameters pop-up window.
在报表列表视图中,单击新建按钮以调用新建报表向导参数弹出窗口。

2.Specify Employee List as the name of the report in the application UI and select Employee in the Data Type drop-down list. Click Create. XAF uses data of this type to generate the report.
在应用程序UI中指定员工列表作为报告的名称,然后在数据类型下拉列表中选择员工。单击创建。XAF使用此类型的数据来生成报告。
在这里插入图片描述

Tip
The Data Type drop-down list only shows the entity classes with DefaultClassOptionsAttribute or VisibleInReportsAttribute.
数据类型下拉列表仅显示具有DefaultClassOptionsAttribute或VisibleInReportsAttribute的实体类。

3.In the Report Wizard, select Table Report and click Next.
在报表向导中,选择表报表并单击下一步。
在这里插入图片描述

4.Select the FirstName, LastName, and Email data fields and click Next.
选择FirstName、LastName和Email数据字段,然后单击Next。
在这里插入图片描述

XAF displays values of these fields in the report.
XAF在报表中显示这些字段的值。

5.Select the Grey report color scheme and specify Employee List as the report’s title. Click Finish.
选择灰色报表配色并将员工列表指定为报表的标题。单击完成。
在这里插入图片描述

6.XAF displays the Runtime Report Designer.
XAF显示运行时报表设计器。
在这里插入图片描述

7.Click the Preview button in the upper right corner to preview the report’s print version.
单击右上角的预览按钮以预览报告的打印版本。
在这里插入图片描述

The current order of the columns in the table header is arbitrary. Let’s change it to the following:
表头中列的当前顺序是任意的。让我们将其更改为以下内容:

  • First Name
  • Last Name
  • Email

8.Click the Design button in the upper right corner to exit the preview mode. In the menu on the right, switch to the Report Explorer.
单击右上角的设计按钮退出预览模式。在右侧菜单中,切换到报表资源管理器。
在这里插入图片描述

9.Expand the Report | GroupHeader | table | tableRow1 item and rearrange its sub-items as displayed in the animation below. Do the same for the Detail | table2 | tableRow2 | item.
展开Report|GroupHeader|table|tableRow1项并重新排列其子项,如下面的动画中所示。对Detail|table2|tableRow2| item执行相同操作。

在这里插入图片描述

The GroupHeader item contains the table header cells. The Detail item contains cells with report data. You have to adjust both, so that the data matches the column header names.
GroupHeader项包含表格标题单元格。Detail项包含带有报告数据的单元格。您必须同时调整两者,以便数据与列标题名称匹配。

10.Adjust the width of the cells.
调整单元格的宽度。
在这里插入图片描述

The LastName and Email cells in the table header have no separator between them. Let’s use cell borders to separate the header cells from each other visually.
表格标题中的LastName和Email单元格之间没有分隔符。让我们使用单元格边框在视觉上将标题单元格彼此分开。

11.Select the Email cell. Click the gear icon in the menu on the right to open the cell’s properties. Navigate to the Appearance section and select the left border option.
选择电子邮件单元格。单击右侧菜单中的齿轮图标以打开单元格的属性。导航到外观部分并选择左边框选项。
在这里插入图片描述

12.Specify the same option for the LastName cell and set no borders for the FirstName cell.
为LastName单元格指定相同的选项,并为FirstName单元格不设置边框。

13.Save the report and go back to the Report List View. Click the Employee List item in the grid and see the report.
保存报告并返回报告列表视图。单击网格中的员工列表项并查看报告。
在这里插入图片描述

The created report is also available in the Windows Forms application.
创建的报告也可在Windows窗体应用程序中使用。
在这里插入图片描述

At runtime, you can use the search function, print the report, and export it in different formats such as PDF, XLS, CSV, and so on. Click the gear icon in the menu on the right to access the export settings for the available formats.
在运行时,您可以使用搜索功能,打印报告,并以不同的格式导出,如PDF、XLS、CSV等。单击右侧菜单中的齿轮图标,访问可用格式的导出设置。

Note
You can create predefined reports at design time. For additional information, see the following article: Create Predefined Static Reports.
您可以在设计时创建预定义的报告。有关其他信息,请参阅以下文章:创建预定义的静态报告。
You can sort and filter the report data based on the parameter that the end user defines.
您可以根据最终用户定义的参数对报表数据进行排序和过滤。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤姆•猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值