title: Excel .xlsx file not opening after downloading the file from the server in java
body: <p>Here is my sample code. I am using eclipse , tomcat server .Browser as IE9.</p>
  
  <pre><code>protected void service(HttpServletRequest request,
              HttpServletResponse response) throws ServletException, IOException {
  
          response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
  
  
          ServletContext context = request.getServletContext();
          @SuppressWarnings("unchecked")
          List&lt;Student&gt; students = (List&lt;Student&gt;) context.getAttribute("students");
          PrintWriter out = response.getWriter();
          for(Student student:students){
              out.println(student.getId()+"\t"+student.getName());
          }
          out.close();
  
      }
  </code></pre>
  
  <p>I am getting the List of Student. But when i am opening the downloaded file file getting error saying that file format or extention is not valid. My downloaded file is .xlsx .</p>