title: Generate excel sheet from html tables using jquery
body: <p>I wanted to generate an excel sheet once a user clicks on a button . Basically i want to do exactly what is dicussed here </p>
  
  <p><a href="https://stackoverflow.com/questions/6517106/how-to-pass-html-table-values-to-excel-sheet-cells">how to pass html table values to excel sheet cells</a>
  (Kalle H. Väravas answer ) </p>
  
  <p><a href="https://stackoverflow.com/questions/5401351/javascript-to-export-html-tables-to-excel?rq=1">JavaScript to export HTML tables to Excel</a></p>
  
  <p>But somehow nothing happens when i click on the button . I am using Mozilla browser . My code needs ActiveXObject enabled . DO i need to do something extra to get it done . ? </p>
  
  <p>I created this fiddle for testing . If this works i will try out my real code . if this works for you then also please let me know . Thanks </p>
  
  <p><a href="http://jsfiddle.net/LBDwP/1/" rel="nofollow noreferrer">jFiddle</a> </p>
  
  <p>Code : </p>
  
  <p>JS : </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function CreateExcelSheet() {
          var i, j, str,
                  myTable = document.getElementById('mytable'),
                  rowCount = myTable.rows.length,
                  excel = new ActiveXObject('Excel.Application');// Activates Excel
          excel.Workbooks.Add(); // Opens a new Workbook
          excel.Application.Visible = true; // Shows Excel on the screen
          for (i = 0; i &lt; rowCount; i++) {
              for (j = 0; j &lt; myTable.rows[i].cells.length; j++) {
                  str = myTable.rows[i].cells[j].innerText;
                  excel.ActiveSheet.Cells(i + 1, j + 1).Value = str; // Writes to the sheet
              }
          }
          return;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Html : </p>
  
  <pre><code>&lt;table id ="myTable" &gt;
              &lt;tr&gt;
                  &lt;td&gt;1&lt;/td&gt;
                  &lt;td&gt;Jan&lt;/td&gt;
                  &lt;td&gt;01/04/2012&lt;/td&gt;
                  &lt;td&gt;Approved&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;2&lt;/td&gt;
                  &lt;td&gt;Feb&lt;/td&gt;
                  &lt;td&gt;01/04/2012&lt;/td&gt;
                  &lt;td&gt;Approved&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;form&gt;
              &lt;input type="button" onclick="CreateExcelSheet();" value="Create Excel Sheet" &gt;
          &lt;/form&gt;
  </code></pre>