日期:2014-05-20  浏览次数:20605 次

struts2+jasperReport生成excel时..excel里面全是null
生成的excel文件里面全是null值...但行数和查出来的实际行数相同

希望高手指教....
action中的代码
Java code

public String goWorkBarExcel()throws Exception{
        NetworkBar workBar;
        List<NetworkBar> list=this.networkBarImp.findWorkBarByBarAddress(this.getParam());
        myList=new ArrayList<NetworkBar>();
        for(Iterator<NetworkBar> it=list.iterator();it.hasNext();){
            workBar=it.next();
            myList.add(workBar);
        }


struts.xml中的代码
XML code
<action name="report_*" class="org.boss.action.NetworkBarAction" method="{1}">
            <result name="excelreport" type="jasper">
                 <param name="location">/jasper/report1.jasper</param>
                  <param name="dataSource">myList</param>
                   <param name="format">HTML</param>
            </result>
            <result name="report">../deal/barreport.jsp</result>
        </action>


------解决方案--------------------
你生成的是动态的还是静态的?
------解决方案--------------------
我大概估计一下喔,可能是字符集设置问题,你所查出来的记录值有包含中文,需要在JSPERIREPORT里面把字段域的格式调成宋体。