jasper-reports - jasper 报告中的垂直文本对齐

标签 jasper-reports

我在 jasper 报告中有一个表格,我需要该表格中某些单元格的内容垂直对齐。 我正在尝试使用 iReport 编辑报告。

在 iReport 中,我可以进入单元格的属性并看到垂直对齐设置为“中间”。此外,当我直接查看 XML 时(见下文),我可以看到 textElement 标签有一个 verticalAlignment="Middle"属性。

如此接近,我可以告诉文本应该在它的小框中垂直对齐,但它不会正确对齐。

我希望有在 jasper 报告中垂直对齐事物经验的人可以 指出我做错了什么。 非常感谢。

<textField 
  isStretchWithOverflow="false"
  isBlankWhenNull="true" 
  evaluationTime="Now" 
  hyperlinkType="None"
  hyperlinkTarget="Self" >

  <reportElement
    x="227"
    y="0"
    width="31"
    height="14"
    key="textField-4"/>

  <box>
    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    <bottomPen lineWidth="0.0" lineColor="#000000"/>
    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
  </box>

  <textElement textAlignment="Center" verticalAlignment="Middle">
    <font fontName="Times New Roman" pdfFontName="Times-Roman" size="8"/>
  </textElement>

  <textFieldExpression class="java.lang.String"><![CDATA[$F{someVariableName}]]></textFieldExpression>
</textField>

所以,要清楚的是,我在报告中的内容是这样的:
|--------|
|  text  |
|        |
|        |
|--------|

我想要的是这样的:
|--------|
|        |
|  text  |
|        |
|--------|

最佳答案

您可以 1) 检查 positionType="FixRelativeToTop"2) 使用 alingn = middle 创建一个样式并将其应用于您的项目 - 也许这会有所帮助。

关于jasper-reports - jasper 报告中的垂直文本对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4209049/

相关文章:

java - Jasper Server - MSWord 导出多个文件

java - 在 JasperReport/iReport 中包含长静态文本的最佳方法是什么?

java - 如何在报表中使用多个XML数据源

java - 如何在 JasperReports 中使用 List<List<String>> 打印表格?

json - 如何使用json作为数据源在jasper报告中创建多个表?

java - 使用 iReport 创建 pdf 时使用自定义字体

spring-mvc - 部署到 Tomcat 8 时编译 Jasper 报告

java - 贾斯珀报告打印

JavaBean 作为 iReport 中的数据源 : “General рroblem: null” (jar is in the classpath! )

java - 从 Java 向 JasperReports SQLl 语句传递参数