Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Struts
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Struts 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 November 13th, 2006, 05:50 AM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sunitapandey
Default dynamically generating Excel file

Hi
I want to generate excel file dynamically containing all data which is displayed on jsp page from view objects.
how can i migrate data from jsp page to xl file.
pls help.
An Sample code would help better to understand it.
Thanks in advance.
sunita
 
Old November 23rd, 2006, 12:33 AM
Registered User
 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi, here is the sample code u may try it before that check u having the all api there needed for excel generation ,

Code:
ServletContext context = this.getServlet().getServletConfig().getServletContext();
JasperPrint jasperPrint = JasperFillManager.fillReport(context.getRealPath("/EmpDetails.jasper"),parameters,con);
ByteArrayOutputStream output = new ByteArrayOutputStream();
        OutputStream outputfile= new FileOutputStream(new File(context.getRealPath("/EmpDetails.xls"));
        JRXlsExporter exporterXLS = new JRXlsExporter();
        exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
        exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, output);
        exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
        exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
        exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
        exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
        exporterXLS.exportReport();
        outputfile.write(output.toByteArray());


 
Old November 23rd, 2006, 03:24 AM
Registered User
 
Join Date: Oct 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sparun1607
Default

What is the jar that has to be imported ... for this program

Arun
 
Old November 23rd, 2006, 03:53 AM
Registered User
 
Join Date: Oct 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sparun1607
Default

and where that jar file has to be imported


Arun





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically generating Javascript (XSLT in IE6) einszwei XSLT 1 June 28th, 2007 01:07 PM
Generating ViewState Names Dynamically rfinks VB How-To 3 July 31st, 2006 11:47 AM
Dynamically Generating Textboxes Maxood PHP How-To 6 March 9th, 2006 09:14 AM
Generating html tags dynamically sachin lad Servlets 1 April 26th, 2005 05:35 PM





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