|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
excel
Hi,
I need to open an Excel (csv file) in an excel spreadsheet and shown in a browser when clicked on a link.. can anyone pl provide suggestions?? TIA, sands |
|
#2
|
||||
|
||||
|
Use a jsp to set proper MIME type and it will open Excel as a plugin.
Take a look at this php example http://www.judas-price.de/scripts/mysql2xls.dhtml
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
|
#3
|
|||
|
|||
|
hi ,
i tried response.setContentType("application/vnd.ms-excel"); and when I dump some text within the file it does open it in an excel spreadsheet but am unable to make it work with a file stored in the oracle DB.. any suggestions?? TIA, gaucho |
|
#4
|
||||
|
||||
|
Why didn't you look at the example provided?
After setting mime type you have to read the file and send it to browser. |
|
#5
|
||||
|
||||
|
You can find a java example here http://www.jguru.com/faq/view.jsp?EID=502939
full of errors, at leastpublic class DownloadServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) |
|
#6
|
||||
|
||||
|
This works, even if not perfectly, on my Win98se+Tomcat+JDK1.3.1_2 PC
[java] import java.io.*; import javax.servlet.http.*; import javax.servlet.*; public class DownloadServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int length; byte[] buf = new byte[1024]; BufferedInputStream in = new BufferedInputStream(new FileInputStream("C:\\LPServer\\jakarta-tomcat-3.2.3\\webapps\\ROOT\\test.csv")); ServletOutputStream out = response.getOutputStream(); response.setContentType("x-application/vnd.ms-excel"); //response.setContentLength(size); // see http://www.faqs.org/rfcs/rfc1806.html response.addHeader("Content-Disposition", "inline; filename=\" test.csv "\""); // copy data while ((in != null) && ((length = in.read(buf)) != -1)) { out.write(buf, 0, length); } } } [/java] Adapted from the example before. I'll work out a better option later! |
|
#7
|
|||
|
|||
|
got it to work finally..
<% String a ="Content-type: "; response.setContentType(contype); long index = 1; while(index < doc.length()){ response.getOutputStream().write(doc.getBytes(index,100)); index+=100; } %> PHP is far easier and simpler... and outputting BLOB is pretty different too!! |
|
#8
|
||||
|
||||
|
OK, I'm just playing around with your original question, and came out with this, using SQL should be more flexible:
Quote:
It reads a file like pippo,pluto,minnie,topolino we,12,12,12 12,we,12,12 where first row is like column names. Your opinion? Thanks in advance |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > excel |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|