The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
May 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Re: Creating Excel in a servlet

Posted by Andreas on October 27, 2000 at 3:58 AM

> Hi, i just want to ask how can i create an excel file in java servlets? i have found one but it uses VJ++.
> thanks

Sorry, the posting didn't have the expected result. The listing I've
transmitted was different.

I'll try it again.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class xls extends HttpServlet {

public void doGet( HttpServletRequest request,
HttpServletResponse response)
throws IOException,
ServletException
{

StringBuffer result = new StringBuffer();

response.setContentType(\"application/vnd.ms-excel\");

//response.setContentType(\"text/html\");

PrintWriter out = response.getWriter();

result.append(\"\");
result.append(\"\");
result.append(\"\");
result.append(\"\");

result.append(\"

\");
result.append(\"\");
result.append(\"\");

result.append(\"

\");
result.append(\"\");
result.append(\"\");

result.append(\"

\");
result.append(\"\");
result.append(\"\");

result.append(\"

IDKundeADatumASumme
1Maier4.1.99200,12
2M�ller03.10.20002000
3Meckes22.12.1989400.60
\");

out.println( result.toString() );

}
}



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us