The WordRenderingExtension class renders your reports to the native Microsoft Word file formats. You can export Page reports and RDL reports to the Office Open XML (OOXML) format (.Docx) or Word HTML format (.Doc) using the FileFormat property.
The .Doc format provides greater layout accuracy for Page and RDL Reports in Microsoft Word, on the other hand, .Docx format provides excellent editing experience for the exported reports.
The OOXML format (.Docx) is recommended in the following scenarios:
-
Open exported reports in a wide range of applications: Users can open and modify the exported Word document in any of the following applications.
- Customize reports after exporting: Positioning and arrangement of report elements in the exported document is implemented using the OOXML format which provides a natural document flow for editing the exported documents.
- Use Word automation features: With support for automation features in the OOXML format, tasks that previously required manual adjustments in the exported Word document are now handled automatically. Report elements such as page header and footer, expressions, heading levels, and table of contents are automatically transformed to the OOXML format.
- Set compatiblity mode: You can render a report as a Word document that is compatible with Microsoft Word 2007-2010 as well as Microsoft Word 2013 using the DocumentCompatibleVersion property.
In order to render the report in Microsoft Word (.HTML or .OOXML), add reference to the following assemblies in the project:
- GrapeCity.ActiveReports.Export.Word.v10.dll
- GrapeCity.ActiveReports.Extensibility.v10.dll
The following steps provide an example of rendering a report in the Word format.
- In Visual Studio, create a new Windows Forms Application or open an existing one.
- On the Form.cs or Form.vb that opens, double-click the title bar to create the Form_Load event.
- Add the following code inside the Form_Load event to render your report in .OOXML or .HTML file format.
Note: To export your report in .HTML format, change the FileFormat property option from .OOXML to .HTML format as depicted below.
wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.HTML
To export a report in .Docx file format
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code
|
' Provide the page report you want to render.
Dim report As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo("C:\Sample_PageReport.rdlx"))
Dim reportDocument As New GrapeCity.ActiveReports.Document.PageDocument(report)
' Create an output directory
Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyWord")
outputDirectory.Create()
' Provide settings for your rendering output.
Dim wordSetting As New GrapeCity.ActiveReports.Export.Word.Page.Settings()
' Set the FileFormat property to .docx
wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.OOXML
' Set the rendering extension and render the report.
Dim wordRenderingExtension As New GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension()
Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))
reportDocument.Render(wordRenderingExtension, outputProvider, wordSetting)
|
C# code. Paste INSIDE the Form Load event. |
Copy Code
|
// Provide the page report you want to render
GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(@"C:\Sample_PageReport.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument reportDocument = new GrapeCity.ActiveReports.Document.PageDocument(report);
// Create an output directory
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyWord");
outputDirectory.Create();
// Provide settings for your rendering output
GrapeCity.ActiveReports.Export.Word.Page.Settings wordSetting = new GrapeCity.ActiveReports.Export.Word.Page.Settings();
// Set the FileFormat property to .docx
wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.OOXML;
//Set the rendering extension and render the report
GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension wordRenderingExtension = new GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
reportDocument.Render(wordRenderingExtension, outputProvider, wordSetting);
|
Word Rendering Extension Properties
ActiveReports offers several options to control how reports render to Microsoft Word.
Common properties (.HTML and .OOXML)
Property |
Description |
Author |
Sets the name of the author that appears in the Author field of the Properties dialog in the rendered Word document. |
FileFormat |
Sets the output file format to .HTML (Doc) or .OOXML (Docx). By default the file format is set to .HTML format. |
Title |
Sets the title for a document that appears in the Title field of properties dialog in the rendered Word document. |
.HTML format
Property |
Description |
BaseUrl |
Sets the base URL for any relative hyperlinks that appear in the Hyperlink base field of the Properties dialog in the rendered Word document. |
Generator |
Sets the identity of the document generator in the rendered Word document. |
PageHeight |
Sets the height of the report pages in inches for the rendered Word document. The value in this property overrides the original settings in the report. |
PageWidth |
Sets the width of the report pages in inches for the rendered Word document. The value in this property overrides the original settings in the report. |
UseMhtOutput |
Indicates whether Mht output is to be used for the resultant Word document or not. |
.OOXML format
Property |
Description |
CompanyName |
Sets the name of the organization or company that appears in the Company field of Properties dialog in the rendered Word document. |
DocumentCompatibilityVersion |
Sets the compatibility mode of the document to the latest version (Microsoft Word 2013) or to previous versions (Microsoft Word 2007 - 2010) of Word. By default the compatibility version is set to Word2007.
|
DpiX |
Sets the horizontal resolution of the images in the rendered Word document. By default DpiX is set to 96. |
DpiY |
Sets the vertical resolution of the images in the rendered Word document. By default DpiY is set to 96. |
PageOrientation |
Sets a value that specifies whether the document pages should be printed in portrait or landscape in the rendered Word document. |
PaperSize |
Sets the paper size for the page. |
Password |
Sets a password that must be provided to open the rendered Word document. |
ReadOnlyRecommended |
Sets a value that indicates whether Microsoft Office Word displays a message whenever a user opens the document, suggesting that the document is read-only. |
WritePassword |
Sets the write password that is required for saving changes in the rendered Word document. |
TOCAutoUpdate |
Automatically updates the TableOfContents control while opening the Word document. By default TOCAutoUpdate is set to False. |
Limitations
.HTML format
- Although background colors for controls export to Word documents, background colors for sections such as Body and Page Header or Footer do not.
- KeepTogether is not supported.
- Some FormattedText tags, for example <b>bi</b> and <s>es</s>, are not exported to Word.
- Image alignments other than the defaults (HorizontalAlignment: Left and VerticalAlignment: Top) are not supported.
- EMF text in the Image report item is blurred when exported to Word.
.OOXML format
Report properties
- The LineSpacing property of a report's style sheet, StartPageNumber property of the report, PrintOnLastPage property of the PageHeader and PageFooter are not supported.
- For Page reports, some of the NumberingStyle property (DocumentMap settings) options are not supported. The supported NumberingStyle options are Decimal, DecimalZero, LowerLetter, UpperLetter, LowerRoman, UpperRoman.
- The BackgroundRepeat property of the BackgroundImage is not supported in Page (Page reports) and Body (RDL reports).
- For RDL reports, Background and Border properties of Page Header or Page Footer are not supported.
- Microsoft Word calculates the columns width by the document width. A RDL report calculates the columns width based on the body width, therefore the width of columns in an exported RDL report may differ from an original RDL report.
- In Microsoft Word, the maximum supported page size is 22 inches (55.87 cm) wide and 22 inches (55.87 cm) high. If an exported report exceeds the maximum size, some data may be lost during export.
- In Microsoft Word, a table can have a maximum of 63 columns. If an exported report table has more than 63 columns, then the table is split and therefore an exported document may differ from an original report.
- A repeated Table Footer (the RepeatOnNewPage property of Table Footer) or multiple repeated headers on a single page are not supported.
- The OverflowPlaceHolder control is not supported.
- If the PrintOnFirstPage property of PageHeader or PageFooter is set to False, then both PageHeader and PageFooter will not be available on the first page of the exported document.
Report controls
- The Background image is not supported in any report control except Shape.
- The Inset option of the BorderStyle property is not supported.
- The Map, Chart, Image, Barcode, SparkLine, Bullet, and CustomControl report controls are exported as an image. If a report control uses the BorderColor, BorderStyle or BorderWidth properties, a report is exported as a table.
- The BorderWidth property of report controls is not exported as is and may differ from the original BorderWidth value.
- PageBreaks are not fully supported. In an exported Word file format, the PageBreak at the beginning of a root table cell is supported while the PageBreaks in nested tables and inside the cell's content are not supported.
- Custom line styles for the LineStyle property set through the ExpressionEditor are exported as a solid line.
- For Shape report control, if the BorderStyle property is set to Double, it is exported as solid.
- For BandedList data region, only the BandedList Header is repeated on each page. The BandedList Footer, GroupHeaders and GroupFooters are not supported.
- Tablix data region is exported as a single table without horizontal split.
- For Tablix and Table data region, the maximum supported table width in Microsoft Word is 22 inches. All columns exceeding this limit are not supported.
- Horizontally aligned images may overlap in iWord application.
- For Image control, Border properties and Padding properties are not supported if the Sizing property is set to Clip.
- For Container report control, rounding corners (the RoundingRadius property) are not supported.
FormattedText
- FormattedText is exported as it is. The HTML and CSS features are not supported.
- The <a> tag without a href attribute, <abbr> and <q> tags are exported as simple text.
- The BackgroundColor, BackgroundImage, BorderColor, BorderStyle and BorderWidth properties are not supported.
- Anchors with an href attribute are exported as hyperlinks.
- Headers like h1, h2, etc. are exported as corresponding Microsoft Word built-in header styles.
TableOfContents
- The TextAlign, DisplayPageNumber, TextIndent, Overline TextDecoration and DisplayPageNumber properties are not supported.
- The Source property of the Document Map settings is not fully supported. Only the Headings Only option of the Source property is supported.
- If a report uses more than one TableOfContents controls, the properties of the first TableOfContents are applied to the other TableOfContents controls in the exported document.
- The FillCharacter property is exported as dots.
TextBox/CheckBox
- If the Format property is set to Numeric or Date, the exported TextBox has a right alignment. Other Format values are exported with the left alignment.
- The Transparent color for text is exported as white.
- The Underline for numbered lists, Right-To-Left (RTL) option of the Direction, Angle, ShrinkToFit and Overline TextDecoration properties are not supported.
- The action Jump to report is not supported.
- The tb-rl (vertical text) option of the WritingMode property is not supported. TextBoxes with the WritingMode property set to tb-rl are exported as lr-tb.
- The NoWrap option of the WrapMode property is exported as WordWrap.
- The LineSpacing property of an exported document will differ from the original report. This is because in Microsoft Word, the line spacing is calculated by the font size value of a report control plus the line spacing value of a report control.
- For CheckBox control, the CheckAlignment property is exported as MiddleRight for TopRight, MiddleRight, and BottomRight options. Other CheckAlignment options are exported as MiddleLeft.
- Paddings exceeding 31 inches is exported as border spaces.
Interactivity
.HTML format
Reports rendered in a Word format supports both Bookmarks and Hyperlinks. However, if visibility toggling (like in a drill-down report) is essential to your report, it is recommended to use the HTML rendering extension. If a Document map is essential to your report, it is recommended to use the PDF rendering extension.
.OOXML format
- Hyperlinks - Hyperlinks on TextBox and Image controls are rendered as hyperlinks in the Microsoft Word.
- Bookmarks - Bookmarks in the report are rendered as Microsoft Word bookmarks. Bookmark links are rendered as hyperlinks that link to the bookmark labels within the document.
- TOC AutoUpdate - TableofContents control in the report is rendered as Microsoft Word table of contents.
See Also