aspose file tools*
The moose likes JSP and the fly likes Excel spread sheet  (in JSP) display  issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Excel spread sheet  (in JSP) display  issues" Watch "Excel spread sheet  (in JSP) display  issues" New topic
Author

Excel spread sheet (in JSP) display issues

Mike Broad
Greenhorn

Joined: Mar 29, 2007
Posts: 13
subject: Excel spread sheet (in JSP) specific name display issues

Environment: Java, J2EE, MyEclipse, Oracle WebShpere ,Struts framwork

I have few reports and clicking the report executes an action and displays the corresponding report (Action forward).

Before displaying the report it pops up a window (with save/open/cancel buttons). Now the widnow has same name for all the reports (load-reports.xls).
I need to display a specific report name.
I searched the work sapce and ould not find any clue.
Any help will be appreciated, TIA
Mike
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Look up the Content-Disposition response header.
There is sample code that sets this in our JspAndExcel FAQ entry.
There is a link to the JspFaq at the top of this forum.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Mike Broad
Greenhorn

Joined: Mar 29, 2007
Posts: 13
Thank you a lot Ben.
I appreciate your help.
This code in my jsp works fine, has there been only one custom name to display:

<%@ page contentType="application/vnd.ms-excel" autoFlush="true" %>
<% response.setHeader("Content-Disposition", "attachment; filename=\"EmployeeReport.xls\""); %>

But still I am not able to figure out completely.
I know the logic , but need some help.

I have nearly 10 reports and I need to use <c:if ...> tag in my Jsp and display the right report name ( on the Excel file)
Can you pl help me how I can do it in my report.jsp .


// In the ReportAction.execute(.....) method
//I have set the report name as an attribute
....
Report report = new Report ();
String r_name = report. getName(); // EmployeeReport, ?ManagerReport etc

System.out.println ("\n\n rep...name: " + s_r_name + "\n") ;
//outputs the expected name to console
req.setAttribute("reportName", r_name );

I need to retrieve it in jsp and add logic to display specific report name such as EmployeeReport, MangerReport etc

Currently my jsp file has these 6 lines of code code:

<%@ taglib uri="/WEB-INF/rep.tld" prefix="rep" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ page import="com.xyz.report.Report" %>

<%@ page contentType="application/vnd.ms-excel" autoFlush="true" %>
<% response.setHeader("Content-Disposition", "attachment; filename=\"EmployeeReport.xls\""); %>
<rep:displayReport/>

Thanks,
Mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Excel spread sheet (in JSP) display issues