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

jasper文件打印求助!!!
jasper文件我已经编译好了.
在JAVA类里面使用以下代码进行调用.小票打印机没响应.是怎么回事呀?
Map<String, String> params = new HashMap<String, String>();
params.put("ftitle", ApplicationContext.getHosName() + "购物凭证小票");

List<XiaopiaoPrint> xps = new ArrayList<XiaopiaoPrint>();
for (TGoodsDJ djtemp : djs) {
XiaopiaoPrint print = new XiaopiaoPrint();
print.setFlsdj(djtemp.getFlsdj());
print.setFsl(djtemp.getFsl());
print.setFlsje(djtemp.getFlsdj() * djtemp.getFsl());
print.setFtm(djtemp.getFtm());
print.setFname(djtemp.getFname());
xps.add(print);
}
JRBeanCollectionDataSource printSource = new JRBeanCollectionDataSource(
xps);

String rcp_path = Platform.getInstallLocation().getURL().getPath();
String fileName = rcp_path + "/report/xiaopiao.jasper";
File file = new File(fileName);
if (!file.exists()) {
return;
}
try {

JasperReport jspJasperReport = null;
try {
jspJasperReport = (JasperReport) JRLoader
.loadObject(new FileInputStream(file));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// JasperReport jspJasperReport = (JasperReport) JRLoader
// .loadObject(new File(fileName));
JasperPrint prt = JasperFillManager.fillReport(jspJasperReport,
params, printSource);
} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


------解决方案--------------------
打漏了 是byte[] bytes=JasperExportManager.exportReportToPdf(prt);