问题描述
publicvoidfill4()throwsJRException{JOptionPane.showMessageDialog(null,"进入fill4");longstart=System.currentTimeMillis();//PreparingparametersMapparameters=newHashMap();parameters.put("ReportTitle","AddressReport");parameters.put("DataFile","CustomBeanFactory.java-BeanCollection");//try{//JasperCompileManager.compileReportToFile("build/classes/test/sellStockPrint.jrxml","build/classes/test/sellStockPrint.jasper");JasperCompileManager.compileReportToFile("src/test2/testprint.jrxml","build/classes/PrintReport/testprint.jasper");JOptionPane.showMessageDialog(null,"断开前!");JasperFillManager.fillReportToFile("build/classes/PrintReport/testprint.jasper","build/classes/PrintReport/testprint.jrprint",parameters,newJRBeanCollectionDataSource(CustomBeanFactory.getBeanCollection()));//找到jasper文件..生成一个jrprint到C:/下面JOptionPane.showMessageDialog(null,"断开后!");System.err.println("Fillingtime:"+(System.currentTimeMillis()-start));JOptionPane.showMessageDialog(null,System.err.toString());JOptionPane.showMessageDialog(null,"出了fill4");}现在我的问题是,我用NETBEANS下载了ireport的插件,在测试的时候,可以生成testprint.jasper,testprint.jrprint这些文件,而且也可以打印和页面显示了,甚至我直接用运行项目也可以运行这些程序,但是.当我清理生成的时候,那个jxml文件不会编绎成jasper文件,这样生成出来的lib包里面也没有这二个文件.然后运行就没有反应了..请问这是什么问题?已经困扰了我好几天了..请各位帮帮忙..
解决方案
解决方案二:
晕,哪有这么复杂,把包都添加好了,把jrxml文件复制到项目中,然后直接编译生jasper再生成报表。JasperDesignjd;try{));jd=JRXmlLoader.load(newFile("E://CACComplainReport.jrxml"));JRDesignQueryjrq=(JRDesignQuery)jd.getQuery();Stringquery=jrq.getText();Stringwhere=(String)getRequest().getSession().getAttribute("setWhere");intexportType=(Integer)(getRequest().getSession().getAttribute("exportType"));query=query+where;jrq.setText(query);jd.setQuery(jrq);JasperReportjreport=JasperCompileManager.compileReport(jd);HashMap<String,Object>p=newHashMap<String,Object>();p.put("beginTime","统计开始时间:"+(String)getRequest().getSession().getAttribute("gecreateTime"));p.put("endTime","统计结束时间:"+(String)getRequest().getSession().getAttribute("lecreateTime"));//获取统计的开始日期p.put("title","CAC投诉工单清单---"+((String)getRequest().getSession().getAttribute("gecreateTime")).split("")[0]);JasperPrintjasperPrint=JasperFillManager.fillReport(jreport,p,SpringBeanFactory.getConnection());StringfileName="CAC投诉工单清单"+((String)getRequest().getSession().getAttribute("gecreateTime")).split("")[0];ExportImpl.export(exportType,fileName,getRequest(),getResponse(),jasperPrint);}catch(JRExceptione){LogUtil.writeLog(e,"EM557");}catch(IOExceptione){LogUtil.writeLog(e,"EM557");}returnnull;}