Jump to content
Changes to the Jaspersoft community edition download ×

How to keep line separator with CLOB


jl_3

Recommended Posts

Hello, I got a problem trying to print comments in my report.

Comment are stored in my ORACLE base in a table text_comment in a column where type is a varchar2.
Those comments are stored using more than one line.
exemple of data :
INDICE       |        TEXTE
     1             |        TOTO/n
     2             |        TUTU

So, when I concat my comments i can get something too big for a varchar (more than 4000 char)

In my report Comments are not my details, for each details I have many comments so I concat them.

I manage to concat my comments in one bloc using CLOB. Using this method : 

SELECT
[...]
DBMS_XMLGEN.CONVERT(
EXTRACT(xmltype('<?xml version="1.0"?><document>'||XMLAGG(XMLTYPE('<V>'|| DBMS_XMLGEN.CONVERT(COMMENTAIRE_TEXTE_FOOTER.COTE_TEXTE)|| ' </V>')  
ORDER BY COMMENTAIRE_TEXTE_FOOTER.COTE_INDICE).getclobval()||'</document>'), '/document/V/text()') .getclobval(),1) AS COMMENTAIRE_FOOTER
[...]
FROM [...] COMMENTAIRE_TEXTE_FOOTER [...]

With this I get a oracle.jdbc.internal.OracleClob object for Ireport.

Using iReport Designer 5.6.0 I read the CLOB Object like this : 
new BufferedReader(new InputStreamReader(((oracle.jdbc.internal.OracleClob)$F{COMMENTAIRE_FOOTER}).binaryStreamValue())).readLine();

My problem is that when i get my concatened comment, it came as a one line comment. 

Exemple : TOTO/nTUTU
But I want :
TOTO
TUTU

Is there a way to keep my line separators throught all the data conversion ?

Jérôme

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

That is because you have /n and your line separator may be different check System.getProperty("line.separator")

In this cases I prefer to use styled test. You can do this, replce the "/n" with breaks <br>:

myText.replace("n", "<br>");

And then In the properties window of the text Field select "html" in the “Markup” drop down (see screenshot below). Also remember to select "Stretch with Overflow" so the txt field will stretch when the text is long.

These are the markup options you have for your reference, check the JasperReports Doc Samples:

  • none - The content of the text element is plain text. There is nothing to be processed. This is the default value.
  • styled - The content of the text element is styled text, the JasperReports proprietary XML type of markup text. It overrides the deprecated isStyledText attribute. (See the Styled text sample)
  • html - The content of the text element is Hyper Text Markup Language
  • rtf - The content of the text element is Rich Text Format
 
Screenshot2016-04-2510_20_47.png.129ef3f7f06b1f367a8526f5e105475c.png
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...