欢迎光临
我们一直在努力

03.02.05.04 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 添加报告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 包添加到 MySolution.Module 项目中。有关如何安装 DevExpress NuGet 包的更多信息,请参阅以下主题:在离线和在线 DevExpress NuGet 源之间进行选择。

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 包添加到 MySolution.Blazor.Server 项目中,并将 DevExpress.ExpressApp.ReportsV2.Win NuGet 包添加到 MySolution.Win 项目中。

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

C#
public class MySolutionEFCoreDbContext : DbContext {
//…
public DbSet ReportData { get; set; }
}

4.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. 在 MySolution.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();
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();
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 Template Kit generates the code used to add the Reports V2 module automatically. 如果在创建 XAF 应用程序时添加 Reports V2 模块,模板工具包会自动生成用于添加 Reports V2 模块的代码。

5.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.NET Core Blazor或Windows Forms运行时中,创建报表的步骤是相同的。本课程将在ASP.NET Core Blazor应用程序中演示这些步骤。

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. 在应用程序用户界面中将报表名称指定为员工列表,并在数据类型下拉列表中选择员工。点击创建。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. 选择 名字、姓氏 和 电子邮件 数据字段,然后点击 下一步。 在这里插入图片描述

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. 展开 报表 | 组头 | 表格 | 表格行1 项,并按照下方动画所示重新排列其子项。对 明细 | 表格2 | 表格行2 | 项执行相同操作。 在这里插入图片描述

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. 表格标题中的姓氏和邮箱单元格之间没有分隔符。我们可以用单元格边框在视觉上分隔标题单元格。

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. 选中 Email 单元格。点击右侧菜单中的齿轮图标以打开单元格属性。导航至 外观 部分,选择左侧边框选项。 在这里插入图片描述

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. 您可以根据最终用户定义的参数对报告数据进行排序和筛选。
赞(0)
未经允许不得转载:171主机测评 » 03.02.05.04 Create and Preview a Report 创建并预览报告
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址