Java Jasper Reports 中的新行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1103107/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 23:47:22  来源:igfitidea点击:

New lines in Jasper Reports?

javajasper-reportsnewlineline-breaks

提问by Kazade

I've just started using Jasper Reports to generate reports from data retrieved using Hibernate. Everything is working, except JR doesn't seem to respect newline characters (\n) in text fields. Is there a way to force line breaks at newline characters?

我刚刚开始使用 Jasper Reports 从使用 Hibernate 检索的数据生成报告。一切正常,除了 JR 似乎不尊重文本字段中的换行符 (\n)。有没有办法在换行符处强制换行?

回答by Kazade

Set the isStyledTextto true(tick it) and to break the line use <br/>.

设置isStyledTexttrue(勾选它)并使用<br/>.

Example:

例子:

text + "<br/>" + newLineText

回答by vespa

If you use iReport, you can select the static text area. In the right column you will find the properties of that object. Under "Static text properties -> Text" you will find your text. Click onto the button [...] so that a window opens where you can enter your text including line breaks.

如果使用 iReport,则可以选择静态文本区域。在右栏中,您将找到该对象的属性。在“静态文本属性 -> 文本”下,您将找到您的文本。单击按钮 [...],将打开一个窗口,您可以在其中输入包括换行符在内的文本。

回答by sfblap

if you use Static Text, in Jasper Studio, you can press Shift + Enter

如果您使用静态文本,在 Jasper Studio 中,您可以按 Shift + Enter