Redigera

Dela via


Export a paginated report to Microsoft Word (Report Builder)

Applies to:  Microsoft Report Builder (SSRS)  Power BI Report Builder  Report Designer in SQL Server Data Tools

The Word rendering extension renders paginated reports to the Microsoft Word format (.docx). The format is Office Open XML.

The content type of files generated by this renderer is application/vnd.openxmlformats-officedocument.wordprocessingml.document and the file extension is .docx.

See Export reports (Report Builder and SSRS) for details on how to export to Word.

After you export the report to a Word document, you can change the contents of your report and design document-style reports such as mailing labels, purchase orders, or form letters.

Note

You can create and modify paginated report definition (.rdl) files in Microsoft Report Builder, Power BI Report Builder, and in Report Designer in SQL Server Data Tools.

Report items in Word

Reports exported to Word appear as a nested table that represents the report body. A tablix data region is rendered as a nested table that reflects the structure of the data region in the report. Text boxes and rectangles are each rendered as a cell within the table. The text box value is displayed inside the cell.

Images, charts, data bars, sparklines, maps, indicators, and gauges are each rendered as a static image within a table cell. Hyperlinks and drillthrough links on these report items are rendered. Maps and areas that can be selected within a chart aren't supported.

Newsletter-style column reports aren't rendered in Word. Report body and page background images and colors aren't rendered.

Pagination

After the report is opened in Word, Word repaginates the entire report again based on the page size. Repagination might cause page breaks to be inserted in locations where you didn't intend to add them. In some instances, this result might cause the exported report to have two successive page breaks in a row or add blank pages. You can try to change Word's pagination by adjusting the page margins.

This renderer supports only logical page breaks.

Page size

When the report is rendered, the following RDL properties set the height and width for the Word page: paper size height and width, left and right page margins, and the top and bottom page margins.

Page width

Word supports page widths that are up to 22 inches wide. If the report is wider than 22 inches, the renderer still renders the report. However, Word doesn't display the report contents while in print layout view or reading layout view. To view the data, switch to normal view or Web layout view. In these views, Word reduces the amount of whitespace, thereby displaying more of your report contents.

When rendered, the report grows as wide as required, up to 22 inches, to display the contents. The minimum width of the report is based on the RDL Width property in the Properties pane.

Document properties

The Word renderer writes the following metadata to the DOCX file.

Report Element properties Description
Report Title (report title) Title
Report.Author Author
Report.Description Comments

Page headers and footers

Page headers and footers are rendered as header and footer regions in Word. If a report page number or an expression that indicates the total number of report pages appears in the page header or footer, the value is translated to a Word field. This action ensures that the accurate page number is displayed in the rendered report. If the header or footer height is set in the report, Word can't support this setting. The PrintOnFirstPage property can under some circumstances specify whether text in a page header page footer prints on the first page of a report. If the rendered report has multiple pages and each page contains only a single section, then you can set PrintOnFirstPage to False. The text is suppressed on the first and page. Otherwise, the text prints regardless of the value of the PrintOnFirstPage property.

The Word renderer attempts to parse all expressions in page headers and footers when reports are exported to Word. Many forms of expressions parse successfully and the expected values appear in page footers and headers on all report pages.

However, a page footer or page header might contain a complex expression that evaluates to different values on different pages of a report. If so, the same value might display on all report pages. The page numbers in the following two expressions don't increment in the exported report. The page number translates to the same value on all report pages.

  • ="Page: " + Globals!PageNumber.ToString + " of " + Globals!TotalPages.ToString

  • =Avg(Fields!YTDPurchase.Value, "Sales") & " Page Number " & Globals!PageNumber

