title: Export to Excel - JSP Page
body: <p>I have a simple table which I would like to export to an Excel file on click of a button.</p>
  
  <p>I wrote a function in JavaScript, but I am not sure what is going wrong.</p>
  
  <pre><code>function CreateExcelSheet()
  {
      var x=myTable.rows
      var xls = new ActiveXObject("Excel.Application")
      xls.visible = true
      xls.Workbooks.Add
      for (i = 0; i &lt; x.length; i++)
      {
          var y = x[i].cells
          for (j = 0; j &lt; y.length; j++)
          {
              xls.Cells( i+1, j+1).Value = y[j].innerText
          }
      }
  }
  </code></pre>
  
  <p>This is the button on the JSP page:</p>
  
  <pre><code>&lt;/table&gt;
      &lt;input type="button" onclick="CreateExcelSheet()" value="Export"&gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>It used to work earlier but it is not working now. Is there any other way to do this?</p>