Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Open Excel file from JSP page.

 
Sheetal Patil
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am using POI API to create Excel file to export JSP page data. I am able to create file but if I click on a link to open the file it shows some garbage data in browser. Can anyone please help me to solve this problem asap.

Thanks in advance,

Sheetal
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP is a poor technology choice for delivering such data. You should be serving such data from a servlet. It may be that you're not creating the data correctly, or it may be that the JSP mechansism, which assume that you are delivering text data such as HTML pages, is getting in your way.
[ September 12, 2005: Message edited by: Bear Bibeault ]
 
Sheetal Patil
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Actually I am getting data from Bean which I displays on my JSP Page. I want to export that bean data to excel. I am using poi api to create excel file in JSP. I am able to create that. But the problem is I have one lonk to export data which should open that excel file. But I can't open that file.

Thanks
Sheetal
 
Vikas Bhatia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sheetal Patil:
Hi

Actually I am getting data from Bean which I displays on my JSP Page. I want to export that bean data to excel. I am using poi api to create excel file in JSP. I am able to create that. But the problem is I have one lonk to export data which should open that excel file. But I can't open that file.

Thanks
Sheetal



It almost looks like that the content-type is not being set properly? Would you mind sharing the code?
 
babu hiran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is how an excel sheet can be done in jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Comparing Apples and Oranges</TITLE>
<LINK REL=STYLESHEET
HREF="JSP-Styles.css"
TYPE="text/css">
</HEAD>
<BODY>
<CENTER>
<H2>Comparing Apples and Oranges</H2>
<%
String format = request.getParameter("format");
if ((format != null) && (format.equals("excel"))) {
response.setContentType("application/vnd.ms-excel");
}
%>
<TABLE BORDER=1>
<TR><TH></TH><TH>Apples<TH>Oranges
<TR><TH>First Quarter<TD>2307<TD>4706
<TR><TH>Second Quarter<TD>2982<TD>5104
<TR><TH>Third Quarter<TD>3011<TD>5220
<TR><TH>Fourth Quarter<TD>3055<TD>5287
</TABLE>
</CENTER>
</BODY>
</HTML>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
narayana,

Sheetal mentioned earlier in the thread that he's using POI to build a file in MS-Excel format which he plans on streaming to the browser.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic