Newlines in Word report fields

ivarsk
Member Posts: 12
Has anyone had success having multi-line fields displayed properly on a Word report in NAV 2015 ?
For the Word content control (plain text type), I have set the "Allow carriage returns (multiple paragraphs)" checkbox, and it does make the difference in the way that pressing Enter inside the content control results in a linebreak, while for the controls without that checkbox, pressing Enter is suppressed and does nothing. Hence, not the Word's fault.
Meanwhile from NAV, I've tried about everything with no success, e.g. the one below outputs a single-liner in Word, CRLF ignored:
Any suggestions? If nothing else, where do we report such issues to MS currently? Connect?
[ currently using CU 5, nothing related to be seen in platform fixes in later builds ].
For the Word content control (plain text type), I have set the "Allow carriage returns (multiple paragraphs)" checkbox, and it does make the difference in the way that pressing Enter inside the content control results in a linebreak, while for the controls without that checkbox, pressing Enter is suppressed and does nothing. Hence, not the Word's fault.
Meanwhile from NAV, I've tried about everything with no success, e.g. the one below outputs a single-liner in Word, CRLF ignored:
CRLF[1] := 13; CRLF[2] := 10; TextField := Description + CRLF + "Description 2";Also tried to directly output a NAV text field with MultiLine=Yes with some linebreaks, same result.
Any suggestions? If nothing else, where do we report such issues to MS currently? Connect?

[ currently using CU 5, nothing related to be seen in platform fixes in later builds ].
0
Comments
-
OK, silly enough, yet worth the journey - a workaround
Essentially I'm placing '{CRLF}' markers where I wish the newlines to appear in Word, and customize standard codeunit to convert those to linebreaks after NAVWordXMLMerger has done its job.
Messing with .docx directly, any guarantees disclaimed.
In Codeunit 9651 Document Report Mgt.:OutStrWordDoc := NAVWordXMLMerger.MergeWordDocument(InStrWordDoc,InStrXmlData,OutStrWordDoc); // standard code HandleCRLFs(OutStrWordDoc); // new function call COMMIT; // standard code
The function itself:LOCAL HandleCRLFs(VAR OutStrWordDoc : OutStream) ZipArchive := ZipArchive.ZipArchive(OutStrWordDoc, ZipArchiveMode.Read); ZipArchiveEntry := ZipArchive.GetEntry('word/document.xml'); StreamReader := StreamReader.StreamReader(ZipArchiveEntry.Open()); Contents := StreamReader.ReadToEnd(); Contents := Contents.Replace('{CRLF}', '<w:br/>'); CLEAR(ZipArchive); ZipArchive := ZipArchive.ZipArchive(OutStrWordDoc, ZipArchiveMode.Update); ZipArchiveEntry := ZipArchive.GetEntry('word/document.xml'); ZipArchiveEntry.Delete(); ZipArchiveEntry := ZipArchive.CreateEntry('word/document.xml'); StreamWriter := StreamWriter.StreamWriter(ZipArchiveEntry.Open()); StreamWriter.Write(Contents); StreamWriter.Close(); // vars: ZipArchive DotNet System.IO.Compression.ZipArchive.'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ZipArchiveMode DotNet System.IO.Compression.ZipArchiveMode.'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ZipArchiveEntry DotNet System.IO.Compression.ZipArchiveEntry.'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' StreamReader DotNet System.IO.StreamReader.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' StreamWriter DotNet System.IO.StreamWriter.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Contents DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
PS. Still looking forward to hear the normal way of doing this0 -
Hi,
Thanks for this - have found it useful!
However, have found one small problem - if you use this technique and the data is in a Header section it does not work.
0 -
@chrisdf
In addition to document.xml, you should also convert the header1.xml (header2.xml, ...) and footer1.xml files.
Standard Word custom xml parts can be used instead of the NAV WordMergeDocument AddIn. Then a CL/LF is correctly transformed into a line feed within a plain text content control.
(see https://massivedynamicsblog.wordpress.com/2016/09/08/wordlayout-revisited/, e. g.)New kits on the blog: https://massivedynamicsblog.wordpress.com0 -
You can use Wordlayout+, which automatically transforms CR/LF into new lines in a word plain text control. Download and info here https://massivedynamicsblog.wordpress.com/2016/09/15/wordlayout/New kits on the blog: https://massivedynamicsblog.wordpress.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions