This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Sending an excel file from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sending an excel file from a servlet" Watch "Sending an excel file from a servlet" New topic
Author

Sending an excel file from a servlet

Chris Stewart
Ranch Hand

Joined: Sep 29, 2001
Posts: 124
I'd like to offer up an excel file for users to download from a servlet. I feel like I've seen this done before, but I can't remember how it was done.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Set the content-type and content-disposition headers.
Write either csv data or an html table to the page.
or
Use a 3rd party library such as POI.

There are several threads within the last couple weeks that go into greater detail on this. Do a search here and in the JSP forum on 'Excel' and you'll find plenty of posts.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
quoting from the forum page: My Profile | Register | Search | FAQ | Forum Home


42
Chris Stewart
Ranch Hand

Joined: Sep 29, 2001
Posts: 124
Originally posted by Jeroen Wenting:
quoting from the forum page: My Profile | Register | Search | FAQ | Forum Home


This example is exactly why people hate this place.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Chris Stewart:
This example is exactly why people hate this place.


I'm drifting a bit from the topic here, but I think it's worth saying.
I've been signed up with this forum for less than a month. In that time, I've easily seen over a dozen people ask about sending, parsing, or otherwise working with Excel sheets in Servlets/JSPs -- many within days or hours of each other. I've personally answered this 3 or 4 times.

Seeing that Mr, Wenting has had 3600 posts and has been signed up since Oct of 2000. I think it's safe to say that he has probably seen that same question asked over a hundred times.

Experienced developers get tired of answering the same question over and over. The more experienced they are, the faster they will tire. Some will take the time to write a FAQ. Some, as Mr. Wenting has done will generously take the time to remind the asker that there is a way to search the list for the answer. Most, however, will just leave and not bother anymore.

Just about every list and forum I've ever seen has had a link to this essay:
http://www.catb.org/~esr/faqs/smart-questions.html#translations
including this one. And yet, the majority of questions on every list and forum are questions that have already been asked and answered many times.

If people who don't want to check to see if a question has been answered before asking it hate a given forum and leave, it doesn't hurt the forum. If someone who knows enough to answer the better questions leaves because they've burned out due to the endless repetition caused by the former type, then the forum/list suffers.

Sometimes RTFM, STFW, or GIYF are the best answers.
Chris Stewart
Ranch Hand

Joined: Sep 29, 2001
Posts: 124
Where's the harm in just leaving the thread alone when you have nothing productive to say? Too many people enjoy being rude, esp here.

Ben got the point across the correct way.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
I've answered this question myself at least a dozen times in the last year alone.
At some point it gets extremely repetitive...

Maybe some people don't know there's a search function, in which case pointing it out helps them.

If they do know but are too lazy to use it, why help them at all?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I've posted something at http://faq.javaranch.com/view?SearchFirst - feel free to link to it, or to add to it when you see fit.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Some will take the time to write a FAQ....

Ilja Preuss, is a case in point... ;-)

Thank you.
[ January 15, 2005: Message edited by: Ben Souther ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Originally posted by Ilja Preuss:
I've posted something at http://faq.javaranch.com/view?SearchFirst - feel free to link to it, or to add to it when you see fit.


hmm, java.lang.OutOfMemoryError trying to access the FAQ.
I know there's a lot to remember about Java, but is it really that much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending an excel file from a servlet