How to you change the markup value for a text element using DynamicJasper?

戏子无情 提交于 2020-01-07 02:07:07

问题


I am using DynamicJasper to generate reports from some tables at run time. I have some fields that the data has been styled using basic html tags as the data was created. Very basic tags like bold and italic, and jasper reports can handle them by setting the markup attribute of the textElement to html. The problem is a can not find a way to change it using DynamicJasper.

I have tried using addFieldProperty("markup", "html") found in ColumnBuilder, but that adds markup as a property to the field markup (probably obvious that it should do that based on the name) instead of the text elemennt.

How to you change the markup value for a text element using DynamicJasper?


回答1:


The DynamicJasper API does not contain methods to set markup.

But you can use JasperReports API for this needs. For example, the JRBasePrintText class and JRCommonText interface have method for setting markup:

public void setMarkup(java.lang.String markup)

The JRCommonText interface has constant fields:

public static final String MARKUP_NONE = "none";
public static final String MARKUP_STYLED_TEXT = "styled";
public static final String MARKUP_HTML = "html";
public static final String MARKUP_RTF = "rtf";

You can modify DynamicJasper classes for your needs like in this post, for example.



来源:https://stackoverflow.com/questions/8229492/how-to-you-change-the-markup-value-for-a-text-element-using-dynamicjasper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!