Ms Access 简明教程

MS Access - Formatting Reports

在本章中,我们将学习如何格式化报表。你会发现格式化报表与格式化表单有很多相似之处,但有一些工具和技巧是专门针对报表的。现在让我们了解报告部分和分组的概念。

In this chapter, we will learn how to format reports. You will find that there are a lot of similarities between formatting reports and formatting forms but there are a few tools and tricks that are specific to reports. Let us now look into the concept of report sections and grouping.

为此,我们需要打开我们在上一章中创建的一个报告。在这里,我们将看到其中一些信息如何在报告中显示。

For this, we need to open a report that we created in the last chapter. Here, we will see how some of this information is displayed on the report.

displayed information

在这里,我们将从报告部分和分组开始。

Here, we will start with the report section and grouping.

现在让我们转到此报告的设计视图。

Let us now go to the Design view of this report.

report section

你可以看到这里没有很多内容,这里只有页眉、详细信息部分和页脚可见。你可以非常容易地添加其他几个部分。

You can see that there’s not a lot to look and here only page header, details section, and page footer are visible. You can add an additional couple of sections very easily.

additional section

在此报告上的任意位置单击鼠标右键,你将看到页眉/页脚和报告页眉/页脚。此报告没有显示该报告页眉/页脚。让我们选择该选项并返回报告视图。

Right click anywhere on that report and you will see Page Header/Footer and Report Header/Footer. This particular report does not have that Report Header/Footer visible. Let us select that option and go back to the Report View.

report header

可以看到,它只在报告的顶部添加了一个小彩色区域。在设计视图中,将鼠标悬停在该页眉分隔符正上方、单击并向下拖动以展开该区域。这将为报告页眉添加更多区域。

You can see it just adds a little colored area at the very top of the report. In the Design View, expand that area by hovering the mouse right at the top of that page header divider, clicking and dragging down. This will add more area to the report header.

report design view

在报告视图中,现在你将在报告的顶部看到更多区域,如下面的屏幕截图所示。

In the Report View, you will now see more area at the very top of the report as in the following screenshot.

more area

报告页眉和页脚控件显示在该报告第一页的顶部。报告页脚控件控制你在报告底部最后一页上看到的内容。

The Report Header and Footer controls appear at the top of the first page of that report. The report footer controls what you see at the very last page at the bottom of the report.

footer control

报告页眉和页脚与你的页眉和页脚不同。放在页眉中的任何内容都会显示在每一页的顶部。同样,放在页脚中的任何内容都会在每页底部重复。

The Report Header and Footer is different from your Page Header and Page Footer. Anything that is placed in the Page Header will appear at the top of every page. Likewise, anything that is placed in the Page Footer will repeat at the bottom of every page.

bottom report

现在你可以添加其他分组级别,要做到这一点,你要确保打开了组排序和总计区域。

Now you can add additional grouping levels, and to do that, you want to make sure you have the group sort and total area turned on.

在设计选项卡的分组和总计部分中,单击组和排序按钮,这将在底部打开组、排序和总计区域,如下面的屏幕截图所示。

In the Grouping and Totals section of the Design tab, click on the Group and Sort button which will open Group, Sort, and Total area at the bottom as shown in the following screenshot.

repeat footer

你现在可以在报告中的任何控件上添加其他组或分组。现在让我们单击添加组。

You can now add additional groups or grouping on any control that you have in your report. Let us now click on Add a Group.

additional group

在上图中,你可以看到报告的基本控件来源,包括项目名称、任务标题、到期日期和完成百分比。现在假设我们想要按项目将所有逾期任务分组,因此从列表中选择项目名称。

In the above screenshot, you can see the underlying control source for report with the project name, task title, due date and percent complete. Let us now say we want to group all of our late tasks by project, so select Project Name from the list.

task by project

现在,你将在详细信息部分上方看到一个额外的分组级别 ProjectName Header 。我们现在可以将此控件上移到此项目名称标题,而不是让项目名称显示在每个逾期任务旁边。你可以选择它,然后按键盘上的 Ctrl + X 将其从详细信息部分中剪切下来,然后单击该项目名称标题背景中的任意位置,然后按 Ctrl + V 将该控件粘贴到该项目名称标题中。

Now you will see an additional grouping level ProjectName Header above your details section. Instead of the project name appearing alongside each individual task that is late, we can now move this control up to this project name header. You can select it, and then press Ctrl + X on your keyboard to cut that from that details section and click anywhere in the background of that project name header, and then press Ctrl + V to paste that control in that project name header.

