user4936282
user4936282

Reputation:

Jasper report generates rich text in report

I have rich text saved in database. I also want to show rich text in report too like underline, bold, font-size or font-face e.t.c

String[] columnNames = {"#", "Reference No.", "Name", "From", "Desc"};
System.out.println("viewList.size() ="+viewList.size());

String[][] data = new String[viewList.size()+documentViewList.size()][5];
int counter=0;
for(int i=0; i < viewList.size(); i++){
    for(int j=0; j< 5; j++){
        if(j==0)data[i][j]=(counter++)+"";
        if(j==1)data[i][j]=viewList.get(i).getFile().getId();
        if(j==2)data[i][j]=viewList.get(i).getReferenceNo().toString();
        if(j==3)data[i][j]=viewList.get(i).getShortText();
        if(j==4)data[i][j]=viewList.get(i).getDescription();
    }
}
tableModel = new DefaultTableModel(data, columnNames);

Here on this line it contain some rich text. But it is showing as it is in data base. e.g.

if(j==4)data[i][j]=viewList.get(i).getDescription();

Database value:

 <p><u>asdasdads asd a</u></p>

I want this text to be under lined.

Upvotes: 0

Views: 1257

Answers (1)

user319799
user319799

Reputation:

Set markup property of the element where you display the value to "styled". If you create JRXML programmatically, use setMarkup ("styled").

EDIT: Actually, you might also try "html" and "rtf". "styled" is what we use in our application, so that was an automatic answer, sort of.

Upvotes: 1

Related Questions