如何使用DynamicJasper更改文本元素的标记值? [英] How to you change the markup value for a text element using DynamicJasper?

查看:130
本文介绍了如何使用DynamicJasper更改文本元素的标记值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DynamicJasper在运行时从某些表生成报告。我有一些字段,数据在创建数据时使用基本的html标签进行样式设置。非常基本的标签,如粗体和斜体,以及jasper报告可以通过将textElement的标记属性设置为 html 来处理它们。问题是找不到使用DynamicJasper更改它的方法。

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.

我尝试使用中找到的addFieldProperty(markup,html) ColumnBuilder ,但是将标记作为属性添加到字段标记(可能很明显它应该根据名称执行此操作)而不是文本元素。

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.

如何使用DynamicJasper更改文本元素的标记值?

推荐答案

DynamicJasper API 不包含设置标记的方法

但您可以使用 JasperReports API 满足这种需求。
例如, JRBasePrintText 类和 JRCommonText 界面有设置标记的方法

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)

JRCommonText接口有常量字段:

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";

您可以根据需要修改DynamicJasper类,例如这篇文章,例如。

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

这篇关于如何使用DynamicJasper更改文本元素的标记值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