name header

现在,你可以转到报告视图,查看对报告中事务进行分组所做的调整,如下面的屏幕截图所示。

You can now go to the Report View and see the adjustments made to group the things in the report as in the following screenshot.

adjustments

每个项目在自己的线上都有自己的小级别,然后在这个区域下方,您将看到所有该项目已逾期的任务。现在,稍做更改之后,您可以在布局视图中开始设置报告格式。

Every single project has its own little level on its own line, and then underneath that area you will see all of the tasks that are late for the above project. With that changed now, you can go through and start formatting your report in the Layout View.

如果您想要扩大项目名称,则拖动下面的行,然后在“格式”选项卡中将字体大小更改为 20。

If you want to make the project name bigger, then drag the line below and change the font size to 20 in the Format Tab.

project name bigger

您可以增加控件的宽度,使其覆盖整个页面宽度。

You can increase the width of the control to cover the entire width of the page.

increase width

若要移除控件周围的边框,请在“格式”选项卡中单击“形状轮廓”,如下面屏幕截图所示。

To remove the border around the control, click on the Shape Outline in the Format tab as in the following screenshot.

shape outline

选择 Transparent 选项。

Select the Transparent option.

transparent

让我们现在转到设计视图,如下面屏幕截图所示。

Let us now go to the Design View as in the following screenshot.

group sort

将任务标题调整到页面的左侧,如下面屏幕截图所示。

Adjust the task title to the left of your page as in the following screenshot.

task title design

让我们现在使用 Ctrl+XCtrl+V 将数据从“页眉”部分带到 ProjectName 标题部分。

Let us now bring the data from the Page Header section to the ProjectName header section using Ctrl+X and Ctrl+V.

add group

让我们现在返回到报告视图。您现在会看到这些标签直接显示在它们描述的控件上方。

Let us now go back to the Report View. You will now see that the labels appear directly above the controls that they describe.

appeared label

如果您注意到了,您会发现任务和下一个项目名称之间没有空格。它们之间应该有额外的空格。为此,我们需要添加 ProjectName Footer

If you notice, you will see that there is no space between the tasks and the next project name. There should be additional space in between. For that, we need to add ProjectName Footer.

现在,转到设计视图。

Now, go to the Design View.

name footer

在“分组、排序和总计”区域中,单击项目名称旁边的“更多”按钮。

In the Group, Sort and Total area click on the More button next to the project name.

您现在将看到有关如何按项目名称分组和排序的所有选项,如下面屏幕截图所示。

You will now find all the options for how to group and sort by project name as in the following screenshot.

group sort name

在此处,我们有一个名为 Without a Footer Section 的属性。让我们通过单击文字 Without a Footer Section 旁边的那个小箭头更改该选项。

Here, we have a property called Without a Footer Section. Let us change that option by clicking on that little arrow next to the words Without a Footer Section.

footer section

将其更改为 With a Footer Section

Change it to With a Footer Section.

with section

正如您在上面的屏幕截图中看到的那样,在“详细信息”部分下方的“ProjectName Footer”部分已添加。这将作为该项目名称组的页脚。

As you can see in the above screenshot that the ProjectName Footer section beneath the Details section is added. This will act as the footer for that project name group.

让我们现在返回到报告视图。

Let us now go back to the Report View.

detail section

若要移除交替区域在“详细信息”部分和“项目名称”区域中作为背景的阴影或外观,请再次转到设计视图。

To remove shading or the appearance of background for alternating areas in both the Details section and in the Project Name area, go to the Design View again.

remove shading

让我们先通过单击详细信息分隔符然后打开“属性”表来更改“详细信息”部分。

Let us change the Details section first by clicking on the detail divider and then open Properties sheet.

在“格式”选项卡上,更改 Alternate Back ColorNo Color ,如下面的屏幕截图所示。

On the Format tab, change the Alternate Back Color to No Color as in the following screenshot.

alternate color

类似地,将“备用背景颜色”更改为“无颜色”,以适用于“ProjectName Header”和“ProjectName Footer”,然后转到“报表视图”。

Similarly change the Alternate Back Color to No Color for both ProjectName Header and ProjectName Footer and go to Report View.

change alternate color

现在你可以看到报表的显示方式。要了解数据将逐页打印的方式,让我们转到“打印预览”。

You can now see how the report looks. To see how your data will print page by page, let us go to the Print Preview.

print preview

这就是打印时显示的样子。

This is how it will look like when you print it.