title: Exporting HTML table into excel using javascript
body: <p>I have table with 4 columns where every column includes text field and button and at the end of every row consists of edit and delete button. 
  I want to export the table into excel format but when I do the text field and button at the column header and edit and delete button are also getting exported into excel file which I dont want. 
  Can any one tell me where I am making the mistake in javascript, please.</p>
  
  <p>Here is my jquery code which I got it from net (<a href="http://jsfiddle.net/insin/cmewv/" rel="nofollow">http://jsfiddle.net/insin/cmewv/</a>)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var tableToExcel = (function() {
    var uri = 'data:application/vnd.ms-excel;base64,'
      , template = '&lt;html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"&gt;&lt;head&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt;&lt;x:ExcelWorksheet&gt;&lt;x:Name&gt;{worksheet}&lt;/x:Name&gt;&lt;x:WorksheetOptions&gt;&lt;x:DisplayGridlines/&gt;&lt;/x:WorksheetOptions&gt;&lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt;&lt;/x:ExcelWorkbook&gt;&lt;/xml&gt;&lt;![endif]--&gt;&lt;/head&gt;&lt;body&gt;&lt;table&gt;{table}&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;'
      , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
      , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
    return function(table, name) {
      if (!table.nodeType) table = document.getElementById(table)
      var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
      window.location.href = uri + base64(format(template, ctx))
    }
  })()
  &lt;/script&gt; 
  </code></pre>
  
  <p>my HTML code as follows </p>
  
  <pre><code>&lt;TABLE  id="table_id" class="display" align="Center" border="1px" width="80%"&gt;
          &lt;thead&gt;
          &lt;tr&gt;
          &lt;th&gt; &lt;b&gt;User_ID &lt;/th&gt;&lt;/b&gt;
          &lt;form action="SearchId" method="post"&gt;
          &lt;input type="hidden" name="hiddenname" value="hidden_uid" &gt;
          &lt;input type="text" name="uid" id="uid"&gt;
          &lt;input type="submit" value="Search"&gt;
          &lt;/form&gt;
  
          &lt;th&gt;&lt;b&gt;User_Name &lt;/th&gt;&lt;/b&gt;
          &lt;form action="SearchId" method="post"&gt;
          &lt;input type="text" name="uname" id="uname"&gt;
          &lt;input type="hidden" name="hiddenname" value="hidden_uname" &gt;
          &lt;input type="submit"  value="Search"&gt;
          &lt;/form&gt;
  
          &lt;th&gt;&lt;b&gt;Password&lt;/th&gt;&lt;/b&gt;
          &lt;form action="SearchId" method="post"&gt;
          &lt;input type="text" name="pass" id="pass"&gt;
          &lt;input type="hidden" name="hiddenname" value="hidden_pass" &gt;
          &lt;input type="submit" value="Search"&gt;
          &lt;/form&gt;
  
          &lt;th&gt;&lt;b&gt;Designation&lt;/th&gt;&lt;/b&gt;
          &lt;form action="SearchId" method="post"&gt;
          &lt;input type="text" name="desig" id="desig"&gt;
          &lt;input type="hidden" name="hiddenname" value="hidden_desig" &gt;
          &lt;input type="submit" value="Search"&gt;
          &lt;/form&gt;
          &lt;/thead&gt;
  
          &lt;tbody &gt;
          &lt;%Iterator itr;%&gt;
          &lt;%List data=(List) request.getAttribute("UserData");
          for(itr=data.iterator();itr.hasNext();)
          {%&gt;
              &lt;tr&gt;
                  &lt;% String s= (String) itr.next(); %&gt; 
                  &lt;td&gt;&lt;%=s %&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%=itr.next() %&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%=itr.next() %&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%=itr.next() %&gt;&lt;/td&gt;
  
                  &lt;form id="edit" action="EditRecord" method="post" &gt;
                  &lt;td&gt;&lt;input type="hidden" name="hidden_edit" id="edit_id" value="&lt;%=s %&gt;"/&gt; 
                  &lt;input type="submit" id="myButton" value="Edit" name="edit" onclick="toggleVisibility('');"&gt; &lt;/td&gt;
                  &lt;/form&gt;
  
                  &lt;td&gt;&lt;form id="delete" action="DeleteRecord" method="post" &gt;
                  &lt;td&gt;&lt;input type="hidden" name="hidden_delete" id="delete_id" value="&lt;%=s %&gt;"/&gt;
                  &lt;input type="submit" value="delete" name="delete"&gt; &lt;/td&gt;
                  &lt;/form&gt;&lt;/td&gt;    
          &lt;%} %&gt;
              &lt;/tr&gt;   
  
              &lt;/tbody&gt;
      &lt;/TABLE&gt;
  </code></pre>