我尝试将HTML样式的文本添加到动态jasper报告中
JRDesignBand band = new JRDesignBand();
band.setHeight(20); // Set band height
JasperDesign jasperDesign = new JasperDesign();
JRDesignTextField textField = new JRDesignTextField();
textField.setX(0); // x position of text field.
textField.setY(0); // y position of text field.
textField.setWidth(860); // set width of text field.
textField.setHeight(20); // set height of text field.
JRDesignExpression jrExpression = new JRDesignExpression(); // new instanse of expression. We need create new instance always when need to set expression.
jrExpression.setText("<p>text space</p>"); // Added String before field in expression.
textField.setExpression(jrExpression);
textField.setMarkup("html");
band.addElement(textField);
((JRDesignSection) jasperDesign.getDetailSection()).addBand(band);
JasperDesignViewer.viewReportDesign(jasperDesign);
但文字仍然有HTML标签。
答案 0 :(得分:0)
据我所知,允许的html标签非常有限,适用于基本的文本格式。
<b>bold</b>
<i>italic</i>
<u>underlined</u>
就是这样。
此处讨论了“html”和“样式化”标记在导出为PDF http://community.jaspersoft.com/questions/521757/html-markup-pdf
时出现问题