Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
With Word layouts, you use Word as the editor for the report. Microsoft Word offers various features to help you format and layout your document reports. You can customize the margins, page orientation, and line spacing to suit your needs. You can define advanced header/footers, utilize sections to change the layout style in different places of the report layout, and utilize fonts to get just the typography that matches your organization.
In the Word report layout, you specify the fields of the report dataset to include on report and how the fields are arranged. You also define the general format of the report, such as text font and size, margins, and background images. You typically arrange the content of the report by adding tables to the layout. To make general formatting and layout changes, such as changing text font, adding and modifying a table, or removing a data field, use the basic editing features of Word, like you do with any Word document.
With the following sections, you can learn more about various concepts that you might want to use in your Word layouts:
- Headers and footers
- Using tables to control alignment of text and images
- Working with pictures
- Using tables to display data from the report dataset (simple repeaters)
- Using lists to display data from the report dataset (simple repeaters)
- Using nested repeaters to display data from nested dataitems in the report dataset
- Sub totals / running totals
- Conditional formatting
- Using the same table style for all tables in the layout
- Using hyperlinks
- Using sections
- Changing layout properties such as margins or orientation
- Using watermarks
- Using fonts
- Using Office document themes
Learn more about how to use Word to lay out documents at Word for Windows training.
Headers and footers in Word layouts
It's common to use headers and/or footers in Word layouts to display general information about the report, such as company logo, or company name and address. To define headers and/or footers, go to Insert > Header or Footer. You can have a different header/footer on the first page of your layout than the rest of the page or section. When working with different headers/footers for the first page, consider entering a manual page break (Ctrl+Enter) when designing them. This practice makes it easier to see the difference in headers/footers. Just remember to remove the page break again.
Learn more at Headers and footers in Word (use Ctrl+click to open in a new tab)
Tip
It's possible to control the headers and footers for different sections of a document. The formatting you set up extends to each page of the section until another section break is encountered. Learn more at Configure headers and footers for different sections of a document (use Ctrl+click to open in a new tab)
Using tables to control alignment of text and images
When designing a Word report layout, consider using tables to control alignment of text and images, also for content outside repeaters.
Using tables, you can design layouts with lines that have text aligned to both the left, middle, and right in the line. You can also control exactly where on the page text elements are placed.
Tip
Show the table gridlines so that you see the boundaries of table cells. Remember to hide the gridlines when you're done editing. To show or hide table gridlines, select the table, and then under Layout on the Table tab, choose View Gridlines.
Working with pictures in Word Layouts
There are at least two things you should consider when adding pictures to your Word layout:
- Control how they fit into the layout (don't overflow).
- Reduce report file size by compressing the pictures.
Control how pictures fit into the layouts
When inserting a picture, ensure that it doesn't take up space according to its size, instead adjust it to the size that you want it in your layout. The best way to do this is to encapsulate the picture in a cell in a table, maybe in a 1x1 table introduced only for this purpose. When you change the size of a table cell for a picture, by default it still adjusts to fit the picture. Therefore, you must also disable the cell's ability to change its size dynamically.
To control the picture size using a table, do as follows:
- Mark the cell.
- Under Layout, Set Height and Width in the Cell size menu.
- In the Table menu, select Properties. On the Table tab, select Positioning and then uncheck the Automatically resize to fit contents option.
Controlling how pictures fit into the layouts is important both for static files in the layout and for pictures inserted from the report dataset.
Reducing file size by compressing pictures
When adding pictures directly to your layout file, such as background images or logos, consider reducing the file size by compressing picture sizes. With compression options in Word, you can reduce both the file size and picture dimensions based on how you intend to use the picture. For instance, maybe the quality needed for print is different from what is needed when just viewing the document report on screen or attach to an email. You can compress all pictures in the file or just the ones that you select.
To compress pictures that are part of the layout file, do as follows:
- After inserting your pictures into Word, select the picture or pictures that you want to compress.
- Under Picture Tools, on the Format tab, in the Adjust group, select Compress picture. Then choose what and how you want to compress and select OK.
Learn more at Reduce the file size of a picture in Microsoft Office
For pictures that are part of the report dataset, you need to adjust the size in Business Central. You can use the codeunit 5080 "Image Handler Management" to scale images in AL (from version 24.1 also available in Business Central online). Learn more at Codeunit "Image Handler Management".
Using tables to display data from the report dataset (simple repeaters)
If you want to add a table to the report layout where data in each row comes from a dataitem from the report dataset, do as follows:
Create a table with two rows and a column for each field that you want displayed.
In the first row, add text for the headers, either as static text or from the
Labelspart of the XML Mapping pane. This row is the header for the table.The second row is the placeholder for the repeating rows with data fields. Select the entire row.
In the XML Mapping pane, right-click the control that corresponds to the report data item that contains the fields that you want repeated, choose Insert Content Control, and then choose Repeating.
Add the repeating fields to the row as follows:
- Place your pointer in a cell.
- In the XML Mapping pane, right-click the field that you want to add, choose Insert Content Control, and then choose Plain Text.
- For each field, repeat steps a and b.
Learn more at Supporting repeating content.
Tip
When you work with a long table, it runs across multiple pages. It's possible to set up the table so that the table header row appears on each page automatically. To achieve this, do as follows:
- Select the header row or rows that you want to repeat on each page. The selection must include the first row of the table.
- Under Table Tools, on the Layout tab, in the Data group, choose Repeat Header Rows.
Learn more at Repeat table header on subsequent pages.
Using lists to display data from the report dataset (simple repeaters)
If you want to add a bulleted or numbered list to the report layout where data in each row comes from a dataitem from the report dataset, do as follows:
Place the cursor on the place where you want the list to be displayed.
In the XML Mapping pane, right-click the control that corresponds to the report data item that contains the fields that you want repeated, choose Insert Content Control, and then choose Repeating.
Inside the content control of the repeater, start the bulleted or numbered list (from Home > Paragraph). This adds a single entry in the list.
Now add the repeating fields to the list entry as follows:
- Place your pointer on the list line.
- In the XML Mapping pane, right-click the control that you want to add, choose Insert Content Control, and then choose Plain Text.
- For each field, repeat steps a and b.
Learn more at Supporting repeating content.
Using nested repeaters to display data from nested dataitems in the report dataset
Word supports placing tables within table cells or having multi-level lists. And you can also add a repeater within a repeater. This means that you can have as many levels as needed in your layout, as long as they fit on the page.
Sub totals/running totals
Word doesn't have a programming model such as RDL and hence it isn't possible to do sub totals/running totals in the Word layout itself.
Instead, you can do the work in the dataset by defining a dataitem that calculates subtotals per partition and then a nested dataitem with the partitioned data. In the layout, you then add a table that repeats over the top level dataitem and use a nested repeater on the partitioned dataitem.
Conditional formatting
Word doesn't have a programming model such as RDL and hence it isn't possible to do conditional formatting directly in the Word layout itself.
But there are ways to work around this limitation by calculating the conditions in AL and adding them to the dataset. In the Word layout, you then utilize the fact that Word don't render XML elements without a value. in the following, you can learn more about different ways to do conditional formatting.
How to hide/show values based on a condition
If you want to hide/show a single value based on a condition, then make sure that the column in the dataset is set to empty or to a value based on the condition.
In the Word layout, you now just use the column as-is.
How to control text properties based on a condition
If you want to show a text and control text properties such as color, font, style, or size based on a condition, add the column twice in the dataset. Set values to empty or to the value based on the condition. Make sure that one of them is empty.
In the Word layout, you now place both columns next to each other, and then set the text properties on each to what you need.
How to mimic the BlankZero or BlankNumbers properties
If you want to mimic the BlankZero or BlankNumbers properties that exist on table and page fields, then set values to empty or to the value based on the condition (zero or the value you would used for BlankNumbers) in the dataset.
In the Word layout, you now just use the column as-is.
How to hide a part of the document based on a condition
If you want to hide a part of the document, such as a table or a list, based on a condition, then create a dummy dataitem with an Integer datasource, which contains a column set to empty or to a value based on the condition. Then place the dummy dataitem on top of the dataitem that your table/list repeats over.
In the Word layout, you now use nested repeaters, where the outer repeater is on the dummy dataitem.
Using the same table style for all tables in the layout
If your document layout contains multiple tables, consider using table styles to ensure that the formatting of your tables is consistent. In case you need to later on apply changes to table layouts, styles save you time because changes only need to be done once.
To set a default table style, do as follows:
- Mark the table.
- Navigate to the Table Design menu.
- For the table style you want to use as default, right-click it.
- In the menu that appears, select Set as Default. A dialog box appears.
- Select This document only, and then choose OK.
Using hyperlinks in Word layouts
In a Word report layout, you can set up hyperlinks on text and picture fields, for example to add a link on invoice reports that targets the URL of a payment service. This link is then present when rendering the report as a Word or PDF document.
Learn more in Using hyperlinks in Word layouts.
Using sections in a Word layout
If you need your report to change style for different types of content, consider using different Sections in your Word layout. Within each section, you can have different formatting, such as page or table layouts, paper orientation, watermarks, and headers/footers.
Note
Before Business Central 2024 release wave 2, you couldn't include Word sections in report layouts that used the WordMergeDataItem property. This restriction is removed starting from 2024 release wave 2. Learn more in How to iterate a Word layout over a data item.
Sections are created using section breaks. To start a new section, select where you want it to begin. Then go to Layout > Breaks. Learn more in Insert a section break (use Ctrl+click to open in a new tab).
Tip
When working with sections in a layout, the recommendation is to turn the display of formatting marks on. This makes it much easier to see in which section of the layout you're working. Learn more in Show or hide tab marks in Word (use Ctrl+click to open in a new tab).
Changing layout properties such as margins or orientation
If you need to change layout properties such as margins, orientation (portrait or landscape), or columns inside your Word layout, then use sections. Your choice of these properties is in scope until the next section break, where they can be overridden.
Learn more at Change page orientation to landscape or portrait.
Using watermarks in Word layouts
A watermark is text or a picture that sits behind your text and pictures, faint or washed-out so that it doesn't interfere with what's on the page. Like headers and footers, a watermark usually appears on all the pages of your document. You define and manage the watermark from the Design tab, select Watermark.
Learn more at Watermarks in Word (use Ctrl+click to open in a new tab).
Using different watermarks in sections
The internal data model in Word only allows one watermark for the entire document. If you try to insert a second watermark, whether in a first page, other pages, or sections, Word deletes or replaces the previous watermark.
In case you want to apply different watermarks to different sections, this work-around might work:
- On the Home tab, select Select > Selection Pane. The Selection pane is used to manage objects in your document: reorder them, show or hide them, and group or ungroup them.
- Within the first section, open the header or footer and insert the watermark you want to use. Just use the normal approach. In the Selection pane, the watermark now shows as "PowerPlusWaterMarkObject" for a text object or "WordPictureWaterMark" for a picture object (each name followed by an identifier). Double-click on the name to make it editable and change it to something else (maybe to the watermark text, such as 'Customer copy' or 'Original'). Now Word doesn't treat the object as a (global) watermark.
- Within each subsequent section, repeat step number 2.
- On the Home tab, choose Select > Selection Pane to turn off the Selection pane again.
Using fonts in Word layouts
The online version of Business Central contains preinstalled fonts on the servers that can be used when generating reports. You can use any of these fonts in your layout.
For more information, see Available fonts in Business Central online.
Fonts don't have to be installed on your machine when working with the layout. You can just mark content and type in the name of the font you want to use. When the report is generated on the server, if the font is installed on the server, then it's used in the rendered report document. If the font isn't available on the server or embedded in the layout, then the report still renders, but the font defined in the Normal style is used.
In case your favorite (true-type) font isn't installed on the Business Central server, then you can embed it in the layout. Learn more at Embedding custom fonts.
Note
Embedding fonts increases the size of the generated documents.
Using Office document themes in Word layouts
Office document themes make it easy to coordinate colors, fonts, and graphic formatting effects across your Word and Excel layouts and quickly update them.
For more information, see Change a theme and make it the default in Word or Excel.
To apply a theme to your Word layout, use the standard styles for text and headers. Then the colors and fonts follow the chosen theme.
For tables, for the table header be respect theme changes, you need to do this:
- Mark the header row.
- In the Table Design menu, expand the Shading menu in Table Styles.
- Now pick a theme color.
If you use the prebuilt Table Styles, you must manually change the color in the Shading menu for the header color to respect theme changes.
To learn more about templates, themes, and Word styles, go to Differences between templates, themes, and Word styles.
Design layouts for precision printing
If you need to design Word layouts where placement of design components on the page needs to be precise, then you can set their absolute position, both horizontal and vertical. It's possible to set precision to two decimals of cm/inch.
For tables, you can control their absolute position on the page in Table Properties. In the Tables tab, choose Around for the text wrapping. Now the Positioning button is unlocked, and you can set the horizontal and vertical position of the table. Learn more at Set or change table properties.
For text boxes, you can control their absolute position on the page in the Shape format menu: Position > More Layout Options (you can also navigate here by right-clicking on the text box). Now you can set the horizontal and vertical position of the text box. Learn more at Ways to customize a text box.
Tip
When designing layouts for precision printing, consider enabling the ruler and gridlines (find them under View > Show). Learn more at Show the ruler.
Related information
Using hyperlinks in Word layouts
WordMergeDataItem property
Report design overview
Report object
Report extension object
Developing a custom report render
Creating an RDL layout report
Creating an Excel layout report