This is a discussion on Display excel in JSR168 portlet - Websphere ; Hi,
We have a requirement to show search results in excel sheet in portlet window. I tried changing the content type..but it throws IllegalArgumentException because the content type "application/vnd.ms-excel" is not supported.
Is there any other way to show excel ...
We have a requirement to show search results in excel sheet in portlet window. I tried changing the content type..but it throws IllegalArgumentException because the content type "application/vnd.ms-excel" is not supported.
Is there any other way to show excel in portlet? Even if it can show open/save dialog, it should be ok.
Thanks
Naveen
Re: Display excel in JSR168 portlet
You can't output binary data of any kind in a portlet. All portlet
output must be the primary output type for the device you are using.
For example, text/html.
To accomplish what you want to do, you will need to either put the excel
data in a file on the filesystem or serve it up through a servlet either
packaged with your portlet or somewhere else on your server.
Then, in the portlet output, write markup that causes the browser to
access the servlet/file to display the data. For example, in an
Re: Display excel in JSR168 portlet
Hi Naveen,
Follow the steps given below:
1. Create a ExportExcelServlet under some package in your Portlet project.
try {
op = response.getOutputStream();
op.write(data.getBytes());
op.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Inside the getData you will create a string buffer...
StringBuffer sb = new StringBuffer();
sb.append("Name,Email,Phone");
sb.append(System.getProperty("line.separator"));
sb.append("Naveen,naveen@ibm.com,111-111-111");
2. Incude the code below in ur jsp..
And you are done....Lemme know if you have any other question..
Aman.
> Hi,
>
> We have a requirement to show search results in excel
> sheet in portlet window. I tried changing the content
> type..but it throws IllegalArgumentException because
> the content type "application/vnd.ms-excel" is not
> supported.
>
> Is there any other way to show excel in portlet? Even
> if it can show open/save dialog, it should be ok.
>
> Thanks
> Naveen
Re: Display excel in JSR168 portlet
Hi All,
Thank you for your suggestions.
I tried something similar to that. I didn't store the file in filesystem.
I am using Apache POI to create excel. So in servlet i just wrote the workbook to the ServletOutputStream.
Thanks
Naveen
Re: Display excel in JSR168 portlet
Naveen...
Hi... I am looking to solve a similar type of problem to the one which you solved; however, with mine, I must connect to an MS Excel workbook which, when opened through MS Excel, interacts live with a TM1 cube. This is how financial analysts are viewing data within TM1.
The way in which I would like to achive this is by way of a portlet so that these users, instead of having to use TM1 to view, slide and dice their data, go through Cognos's portal and view it from there.
Will you be able to share what you did in your case to see if I may be able to integrate it? I will gladly appreciate it.