title: what is equivalent for PdfWriter.getInstance(document,response.getOutputStream()); to excel
body: <p>I have an option to export the data to PDF, the code is listed below : </p>
  
  <pre><code>  response.setHeader("Content-disposition", "attachment; filename=\"" + title + ".pdf\"");
    PdfWriter.getInstance(document,response.getOutputStream());
  </code></pre>
  
  <p>what is the equivalent option to export <code>Excel</code> file like <code>PdfWriter.getInstance(document,response.getOutputStream());</code></p>
  
  <p>also below code is perfect to perform download but it fails to open the <code>PDF</code> file when i give open with option.</p>
  
  <p>how to go about.</p>
  
  <p>UPDATE :</p>
  
  <p>this is the code that i use to genarate and export the PDF file, same way is there any way to do for excel file ?</p>
  
  <pre><code>if(exportTo.equals("pdf"))
          {
          response.setHeader("Content-disposition", "attachment; filename=\"" + title + ".pdf\"");
          response.setContentType("application/pdf");
          PdfWriter.getInstance(document,response.getOutputStream());
  
          try {
              document.open();
              addTitlePage(document, "Employee Report Details");
  
             /* Image image = Image.getInstance(path+"images/abi.png");
              image.setAbsolutePosition(40f, 770f);
              image.scaleAbsolute(70f, 50f);
              document.add(image);*/
  
              Map headerMap = new LinkedHashMap();
              headerMap = custDAO.getHeader(query);
  
              float[] colsWidth = {1.5f,3f,4f,4f,2f};
              PdfPTable table = new PdfPTable(colsWidth);
              table.setWidthPercentage(98);
              table.setHorizontalAlignment(Element.ALIGN_CENTER);
  
              PdfPCell c1 = new PdfPCell();
              for (Iterator it = headerMap.keySet().iterator(); it.hasNext();) {
                  String headerName = (String) headerMap.get(it.next());
                  c1 = new PdfPCell(new Phrase(headerName, headerFont));
                  c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
                  table.addCell(c1);
              }
              table.setHeaderRows(1);
              table = custDAO.creadPDFTable(query, table);
              document.add(table);
              document.close();
          } catch (Exception ex) {
              ex.printStackTrace();
          }
          }
  </code></pre>
  
  <p>Regards</p>