7 Replies Latest reply: May 10, 2017 9:30 AM by Ali Ahmad RSS

    RTF presentation in table

      Hi

       

      I have a column in sql database as RTF, i want to show this column in plain table in Qlikview.

      How to convert it to string?

        • Re: RTF presentation in table
          - -

          Hi,

             u can make use of

            

             ord() or chr()  functions

          example:

            ord('R')

            result- returns number 82

            chr(82) returns R

           

           

           

          regards,

          Vaibhav

            • Re: RTF presentation in table

              thanks vibhav for your reply,

              one of the values in the field is

               

              7B5C727466315C616E73695C616E7369637067313235325C64656666305C6465666C616E67313033337B5C666F6E7474626C7B5C66305C666E696C5C666368617273657430204D6963726F736F66742053616E732053657269663B7D7D0D0A5C766965776B696E64345C7563315C706172645C66305C66733137205B41627261722041686D61645D5C7061720D0A546869732061637469766974792068617320616C7265616479206265656D20636F6D706C657465642C20776520646F20756E6465727374616E642020776879206974207374696C6C20686572655C7061720D0A5C7061720D0A7D0D0A00

               

              Can u please tell me what fuction to apply to convert it in text format

               

            • Re: RTF presentation in table
              Alberto Varela

              Hello, Were you able to convert RTF into plain text? Any chance you can share your script?

               

              Thank you!

              • Re: RTF presentation in table
                harish krishnamoorthy

                Hi All,

                 

                I am beginner with QlikView and I had to face a challenge of extracting the plain text by parsing  RTF/RichText. Seems to be an easy problem and the solution is even easier ,but it took me some time to arrive at the solution, hence i would like to share it with the community. 

                 

                I created a custom function in QlikView  by writing a JScript  in the Edit Module (CTRL +M) space. The function is as shown below

                 

                function convertToPlain(rtf)

                {

                    rtf = rtf.replace(/\\par[d]?/g, "");

                    return rtf.replace(/\{\\[^{}]+;\}|[{}]|\\\n?[A-Za-z]+\n?(?:-?\d+)?[ ]?|[{\\\*}]/g, "");

                }

                 

                All this function does is replaces the string which matches the regex expression marked in bold with a empty string  "" . I am sure that some of you can write a better Regex Expression, but this was the one which worked for me(there are lot of posts where you find different regex expression which might work for you but you need to do thorough testing). You can use websites such as https://regex101.com/ to build your own Regex Exp and test it.

                 

                Now all  you have to do is to call this function in your load script as shown below

                 

                Load  convertToPlain(<YourRTFColumn>) from <YourSource>;

                 

                Please feel free to contribute if you think there is a better way to do it or someone wants to add on to this.

                  • Re: RTF presentation in table
                    Ali Ahmad

                    Hi, I  am trying to understand how you did this. What if this was your RTF output?

                     

                    {\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}\viewkind4\uc1\pard\lang1033\f0\fs16\par\parRing stedet F\'d8R utr.\par\parK-pers varsles ETTER utr.\par\parUtr. v/ Vakt-Service\par\par\'c5pningstider:\par\parVarsle inst. ved feil:\parL\'e5ne n\'f8kkel til inst:\parBlokkering v/:\parForsikringsselskap:\parInstruks fra: 13/12/2012\par\par}