How to export data to Excel form a portlet?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > WebSphere > WebSphere Portal Server > How to export data to Excel form a portlet?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    How to export data to Excel form a portlet?  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-24-07 12:51 PM

Hello

I need to develop a portlet from which I can export data to Excel. The data 
keept in a HashMap are presented  in a table format, when portlet in VIEW mo
de. When pressing an "Export" button I would like to be presented with a pop
up  asking if I want to Ope
n / Save the Excel file or Cancel the operation.

The Java code I am using in a JSP is :

<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>

<%

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition",
"attachment; filename=tabella11.xls");
// attachment - since we don't want to open
// it in the browser, but
// with MS-Excel, and set the
// default file name to use.
response.setHeader("CacheControl", "no-cache");
response.setHeader("pragma","no-cache");
response.setHeader("Expires","-1");

StringBuffer recordString = new StringBuffer();
recordString.append("<HTML><body><table>");
recordString.append("<tr><td>hello</td></tr>");
recordString.append("</table>");
String str = recordString.toString();

PrintWriter pw=response.getWriter();
pw.println(str);
%>

But unfortunatelly I get an exception:

2007.01.23 16:03:50.906 E com.ibm.wps.services.dispatcher.DispatcherServiceI
mpl handleRequest
java.lang.IllegalStateException: Writer already obtained

Can anyone help me please with some piece of code or an workaround for solvi
ng this issue?


Thanks in advance.


Otilia







[ Post a follow-up to this message ]



    Re: How to export data to Excel form a portlet?  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-24-07 06:17 PM

You should build a servlet for this. You can create a servlet in your portle
t application.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:24 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register