Export HTML INTO EXCEL USING JAVASCRIPT





                 HOW TO MAKE EXCEL USING JAVASCRIPT AND JQUERY

                                                                       CODE HERE:

 <table align="center" border="1px" cellpadding="12px" cellspacing="0px" id="my-table-id"><tbody>
<tr><td>My Text 1</td>
  <td><input placeholder=" Enter Some Text Here For Excel Input" type="text" /></td>
 </tr>
<tr>
  <td>My Text 2</td>
  <td><input placeholder=" Enter Some Text Here For Excel Input" type="text" /></td>
 </tr>
<tr>

  <td align="center" colspan="2px"><span style="background-color: #6fa8dc; color: #38761d;"><input onclick="ETEDAMAN()" type="button" value="Click to Download" /></span></td>
 </tr>
</tbody></table> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript"> function ETEDAMAN(mytblId){ var data =[]; $("#my-table-id td:not(:last)").each(function(index){ var input= $(this).find("input[type='text']"); (input.length) ? data.push(input.val(),"\n") : data.push($(this).text(),"\t") }); window.open('data:application/vnd.ms-excel,' + encodeURIComponent(data.join(""))); } </script>

DEMO
My Text 1
My Text 2

2 Comments

  1. Hi,
    This code does not work in IE. Please can you suggest a way to make it work in IE.

    ReplyDelete