These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: how to generate jasperreports with hibernate2.1.6
PostPosted: Wed Jan 24, 2007 3:05 am 
Newbie

Joined: Wed Jan 24, 2007 2:24 am
Posts: 6
iam using hibernate2.1.6 but iam unable to develope jasperreports

iam getting problems like

cannot resolve symbol : variable JRLoader
[location: class com.edhand.example1.AddItemAction
(JasperReport)JRLoader.loadObject(report File.getPath());




my code is:

File reportFile = new File(getServlet().getServletContext().getRealPath(
"/supreme.jasper"));
List StoreVoucherList = ((org.hibernate.classic.Session) session).find("from com.iserviceglobe.pims.StoresIssueVoucher");


Map parameters = new HashMap();

JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(StoreVoucherList);
JasperReport jasperReport =
(JasperReport)JRLoader.loadObject(reportFile.getPath());
JasperPrint jasperPrint =
JasperManager.fillReport(jasperReport,parameters,ds);

byte[] bytes = null;
JRXlsExporter jasperXlsExportMgr = new JRXlsExporter();
ByteArrayOutputStream xlsReport = new ByteArrayOutputStream();
jasperXlsExportMgr.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
jasperXlsExportMgr.setParameter(JRExporterParameter.OUTPUT_STREAM, xlsReport);


jasperXlsExportMgr.exportReport();
bytes = xlsReport.toByteArray();
response.setContentType("application/xls");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();


please give me solution


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 24, 2007 7:38 am 
Beginner
Beginner

Joined: Thu Aug 04, 2005 5:06 am
Posts: 31
Location: Bedford, UK
This works with Hibernate 3 but should be ok for you:

ByteArrayOutputStream xlsReport = new ByteArrayOutputStream();
InputStream inputStream;
inputStream = new FileInputStream(reportFile.getPath());

JRXlsExporter xlsExporter = new JRXlsExporter();

JasperPrint jasperPrint =
JasperFillManager.fillReport(
inputStream,
params,
new JRBeanCollectionDataSource(StoreVoucherList)
);

xlsExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
xlsExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, xlsReport);
xlsExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
xlsExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
xlsExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
xlsExporter.exportReport();

OutputStream ouputStream = response.getOutputStream();
ouputStream.write(xlsReport.toByteArray());
ouputStream.flush();
ouputStream.close();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.