ActiveReports 18 .NET Edition
Developers / Export Reports / Export Page/RDLX Reports / Word Export
In This Topic
    Word Export
    In This Topic

    The WordRenderingExtension class renders your reports to the native Microsoft Word file formats. You can export Page reports and RDLX reports to Microsoft Office Open XML (OOXML) format (.Docx) or Word HTML format (.Doc) using the FileFormat property.

    The Word HTML format (.Doc) provides greater layout accuracy for Page and RDLX Reports in Microsoft Word, on the other hand, OOXML format (.Docx) provides excellent editing experience for the exported reports.

    The OOXML format (.Docx) is recommended in the following scenarios:

    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.
    Categories Sets the name of the categories that appears in the Categories field in the Properties of the exported 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.

    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 previous versions (Microsoft Word 2007 - 2013) of Word. By default, the compatibility version is set to Word2013. 

    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. 

    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

    Limitations

    HTML format

    OOXML format

    Report properties

    Report controls

    FormattedText

    Export Report using Word Rendering Extension

    The following steps provide an example of rendering a report in Word format (.doc or .docx).

    1. Create a new Visual Studio project.
    2. In the New Project dialog that appears, select ActiveReports 18 Page report Application and specify a name for the project in the Name field.
    3. Click OK to create a new ActiveReports 18 Page report Application. By default, a Page report is added to the project.
    4. Add a reference to MESCIUS.ActiveReports.Export.Word package in the project.
    5. On the Form.cs or Form.vb that opens, double-click the title bar to create the Form_Load event.
    6. 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 Word HTML format (.Doc), change the FileFormat property option from OOXML to HTML format as shown. 
    wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.HTML

    To export a report in .Docx file format

    VB code. Paste INSIDE the Form Load event.
    Copy Code
    ' Provide the Page report you want to render.
    
    Dim rptPath As New IO.FileInfo("..\..\PageReport1.rdlx")
    
    Dim pageReport As New GrapeCity.ActiveReports.PageReport(rptPath))
    
    ' 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 .OOXML.
    
    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))
    
    ' Overwrite output file if it already exists.
    
    outputProvider.OverwriteOutputFile = True
    
    pageReport.Document.Render(wordRenderingExtension, outputProvider, wordSetting)             
    
    C# code. Paste INSIDE the Form Load event.
    Copy Code
    // Provide the Page report you want to render.
    
    System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
    
    GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);
    
     // 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 .OOXML.
    
    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));
    
    // Overwrite output file if it already exists.
    
    outputProvider.OverwriteOutputFile = true;
    
    pageReport.Document.Render(wordRenderingExtension, outputProvider, wordSetting);