javascript - datatables export to excel <select option> -
in test page have insert option list , need export excel selected value, excel result include list of "select option".
my code:
<!doctype html> <html> <head> <title>test export excel "select option" </title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <script src="https://code.jquery.com/jquery-1.12.3.js"></script> <script src="https://cdn.datatables.net/1.10.12/js/jquery.datatables.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.2.1/js/datatables.buttons.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script> <script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script> <script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script> <script src="https://cdn.datatables.net/buttons/1.2.1/js/buttons.html5.min.js"></script> <link href="https://cdn.datatables.net/1.10.12/css/jquery.datatables.min.css" rel="stylesheet" type="text/css"> <link href="https://cdn.datatables.net/buttons/1.2.1/css/buttons.datatables.min.css" rel="stylesheet" type="text/css"> <script> $(document).ready(function() { $('#example').datatable( { dom: 'bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf' ] } ); } ); </script> <div> <table id="example" class="display" cellspacing="0" border="1" width="100%"> <thead> <tr> <th>name</th> <th>position</th> <th>office</th> <th>age</th> <th>start date</th> <th>salary</th> </tr> </thead> <tbody> <tr> <td>tiger nixon</td> <td>system architect</td> <td><select class="form-control"> <option value="edinburgh" selected>edinburgh</option> <option value="singapore" >singapore</option> <option value="tokyo" >tokyo </option> </select> </td> <td>61</td> <td>2011/04/25</td> <td>$320,800</td> </tr> <tr> <td>garrett winters</td> <td>accountant</td> <td><select class="form-control"> <option value="edinburgh" >edinburgh</option> <option value="singapore" >singapore</option> <option value="tokyo" selected>tokyo </option> </select> </td> <td>63</td> <td>2011/07/25</td> <td>$170,750</td> </tr> <tr> <td>ashton cox</td> <td>junior technical author</td> <td><select class="form-control"> <option value="edinburgh" >edinburgh</option> <option value="singapore" >singapore</option> <option value="tokyo" selected>tokyo </option> </select> </td> <td>66</td> <td>2009/01/12</td> <td>$86,000</td> </tr> <tr> <td>shad decker</td> <td>regional director</td> <td><select class="form-control"> <option value="edinburgh" >edinburgh</option> <option value="singapore" selected>singapore</option> <option value="tokyo" >tokyo </option> </select> </td> <td>51</td> <td>2008/11/13</td> <td>$183,000</td> </tr> <tr> <td>michael bruce</td> <td>javascript developer</td> <td><select class="form-control"> <option value="edinburgh" selected>edinburgh</option> <option value="singapore" >singapore</option> <option value="tokyo" >tokyo </option> </select> </td> <td>29</td> <td>2011/06/27</td> <td>$183,000</td> </tr> <tr> <td>donna snider</td> <td>customer support</td> <td><select class="form-control"> <option value="edinburgh" >edinburgh</option> <option value="singapore" selected>singapore</option> <option value="tokyo" >tokyo </option> </select> </td> <td>27</td> <td>2011/01/25</td> <td>$112,000</td> </tr> </tbody> </table> </div> </body> </html>
the result exporting in excel ok except "office" column ("c") containing values in option list (edinburgh, singapore, tokyo). export excel result
Comments
Post a Comment