<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tree-template" pageWidth="595" pageHeight="842" columnWidth="481" leftMargin="57" rightMargin="57" topMargin="72" bottomMargin="72">
<style name="Title" forecolor="#000000" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/>
<style name="SubTitle" forecolor="#666666" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true" pdfFontName="Times-Roman"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style mode="Opaque" backcolor="#F0EFEF"/>
</conditionalStyle>
</style>
<parameter name="JasperCustomSubReportLocation" class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="JasperCustomSubReportDatasource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<field name="name" class="java.lang.String"/>
<field name="notes" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<field name="project" class="com.pearson.ltg.qmo.dashboard.domain.QDashProject">
<fieldDescription><![CDATA[project]]></fieldDescription>
</field>
<field name="theme" class="java.lang.String"/>
<field name="goals" class="java.lang.String"/>
<field name="statusDetails" class="java.lang.String"/>
<field name="mitigation" class="java.lang.String"/>
<field name="status" class="java.lang.String"/>
<field name="releaseDate" class="java.util.Calendar"/>
<group name="Group1">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/15)]]></groupExpression>
</group>
<group name="Group2">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/5)]]></groupExpression>
<groupHeader>
<band height="10"/>
</groupHeader>
</group>
<title>
<band height="58" splitType="Stretch">
<staticText>
<reportElement style="Title" x="4" y="0" width="477" height="56"/>
<textElement>
<font size="48" isBold="false"/>
</textElement>
<text><![CDATA[Release Details]]></text>
</staticText>
</band>
</title>
<detail>
<band height="189" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="0" y="7" width="481" height="13" forecolor="#D0B48E" backcolor="#9DB1B8"/>
</frame>
<textField>
<reportElement x="279" y="7" width="202" height="13"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="79" y="7" width="100" height="13"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{project}.getName()]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="2" y="7" width="79" height="13"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Platform : ]]></text>
</staticText>
<staticText>
<reportElement x="179" y="7" width="100" height="13"/>
<textElement>
<font size="10" isBold="true" isItalic="false"/>
</textElement>
<text><![CDATA[Release Name :]]></text>
</staticText>
<staticText>
<reportElement x="0" y="20" width="47" height="20"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Status : ]]></text>
</staticText>
<textField>
<reportElement x="79" y="20" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{status}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="40" width="79" height="20"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Release Date: ]]></text>
</staticText>
<staticText>
<reportElement x="0" y="60" width="181" height="20"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Release Goals]]></text>
</staticText>
##want this field to auto stretch as per content##
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="80" width="463" height="20"/>
<textElement>
<font size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{goals}==null ? "Not Defined":$F{goals}]]></textFieldExpression>
</textField>
##want this field to auto stretch as per content##
<staticText>
<reportElement stretchType="RelativeToTallestObject" x="0" y="100" width="98" height="20"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Status Details]]></text>
</staticText>
<textField isStretchWithOverflow="true">
<reportElement stretchType="RelativeToTallestObject" x="2" y="120" width="463" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{statusDetails}==null ? "Not Defined":$F{statusDetails}]]></textFieldExpression>
</textField>
<staticText>
<reportElement stretchType="RelativeToTallestObject" x="0" y="140" width="98" height="20"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Risk Mitigation]]></text>
</staticText>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="18" y="160" width="463" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{mitigation}==null?"Not Defined":$F{mitigation}]]></textFieldExpression>
</textField>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="79" y="40" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[new SimpleDateFormat("MMM dd,yyyy").format($F{releaseDate}.getTime())]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="180" width="481" height="1"/>
</line>
</band>
</detail>
<columnFooter>
<band height="12" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="13" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="0" y="0" width="477" height="13" forecolor="#D0B48E" backcolor="#9DB1B8"/>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement style="Column header" x="2" y="0" width="197" height="13" forecolor="#FFFFFF"/>
<textElement verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement style="Column header" x="450" y="0" width="27" height="13" forecolor="#FFFFFF"/>
<textElement verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Column header" x="370" y="0" width="80" height="13" forecolor="#FFFFFF"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
</frame>
</band>
</pageFooter>
</jasperReport>
回答
該字段可以自動延伸溢出,但它下降(有點文字換行),而不是增加寬度。在PDF文檔中,您需要注意的選項很少或沒有用。
檢查這個其他線程的進一步信息Dynamic column cell width
編輯還要檢查,包括JasperReports的字體擴展。也許這可能有助於在沒有OS字體問題的情況下進行完美的部署。
我正在生成一個RTF JasperReport,該文本字段的高度不是自動拉伸的。 – 2012-02-21 12:28:07
得到了解決方案。將所有靜態文本字段和所有元素屬性修改爲positionType =「Float」。 – 2012-02-27 08:13:29
好。創建答案並檢查它,以便其他人知道! – Alfabravo 2012-02-27 16:20:48
得到了解決方案。將所有靜態文本字段和所有元素屬性修改爲positionType =「Float」。
只需將isStretchWithOverflow="true"
添加到您希望作爲元素的textField。
<textField isStretchWithOverflow="true">
<reportElement x="279" y="7" width="202" height="13"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
</textField>
- 1. 如何根據文本內容顯示浮動文本字段?
- 2. 根據其內容拉伸div
- 3. JasperReport:如何動態重複字段
- 4. 如何根據輸入字段動態更改網頁內容
- 5. JasperReport和文本字段
- 6. 根據動態下拉框在表單中填充文本字段。
- 7. 如何在一個區域傳播/拉伸文本內容?
- 8. 如何將動態前景應用於JasperReport中的文本字段
- 9. JasperReports文本字段拉伸 - 可拉伸高度是否有限?
- 10. html - 拉伸內容
- 11. 內容不拉伸
- 12. 拉伸div內容
- 13. 如何根據標籤文本長度來拉伸容器寬度?
- 14. 下拉框的動態文本字段
- 15. 如何在MFC中拉伸文本?
- 16. 我如何根據文字拉伸我的div?
- 17. 如何根據字段值在logstash中動態翻譯字典?
- 18. 背景圖片在滾動視圖內粘貼文本字段時拉伸
- 19. 如何根據文本塊中的內容設置UIElement的動態高度
- 20. 如何根據下拉填充文本字段?
- 21. 保存在自定義動態文本字段的tableView內容
- 22. 如何根據字段拆分文件並編輯內容
- 23. 如何根據文件字段的內容操作表單?
- 24. 如何根據下拉列表自動更改文本框的內容?
- 25. 如何拉伸HeaderedContentControl的內容?
- 26. 如何根據右側拉伸圖像?
- 27. 根據下拉列表值動態顯示所需文本字段
- 28. 如何將輸入文本拉伸爲全寬?動態PHP
- 29. 在Silverlight中拉伸組合框內容
- 30. 如何根據其容器調整ExtJS文本字段寬度
您的報告如何定義,垂直或水平? – adis 2012-02-21 12:12:37
很高興你告訴我們發生了什麼錯誤情況。現在,你使用的是什麼jasperreports版本?你如何編輯它? – Alfabravo 2012-02-21 12:35:24
我正在使用iReport進行編輯。 Jasper報告版本爲3.7.6 – 2012-02-21 12:58:20