IREPORT +jasperreport 做报表时 对于 $F{xxxx}传值很长的情况下,怎么让它自动换行呢?

类似这种情况,服务器在windows下,这种框可以自动换行,但在linux下却只显示第一行信息到框最右边剩下的就不显示了,求教这种问题怎么解决??StretchWithO... 类似这种情况,服务器在windows下,这种框可以自动换行,但在linux下却只显示第一行信息到框最右边剩下的就不显示了,求教这种问题怎么解决??Stretch With Overflow这个选项钩选了也没用。 展开
 我来答
圣鸾OJ
2015-09-10 · TA获得超过1629个赞
知道小有建树答主
回答量:1136
采纳率:96%
帮助的人:108万
展开全部
最近刚刚学习jasperreport报表使用,做了几个例子,但在实现动态添加元素(列名,循环数据)上出现了问题,没办法解决.
但是出现这种异常,感觉自己没什么错,查了很久的资料还找不到答案,各位帮下忙.
net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
1. Field not found : Field1
这是设计
[img=http://f18.yahoofs.com/users/4806be90z2166bf67/86a5/__sr_/52b4.jpg?phA0C.IBEdd4GMmG][/img]
保存设计,名domeDynamic.jrxml.
代码
int randomNum = new Random().nextInt(20);
String jrxmlPath = this.getServletContext().getRealPath("/jasper");
jrxmlPath = jrxmlPath + "\\domeDynamic.jrxml";

JasperDesign jasperDesign= JRXmlLoader.load(jrxmlPath);//因为还是添加元素进去,所以还只是jrxml文件

JRDesignBand columnHeaderBand = (JRDesignBand )jasperDesign.getColumnHeader();//获取ColumnHeader拦
JRDesignBand detailBand = (JRDesignBand )jasperDesign.getDetail();//获取Detail拦
JRDesignTextField detailField= (JRDesignTextField )detailBand.getElementByKey("textField-2");
JRDesignStaticText columnHeaderField = (JRDesignStaticText)columnHeaderBand.getElementByKey("staticText-3");
Map map = new HashMap();
List list = new ArrayList(); 数据集 list.add(map);
map.put("Field1","1");
map.put("Field2","2");
//根据随即生成的数进行动态添加列
for(int i=0,y=3;i<=randomNum;i++,y++){
String detailFieldKey = "Field-"+y;
//String columnHeaderFieldKey = "staticText-"+y+1;
map.put(detailFieldKey,y);
//map.put(columnHeaderFieldKey,"列"+y);

detailField= (JRDesignTextField)detailField.clone();
detailField.setX(detailField.getX()+detailField.getWidth());
JRDesignExpression expression = new JRDesignExpression();
expression.setText("$F{"+detailFieldKey+"}");
System.out.println("$F{"+detailFieldKey+"}");
expression.setValueClass(java.lang.String.class);
detailField.setExpression(expression);
detailBand.addElement(detailField);

columnHeaderField = (JRDesignStaticText)columnHeaderField.clone();
columnHeaderField.setX(columnHeaderField.getX()+columnHeaderField.getWidth());
columnHeaderField.setText("列"+y);
columnHeaderBand.addElement(columnHeaderField);
}
list.add(map);
System.out.println(list);
JRDataSource jRDataSource = new JRMapCollectionDataSource(list); //用这个应该可以
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);//编译jrxml文件,异常也出在这一行.
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,null,jRDataSource); //填充打印
OutputStream outputStream = response.getOutputStream();
response.setContentType("application/pdf");
response.setCharacterEncoding("GB2312");
response.setHeader("Content-Disposition","attachment; filename="+URLEncoder.encode("PDF报表","GB2312")+".pdf");
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,outputStream);
exporter.exportReport();
outputStream.close();
out.clear();
out = pageContext.pushBody();
异常:
net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
1. Field not found : Field1
2. Field not found : Field2
3. Field not found : Field-3
4. Field not found : Field-4
5. Field not found : Field-5
6. Field not found : Field-6
7. Field not found : Field-7
8. Field not found : Field-8
at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:260)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:144)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:219)
at org.apache.jsp.domeDynamic_jsp._jspService(domeDynamic_jsp.java:138)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
碰到过这问题的帮忙解决下! 谢谢呀。
顺便问一下 如果一个报表要使用多个数据源. 也就是多个Detail的情况下要怎么做?
网易云信
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同... 点击进入详情页
本回答由网易云信提供
wademylove159
2013-08-15 · 超过51用户采纳过TA的回答
知道小有建树答主
回答量:136
采纳率:100%
帮助的人:134万
展开全部
有个属性,选中要换行的字段,里面有个属性是自动换行的,就是你上面的这个Stretch With Overflow,还要选那个Stretch Type才会生效,你试试看
追问
选了还是不行   只能补几个空格让它换行了
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式