I. Overview
When exporting the report, if the export type is Word export and there are header and footer settings in the report, you need to export the header and footer to Word at the same time.
II. Example
1. Template settings
Create a new template, and the report style is as shown in the figure below :
2. Header and Footer Settings
Set the header for this template: FineReport, which is displayed in the center, as shown in the figure below. For the detailed setting process, please refer to Header and Footer.
Note: The header and footer support a mix of multiple elements, such as strings, pictures, line breaks, etc., are all placed in the header and footer.
3. Save and Preview
The renderings are as follows:
4. Export Word from B/S side
Click Export>Word in the toolbar on the Web side. After the output is successful, open Word, and you will see that the exported Word contains a header, as shown in the figure below:
III. Matters needing attention
1. More blank lines after Word export
1) Problem Description
The template has a header and footer. The exported Word has one more blank line on each page except for the first page, as shown in the following figure:
2) Cause analysis
The default distance of the header in Word is 12.7 mm from the top, which corresponds to the margin of FineReport.
The height logic of the page margins and headers is different between the two. After exporting Word, the report content may be squeezed down by the header and cause the display to move down or disconnect.
3) Solution
Click the menu bar Template>Page Setup>Page, set the top margin to 12.7mm, as shown in the figure below:
At this time, when previewing and exporting Word, the top distance of the header is the same, so the export result is consistent with the preview result.
2. Blank pages appear after Word is exported
1) Problem description
After the page margin is adjusted to 12.7mm, there are still blank pages in the exported Word.
2) Cause analysis
Generally, the page is stretched due to the addition of pictures in the header and footer.
3) Solution
When adding headers and footers, choose to add Background > Image instead of adding Image directly. As shown below: