简体   繁体   English

Jasper报表在报表中生成富文本

[英]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 etc 我也想在报表中显示富文本,例如下划线,粗体,字体大小或字体等

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. 但是它正显示在数据库中。 eg 例如

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. 我希望此文本下划线。

Set markup property of the element where you display the value to "styled". 将显示值的元素的markup属性设置为“样式”。 If you create JRXML programmatically, use setMarkup ("styled") . 如果您以编程方式创建JRXML,请使用setMarkup(“ styled”)

EDIT : Actually, you might also try "html" and "rtf". 编辑 :实际上,您也可以尝试“ html”和“ rtf”。 "styled" is what we use in our application, so that was an automatic answer, sort of. “样式化”是我们在应用程序中使用的样式,因此是一种自动答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM