Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2011, 07:36 AM
Registered User
 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exel Repoert not crating

Hi All.

In Our Project we r using Jasper to generate report in the Xls, we are supposed to use jasperreports-3.5.3 and poi 3.5... but Xls is not generating and even server is not throwing any exception...

Pls help on this..

below is my code snippet



try{
LightDatabaseManager dbManager = new LightDatabaseManager(this);
JasperReport jasperReport = (JasperReport) JRLoader.loadObjectFromLocation(
reportDetail.getFilePath());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameterMap,
dbManager.getConnection());
exportToFile(reportDetail, jasperPrint);
}
catch(Exception e){
e.printStackTrace();
logger.error("XXXXXXXXXXXX"+e);
}




private void exportToFile(NBReportConfigLEnum reportDetail, JasperPrint jasperPrint)
throws JRException{
logger.debug("...................................I nside exportToFile.............");
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
switch(reportDetail.getFileResponse()){
case PDF:
JasperExportManager.exportReportToPdfStream(jasper Print, baos);
servletResponse.setContentLength(baos.size());
setInputStream(new ByteArrayInputStream(baos.toByteArray()));
break;
case XLS:
logger.debug(".....Inside XLS......");
JRXlsExporter exporterXLS = new JRXlsExporter();
logger.debug(".....exporterXLS......"+exporterXLS) ;
exporterXLS.setParameter(JRXlsExporterParameter.JA SPER_PRINT, jasperPrint);
logger.debug(".....After JASPER_PRINT......");
exporterXLS.setParameter(JRXlsExporterParameter.OU TPUT_STREAM, baos);
logger.debug(".....After OUTPUT_STREAM......");
exporterXLS.setParameter(JRXlsExporterParameter.IS _ONE_PAGE_PER_SHEET,
Boolean.FALSE);
logger.debug(".....After IS_ONE_PAGE_PER_SHEET......");
exporterXLS.setParameter(JRXlsExporterParameter.IS _DETECT_CELL_TYPE,
Boolean.TRUE);
logger.debug(".....After IS_DETECT_CELL_TYPE......");
exporterXLS.setParameter(JRXlsExporterParameter.IS _WHITE_PAGE_BACKGROUND,
Boolean.FALSE);
logger.debug(".....After IS_WHITE_PAGE_BACKGROUND......");
exporterXLS.setParameter(JRXlsExporterParameter.IS _REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
Boolean.TRUE);
logger.debug(".....After IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS......");

try {
logger.debug(".....Inside exportReport block......");
exporterXLS.exportReport(); logger.debug(".....After exportReport......");
}catch(Exception ex) {
logger.error("Exception in exportReport() ::: "+ex);
ex.printStackTrace();
}

try {
servletResponse.setContentLength(baos.size());
servletResponse.setContentType("application/vnd.ms-excel");
setInputStream(new ByteArrayInputStream(baos.toByteArray()));
}catch(Exception ex) {
logger.error("Exception when setting servletResponce in exportToFile() :::"+ex);
ex.printStackTrace();
}
break;
default:
break;
}
}
catch(Exception e){
e.printStackTrace();

}
}
}


exporterXLS.exportReport() is invoking but it's not throwing any exception and not generating any Xls..

Last edited by kusha85; May 10th, 2011 at 07:53 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Exel to XML karephul XML 2 June 14th, 2006 03:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.