问题描述
我有一些以HTML格式显示的Jasper报告。我希望HTML表格中列的宽度自动调整大小以适应最宽单元格的内容(在该列中),以便显示所有数据。
< td style =width:20px; height:17px;>
< span style =font-family:Arial; font-size:11px;> foo-bar-baz @examp< / span>
< / td>
我不能简单地删除所有这些宽度属性(使用JavaScript),因为(如HTML以上)使用这些宽度时隐藏的任何数据甚至不会返回到客户端
$ p $ Cheer
Don $ p
虽然不完美,但您可以将该字段标记为溢出。这至少会给你所有的数据。在您的jrxml文件中,它将类似于:
< textField isStretchWithOverflow =truehyperlinkType =None>
< reportElement style =Report Sub-Titlex =0y =84width =802height =20/>
< textElement />
< textFieldExpression class =java.lang.String><![CDATA [期间...]]>< / textFieldExpression>
< / textField>
恐怕我不知道Jasper报告的任何功能会允许动态调整大小列的宽度 - 这可能是HTML的意义之一,但对于其他输出格式(例如PDF)没什么意义。
I have some Jasper reports which are displayed in HTML format. I would like the width of the columns in the HTML tables to automatically resize to fit the content of the widest cell (in that column), such that all the data is displayed.
Currently this does not happen because the HTML generated by Jasper specifies fixed widths for the <table> and some <td> elements, e.g.
<td style="width: 20px; height: 17px;">
<span style="font-family: Arial; font-size: 11px;">foo-bar-baz@examp</span>
</td>
I can't simply remove all these width properties (using JavaScript), because (as shown in the HTML above) any data that would be hidden when using these widths is not even returned to the client-side
Cheers,Don
While not perfect, you could flag the field to stretch with overflow. This would at least give you all the data. In your jrxml file it would be similar to:
<textField isStretchWithOverflow="true" hyperlinkType="None">
<reportElement style="Report Sub-Title" x="0" y="84" width="802" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["For the period ...]]></textFieldExpression>
</textField>
I'm afraid I don't know of any feature of Jasper reports that would allow the dynamic resizing of column widths - It is probably one of those things that makes sense for HTML but little sense for other output formats such as PDF.
这篇关于动态列单元格宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!