bootstrap4.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>HTML table Export</title>
  6. <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
  7. <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
  8. <script src="https://unpkg.com/bootstrap-table@1.18.3/dist/bootstrap-table.min.js"></script>
  9. <script src="https://unpkg.com/bootstrap-table@1.18.3/dist/extensions/export/bootstrap-table-export.js"></script>
  10. <script src="https://unpkg.com/bootstrap-table@1.18.3/dist/extensions/toolbar/bootstrap-table-toolbar.js"></script>
  11. <script type="text/javascript" src="../libs/FileSaver/FileSaver.min.js"></script>
  12. <script type="text/javascript" src="../libs/js-xlsx/xlsx.core.min.js"></script>
  13. <script type="text/javascript" src="../libs/jsPDF/jspdf.umd.min.js"></script>
  14. <script type="text/javascript" src="../tableExport.js"></script>
  15. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  16. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
  17. <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.18.3/dist/bootstrap-table.min.css">
  18. <script type="text/javaScript">
  19. function detailFormatter(index, row) {
  20. var html = [];
  21. $.each(row, function (key, value) {
  22. html.push('<p><b>' + key + ':</b> ' + value + '</p>');
  23. });
  24. return html.join('');
  25. }
  26. </script>
  27. </head>
  28. <body>
  29. <a href="#" onclick="$('#table1,#table2').tableExport({type:'excel',
  30. mso: {
  31. fileFormat:'xmlss',
  32. worksheetName: ['Table 1','Table 2']
  33. },
  34. ignoreColumn: [0, 'checkbox']
  35. });">
  36. <br>&nbsp;<b>Click to export to Excel ('xmlss' = XML Spreadsheet 2003 file format)</b>
  37. </a>
  38. <a href="#" onclick="$('#table1').tableExport({type:'excel',
  39. mso: {
  40. fileFormat:'xlsx'
  41. },
  42. ignoreColumn: [0, 'checkbox']
  43. });">
  44. <br>&nbsp;<b>Click to export to Excel ('xlsx' = Excel 2007 Office Open XML format)</b>
  45. </a>
  46. <a href="#" onclick="$('#table1').tableExport({type: 'pdf',
  47. jspdf: {orientation: 'l',
  48. margins: {right: 10, left: 10, top: 40, bottom: 40},
  49. autotable: {tableWidth: 'auto'}}});">
  50. <br>&nbsp;<b>Click to export to PDF (jsPDF / jsPDF-AutoTable)</b>
  51. </a>
  52. <div class="container">
  53. <h1 align="center">Data</h1><br>
  54. <table id="table1"
  55. data-toggle="table"
  56. data-height="600"
  57. data-show-toggle="true"
  58. data-show-columns="true"
  59. data-click-to-select="true"
  60. data-detail-view="true"
  61. data-detail-formatter="detailFormatter"
  62. data-url="tableExport.json">
  63. <thead>
  64. <tr>
  65. <th data-field="checkbox" data-checkbox="true" > </th>
  66. <th data-field="Rank" data-sortable="true" data-filter-control="select" data-visible="true" >Rank </th>
  67. <th data-field="Flag" data-sortable="true" data-filter-control="input" data-visible="false" >Flag </th>
  68. <th data-field="Country" data-sortable="true" data-filter-control="select" data-visible="true" >Country </th>
  69. <th data-field="Population" data-sortable="true" data-filter-control="select" data-visible="false" >Population </th>
  70. <th data-field="Date" data-sortable="true" data-filter-control="select" data-visible="true" >Date </th>
  71. <th data-field="p_of_world" data-sortable="true" data-filter-control="select" data-visible="false" >% of world </th>
  72. <th data-field="Language" data-sortable="true" data-filter-control="select" data-visible="true" >Language </th>
  73. </tr>
  74. </thead>
  75. </table>
  76. <br><br>
  77. <table id="table2"
  78. data-toggle="table"
  79. data-pagination="false"
  80. data-detail-view="true"
  81. data-url="bootstrap3.json">
  82. <thead>
  83. <tr>
  84. <th data-field="col1" data-sortable="true">Col 1</th>
  85. <th data-field="col2" data-sortable="true">Col 2</th>
  86. </tr>
  87. </thead>
  88. </table>
  89. </div>
  90. </body>
  91. </html>