COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Samrat on 12 Aug 2015 05:56:20 AM

Title: Wrap text on number of characters in report studio
Post by: Samrat on 12 Aug 2015 05:56:20 AM
Dear friends,

In report studio,I have a requirement to wrap a string to next line after 25 characters for example I have a text ab10,bc20,cd30,ef40,gh50,ij60,kl70 in report it should show as
                                      ab10,bc20,cd30,ef40,gh50,
                                      ij60,kl70

Note: comma(,) will also needs to be considered as a character.

I tried giving wrap text option and setting width of column in pixels,this solutions works for few strings and few strings displayed  more than 25 characters in single line.



Thanks,
Samrat




                                       
Title: Re: Wrap text on number of characters in report studio
Post by: MFGF on 12 Aug 2015 05:59:20 AM
Quote from: Samrat on 12 Aug 2015 05:56:20 AM
Dear friends,

In report studio,I have a requirement to wrap a string to next line after 25 characters for example I have a text ab10,bc20,cd30,ef40,gh50,ij60,kl70 in report it should show as
                                      ab10,bc20,cd30,ef40,gh50,
                                      ij60,kl70

Note: comma(,) will also needs to be considered as a character.

I tried giving wrap text option and setting width of column in pixels,this solutions works for few strings and few strings displayed  more than 25 characters in single line.



Thanks,
Samrat




                                     

Hi,

I think you have the correct approach here - you just need to use a font that has the same width for each character (monospace font) eg Courier.

Cheers!

MF.
Title: Re: Wrap text on number of characters in report studio
Post by: bdbits on 12 Aug 2015 05:10:28 PM
You could also try using 'em' instead of 'px' for width, if you don't want a monospaced font. But it still might not be exactly 25 characters, unless you go monospaced.
Title: Re: Wrap text on number of characters in report studio
Post by: Samrat on 25 Aug 2015 08:54:05 AM
Hi MF,

Sorry for late reply.

Thanks for your reply.
Your idea is really good and it works fine.

Our Business user was more specific about font,hence we came up with below idea

Insert a table(instead of line item) in the list with 1 column and 4 rows,in the first row of the table use substring(line item,1,25)
in the seocnd row use substring(line item,26,25) in the third row use substring(  line item,51,25) and so on.. depending on the no of line the text can grow.In our my scenario user asked us to restrict text for 4 line,hence I have taken to display 100 characters i.e 25 characters per line.

Thought of sharing the solution if it helps some one.

Cheers,
Samrat
Title: Re: Wrap text on number of characters in report studio
Post by: bdbits on 25 Aug 2015 02:15:15 PM
Only thing I don't like about it is that you'll break strings right in the middle. But finding an expression to handle proper breaks (e.g. consider comma placement) would be non-trivial to say the least. More importantly, it sounds like your users are happy enough. Which in the end is the important thing.

Thanks for sharing your solution. Too many people never do that.