This result occurs because Word renderer parses the report for fields related to pagination such as PageNumber and TotalPages and handles only simple reference, not calls to a function. In this case, the expression calls the ToString function. The following two expressions are equivalent and both render correctly when you preview the report in Report Builder or Report Designer or render the published report in a Reporting Services web portal or a SharePoint library. However, the Word renderer parses only the second expression successfully and renders the correct page numbers.

  • Complex expression: Expression is ="Average Sales " & Avg(Fields!YTDPurchase.Value, "Sales") & " Page Number " & Globals!PageNumber

  • Expression with Text Runs: Text, Average Sales, and expression, =Avg(Fields!YTDPurchase.Value, "Sales), and text, Page Number, and expression =Globals!PageNumber

To avoid this problem, use text runs instead of one complex expression when you use expressions in footers and headers. The following two expressions are equivalent. The first one is a complex expression the second one uses text runs. The Word renderer parses only the second expression successfully.

Document map

If any document map labels exist in the report, they're available to be used as Word Table of Contents (TOC) labels on the respective report items and groups. The document map label is used as the label text for the TOC labels. The target link is positioned near the item on which the label is set. While a TOC isn't created for you on export in the Word document, you can build your own TOC using the document map labels that are rendered in the report with the following steps.

  1. In the Word document, select the position where the TOC should go.
  2. From the ribbon, select Insert.
  3. Select the Quick Parts menu.
  4. Select Field from the menu.
  5. From Field names, select TOC, and select the Table of Contents button from the Field properties pane.
  6. In the popup window, select the Options button, and ensure the Table entry fields box is checked.
  7. Select OK from both popup windows to complete the process and generate the TOC.

For more information, see Create a document map or table of contents (Report Builder).

Interactivity

Some interactive elements are supported in Word. The following section is a description of specific behaviors.

Show and hide

The Word renderer renders report items based on their state when rendered. If a report item's state is hidden, the report item isn't rendered in the Word document. If a report item's state is shown, the report item is rendered in the Word document. Toggle functionality isn't supported in Word.

Hyperlinks and drillthrough links on text box and image report items are rendered as hyperlinks in the Word document. When you select the hyperlink, the default Web browser opens and navigates to the URL. When you select the drillthrough hyperlink, the originating report server is accessed.

Interactive sort

The report contents are rendered based on how they're currently sorted within the report data region. Word doesn't support interactive sorting. After the report is rendered, you can apply table sorting within Word.

Bookmarks

Bookmarks in the report are rendered as Word bookmarks. Bookmark links are rendered as hyperlinks that connect to the bookmark labels within the document. Bookmark labels must be fewer than 40 characters long. The only special character that can be used in a bookmark label is an underscore (_). Unsupported special characters are stripped from the bookmark label name and, if the name is longer than 40 characters, the name is truncated. If there are duplicate bookmark names in the report, the bookmarks aren't rendered in Word.

Render Word styles

The following section is a brief description of how styles are rendered in Word.

Color palette

Colors rendered in the report are rendered in the Word document.

Border

Borders for report items, other than the page border, are rendered as Word table cell borders.

Squiggly lines in exported reports

When exported and viewed in Word, report data or constants might be underlined with red or green squiggly lines. The red squiggly lines identify spelling errors. The green squiggly lines identify grammar errors. This result occurs when the report includes words that don't comply with the proofing (spelling and grammar) of the editing language that is specified in Word. For example, English report column titles are likely be underlined with red squiggly lines when the report is rendered in a Spanish version of Word. Perceived spelling errors are more common in reports than perceived grammar errors because reports typically include only short text, not complete sentences or paragraphs.

The presence of squiggly lines in reports implies the report has errors, which it likely doesn't. You can remove the squiggly lines by changing the proofing language for the report. To change the proofing language, select the content of the report and then specify the appropriate language for the content. You can select all or part of the content. In Word, the language option Set Proofing Language is in the Language area on the Review tab. After you update the content, you need to resave the document.

Depending on the language version of your Office program, the proofing tools (for example, dictionary) of the language that you chose is included with the program or provided in a Microsoft Office language pack that you purchase.

The following articles provide additional information about setting Office and Word options.

Note

When you change the editing language in Microsoft Office Language Preferences or the Word Options dialog in Word, the change applies to all Office programs.

Word limitations

Microsoft Word applies the following limitations:

  • Word tables support a maximum of 63 columns. If your report has more than 63 columns and you try to render it, Word splits the table. The other columns are placed next to the 63 columns displayed in the report body. Therefore, the report columns might not line up as expected.

  • Word supports a maximum page width of 22 inches wide and 22 inches high. If your content is wider than 22 inches, some data might not be displayed in Print Layout view.

  • Word ignores page header and footer height settings.

  • After the report is exported, Word paginates the report again. This result might cause more page breaks to be added to the rendered report.

  • Word doesn't repeat header rows on page two and greater, although you set the RepeatOnNewPage property of the static header row in a tablix (table, matrix, or list) to True. You can define explicit page breaks in your report to force header rows to appear on new pages. However, because Word applies its own pagination to the rendered report exported to Word, results might vary and the header row might not repeat predictably. The static header row is the row that contains the column headings.

  • Text boxes grow when they contain nonbreaking spaces.

  • When text is exported to Word, text with font decoration in certain fonts might generate unexpected or missing glyphs in the rendered report.

Benefits of using the Word renderer

In addition to making the features that are new in Microsoft Word .docx files available to exported reports, *.docx files of exported reports tend to be smaller. Reports exported by using the Word renderer are typically smaller than the same reports exported by using the Word 2003 renderer.

Backward compatibility of exported reports

You can select a Word compatibility mode and set compatibility options. The Word renderer creates documents with compatibility mode turned on. Resaving the documents with compatibility mode turned off might affect the layout of the document.

If you turn off compatibility mode and then resave a report, the report layout might change in unexpected ways.

The Word 2003 renderer

Important

The Microsoft Word 2003 (.doc) rendering extension is deprecated. For more information, see Deprecated features in SQL Server Reporting Services in SQL Server 2016.

The Word renderer is compatible with Microsoft Word 2003 with the Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint installed. For more information, see Microsoft Office compatibility pack for Word, Excel, and PowerPoint.

The previous version of the Word rendering extension, compatible with Microsoft Word 2003, is renamed to Word 2003. Only the Word rendering extension is available by default. You must update the Reporting Services configuration files to make the Word 2003 rendering extension available. The content type of files generated by the Word 2003 renderer is application/vnd.ms-word and the file name extension of files is .doc.

In SQL Server Reporting Services, the default Word renderer is the version that renders to the Microsoft Word format (.docx). This format is the Word option that the Export menus in a Reporting Services web portal and SharePoint list. The earlier version, compatible only with Microsoft Word 2003, is now named Word 2003 and is listed on menus using that name. The Word 2003 menu option isn't visible by default, but an administrator can make it visible by updating the RSReportServer configuration file. To export reports from SQL Server Data Tools (SSDT) using the Word 2003 renderer, you update the RSReportDesigner configuration file. However, making the Word 2003 renderer visible doesn't make it available in all scenarios. Because the RSReportServer configuration file resides on the report server, the tools or products from where you export reports must be connected to a report server to read the configuration file. If you use tools or products in disconnected or local mode, making the Word 2003 renderer visible has no effect. The Word 2003 menu option remains unavailable. If you make the Word 2003 renderer visible in the RSReportDesigner configuration file, the Word 2003 menu option is always available in SQL Server Data Tools (SSDT) report preview.

The Word 2003 menu option is never visible in the following scenarios:

If the Word 2003 renderer is configured to be visible, both the Word and Word 2003 menu options are available in the following scenarios:

  • Reporting Services web portal when Reporting Services is installed in native mode.

  • SharePoint site when Reporting Services is installed in SharePoint integrated mode.

  • SQL Server Data Tools (SSDT) when you preview reports.

  • Report Builder connected to a report server.

  • The Report Viewer Web Part in remote mode.

The following XML shows the elements for the two Word rendering extensions in the RSReportServer and RSReportDesigner configuration files:

<Extension Name="WORDOPENXML" Type="Microsoft.ReportingServices.Rendering.WordRenderer.WordOpenXmlRenderer.WordOpenXmlDocumentRenderer,Microsoft.ReportingServices.WordRendering"/>

<Extension Name="WORD" Type="Microsoft.ReportingServices.Rendering.WordRenderer.WordDocumentRenderer,Microsoft.ReportingServices.WordRendering" Visible="false"/>

The WORDOPENXML extension defines the Word renderer for Microsoft Word .docx files. The WORD extension defines the Microsoft Word 2003 version. Visible = "false" indicates the Word 2003 renderer is hidden. For more information, see RsReportServer.config configuration file and RSReportDesigner configuration file.

Differences between the Word and Word 2003 renderers

Reports, rendered by using the Word or Word 2003 renderers tend to be visually indistinguishable. However, you might notice minor differences between the two the Word or Word 2003formats.

Device information settings

You can change some default settings for this renderer, by changing the device information settings. You can change some default settings such as to omit hyperlinks and drillthrough links or expand all items that can be toggled regardless of the original state of the item when rendered. For more information, see Word device information settings.