This solution doesn't use any third party jar files or tools. The program will just use the Setcontent type and printwriter object , which are key features for the solution.
/** * * The following java program demonstrates a simple way to write the output in to Excel sheets or Spread sheets * */ class Excel_Writing extends HttpServlet { public void doGet (HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { try { //This Type specifies that output is in the Excel format response.setContentType("application/vnd.ms-excel"); PrintWriter out = null; out = response.getWriter(); //Here the file name in which the printwriter is going to write response.setHeader("Content-disposition","attachment;filename=ExcelWriting.xls"); // By using \t or tab makes the printwriter to write in different columns out.print("Name"+"\t"); out.print("Company"+"\t"); //To write in new row out.println(); out.print("Raj"+"\t"); out.print("Java Programming Tutorial"+"\t"); out.println(); out.close(); } catch (Exception e) { System.out.println("Exception in Excel_Writing Class"+e.getMessage()); } } }