uploadExcel.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. <?php
  2. include($_SERVER['DOCUMENT_ROOT']."/Authorization/script/php/permission/check_right.php");
  3. if (!isset($_FILES['excel']['error'])) {
  4. //header("Location: /DataBase/Upload.php");
  5. }
  6. if (0 < $_FILES['excel']['error']) {
  7. echo 'Error: ' . $_FILES['excel']['error'] . '<br>';
  8. } else {
  9. $filepath = 'uploads/' . $_FILES['excel']['name'];
  10. move_uploaded_file($_FILES['excel']['tmp_name'], $filepath);
  11. $project_id = $_POST['projectId'];
  12. $project_name = $_POST['projectName'];
  13. $category_id = $_POST['category'];
  14. $file = $_FILES['excel']['name'];
  15. }
  16. ?>
  17. <!doctype html>
  18. <html class="fixed">
  19. <head>
  20. <!-- Basic -->
  21. <meta charset="UTF-8">
  22. <title>設計資料庫匯入工具</title>
  23. <meta name="keywords" content="HTML5 Admin Template" />
  24. <meta name="description" content="JSOFT Admin - Responsive HTML5 Template">
  25. <meta name="author" content="JSOFT.net">
  26. <script src="/DataBase/assets/vendor/jquery/jquery.js"></script>
  27. <script src="/Common/script/js/user-image.js"></script>
  28. <!-- Mobile Metas -->
  29. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  30. <!-- Web Fonts -->
  31. <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
  32. <!-- jstree CSS -->
  33. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/themes/default/style.min.css">
  34. <!-- Vendor CSS -->
  35. <link rel="stylesheet" href="/DataBase/assets/vendor/bootstrap/css/bootstrap.css" />
  36. <link rel="stylesheet" href="/DataBase/assets/vendor/font-awesome/css/font-awesome.css" />
  37. <link rel="stylesheet" href="/DataBase/assets/vendor/magnific-popup/magnific-popup.css" />
  38. <link rel="stylesheet" href="/DataBase/assets/vendor/bootstrap-datepicker/css/datepicker3.css" />
  39. <link rel="stylesheet" href="/DataBase/assets/vendor/pnotify/pnotify.custom.css" />
  40. <!-- Specific Page Vendor CSS -->
  41. <link rel="stylesheet" href="/DataBase/assets/vendor/jquery-ui/css/ui-lightness/jquery-ui-1.10.4.custom.css" />
  42. <link rel="stylesheet" href="/DataBase/assets/vendor/bootstrap-multiselect/bootstrap-multiselect.css" />
  43. <link rel="stylesheet" href="/DataBase/assets/vendor/morris/morris.css" />
  44. <link rel="stylesheet" href="/DataBase/assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.css" />
  45. <!-- Theme CSS -->
  46. <link rel="stylesheet" href="/DataBase/assets/stylesheets/theme.css" />
  47. <!-- Skin CSS -->
  48. <link rel="stylesheet" href="/DataBase/assets/stylesheets/skins/default.css" />
  49. <!-- Theme Custom CSS -->
  50. <link rel="stylesheet" href="/DataBase/assets/stylesheets/theme-custom.css">
  51. <!-- Head Libs -->
  52. <script src="/DataBase/assets/vendor/modernizr/modernizr.js"></script>
  53. <!-- chart.js -->
  54. <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  55. <!-- DataTable -->
  56. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">
  57. <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
  58. <!-- Icon -->
  59. <link rel="shortcut icon" href="/DataBase/assets/images/favicon.ico" />
  60. <link href="https://js.arcgis.com/4.21/esri/themes/light/main.css" rel="stylesheet">
  61. <link href="/DataBase/CustomCSS/main.css" rel="stylesheet">
  62. <script src="/DataBase/script/js/bootstrap.js"></script>
  63. <script src="/DataBase/script/js/pdfobject.min.js"></script>
  64. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/jstree.min.js"></script>
  65. <script src="https://js.arcgis.com/4.21/"></script>
  66. <style>
  67. body {
  68. color: #000;
  69. }
  70. .row {
  71. margin-top: -15px;
  72. }
  73. .page-header>ul {
  74. list-style: none;
  75. padding: 0;
  76. margin: 0;
  77. }
  78. .page-header>ul>li {
  79. display: inline-block;
  80. font-size: 25px;
  81. color: #FFFFFF;
  82. }
  83. .page-header>ul>li.right {
  84. float: right;
  85. padding-right: 10px;
  86. }
  87. .input-search {
  88. margin-top: 8px;
  89. }
  90. .page-header li>label {
  91. margin-top: 13px;
  92. border-bottom: 4px solid #0088cc;
  93. height: 41px;
  94. padding-left: 40px;
  95. }
  96. .sidebar-left {
  97. box-shadow: 0 0 0;
  98. }
  99. .jstree-default .jstree-icon {
  100. color: #ffe693;
  101. }
  102. .jqsfield {
  103. color: white;
  104. font: 10px arial, san serif;
  105. text-align: left;
  106. }
  107. .jstree-anchor {
  108. width: 250px;
  109. text-overflow: ellipsis;
  110. overflow: hidden;
  111. white-space: nowrap;
  112. }
  113. .jstree-anchor,
  114. .jstree-anchor:link,
  115. .jstree-anchor:visited,
  116. .jstree-anchor:hover,
  117. .jstree-anchor:active {
  118. color: #abb4be;
  119. }
  120. td,
  121. th {
  122. text-align: center;
  123. }
  124. #tablepage匯入資訊>thead>tr>th {
  125. width: 25%;
  126. }
  127. #tableform>thead>tr>th {
  128. width: 50%;
  129. }
  130. .nav-main {
  131. padding: 15px;
  132. }
  133. .node-hidden {
  134. display: none;
  135. }
  136. html.fixed .page-header {
  137. left: 0px;
  138. }
  139. html.fixed .content-body {
  140. margin-left: 0px;
  141. }
  142. .sidebar-left {
  143. width: 0px;
  144. }
  145. #viewDiv {
  146. height: 100%;
  147. width: 100%;
  148. }
  149. #zoom {
  150. margin-bottom: 5px;
  151. }
  152. #actions {
  153. padding: 5px;
  154. }
  155. .container {
  156. height: 50%;
  157. width: 100%;
  158. }
  159. #createSlideDiv {
  160. background-color: white;
  161. opacity: 0.9;
  162. color: black;
  163. padding: 6px;
  164. }
  165. #slidesDiv {
  166. background-color: white;
  167. opacity: 0.9;
  168. color: black;
  169. padding: 10px;
  170. visibility: hidden;
  171. bottom: 20px;
  172. overflow-y: auto;
  173. text-align: center;
  174. height: 260px;
  175. }
  176. #slidesDiv .slide {
  177. /* Show cursor as pointer when on a slide */
  178. cursor: pointer;
  179. margin-bottom: 6px;
  180. }
  181. #slidesDiv .slide .title {
  182. /* Center the title text */
  183. text-align: center;
  184. }
  185. /* Draw active slide with a nice border around the thumbnail */
  186. #slidesDiv .slide.active img {
  187. box-shadow: 0px 0px 12px black;
  188. border-style: solid;
  189. border-width: thin;
  190. border-color: black;
  191. }
  192. .pdfobject-container {
  193. height: 730px;
  194. }
  195. #topbar {
  196. background: #fff;
  197. padding: 10px;
  198. }
  199. /* uploadExcel */
  200. td>label {
  201. width: 8em;
  202. text-align: left;
  203. padding-right: 0.5em;
  204. /* display: inline-block; */
  205. }
  206. .excel {
  207. font-family: Arial, Helvetica, sans-serif;
  208. border-collapse: collapse;
  209. width: 100%;
  210. }
  211. .nav-tabs>li.active>a,
  212. .nav-tabs>li.active>a:focus,
  213. .nav-tabs>li.active>a:hover {
  214. border: 1px solid #000;
  215. }
  216. .excel td,
  217. .excel th {
  218. border: 1px solid #aaa;
  219. padding: 8px;
  220. }
  221. .excel tr:nth-child(even) {
  222. background-color: #f2f2f2;
  223. }
  224. .excel tr:hover {
  225. background-color: #ddd;
  226. }
  227. .excel th {
  228. padding-top: 12px;
  229. padding-bottom: 12px;
  230. text-align: center;
  231. background-color: #004B7C;
  232. color: white;
  233. }
  234. table.dataTable tbody tr td.NullClass {
  235. background-color: #ed9c28;
  236. }
  237. table.dataTable tbody tr td.ErrorClass {
  238. background-color: #d2322d;
  239. }
  240. .submit {
  241. display: inline-block;
  242. margin-left: auto;
  243. margin-right: auto;
  244. width: 20%;
  245. background-color: #004B7C;
  246. border: none;
  247. color: white;
  248. padding: 15px 32px;
  249. text-align: center;
  250. text-decoration: none;
  251. font-size: 16px;
  252. margin: 10px;
  253. }
  254. .delete {
  255. background-color: red;
  256. border: none;
  257. color: white;
  258. padding: 5px 32px;
  259. text-align: center;
  260. text-decoration: none;
  261. display: inline-block;
  262. font-size: 16px;
  263. }
  264. .center {
  265. text-align: center;
  266. }
  267. .nav-tabs.nav-justified li.active a.error.text-center,
  268. a.error.text-center:hover {
  269. border-bottom-color: transparent;
  270. border-top: 3px solid #d2322d;
  271. box-shadow: none;
  272. color: #d2322d;
  273. }
  274. a.error.text-center,
  275. i.error,
  276. td.error {
  277. color: #d2322d;
  278. }
  279. .nav-tabs.nav-justified li.active a.warning.text-center,
  280. a.warning.text-center:hover {
  281. border-bottom-color: transparent;
  282. border-top: 3px solid #ed9c28;
  283. box-shadow: none;
  284. color: #ed9c28;
  285. }
  286. a.warning.text-center,
  287. i.warning,
  288. td.warning {
  289. color: #ed9c28;
  290. }
  291. .nav-tabs.nav-justified li.active a.info.text-center,
  292. a.info.text-center:hover {
  293. border-bottom-color: transparent;
  294. border-top: 3px solid #0088cc;
  295. box-shadow: none;
  296. color: #0088cc;
  297. }
  298. a.info.text-center,
  299. i.info {
  300. color: #0088cc;
  301. }
  302. .nav-tabs.nav-justified li.active a.success.text-center,
  303. a.success.text-center:hover {
  304. border-bottom-color: transparent;
  305. border-top: 3px solid #4a934a;
  306. box-shadow: none;
  307. color: #4a934a;
  308. }
  309. a.success.text-center,
  310. i.success {
  311. color: #4a934a;
  312. }
  313. .dataTables_wrapper .dataTables_filter label {
  314. width: initial;
  315. }
  316. .dataTables_wrapper .dataTables_filter input {
  317. width: initial;
  318. }
  319. </style>
  320. </head>
  321. <body>
  322. <section class="body">
  323. <!-- start: header -->
  324. <header class="header">
  325. <div class="logo-container">
  326. <div class="banner-txt">設計資料庫匯入工具</div>
  327. <div class="visible-xs toggle-sidebar-left" data-toggle-class="sidebar-left-opened" data-target="html" data-fire-event="sidebar-left-opened">
  328. <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
  329. </div>
  330. </div>
  331. <!-- start: search & user box -->
  332. <div class="header-right">
  333. <span class="separator"></span>
  334. <ul class="notifications">
  335. <li>
  336. <a href="/DataBase/Upload.php" class="notification-icon" data-toggle="tooltip" title="匯入工具" data-placement="bottom">
  337. <i class="fa fa-upload"></i>
  338. </a>
  339. <a href="/Front-Page/home.php" class="notification-icon" data-toggle="tooltip" title="綜合登入入口" data-placement="bottom">
  340. <i class="fa fa-home"></i>
  341. </a>
  342. </li>
  343. </ul>
  344. <span class="separator"></span>
  345. <div id="userbox" class="userbox">
  346. <a href="#" data-toggle="dropdown">
  347. <figure class="profile-picture"> <img src="/DataBase/assets/images/!logged-user.jpg" alt="Joseph Doe" class="img-circle" data-lock-picture="/DataBase/assets/images/!logged-user.jpg" /> </figure>
  348. <div class="profile-info" data-lock-name="John Doe" data-lock-email="johndoe@JSOFT.com"> <span class="name"><?php echo $_SESSION['name'] ?></span> <span class="role"><?php echo($groupName);?></span> </div> <i class="fa custom-caret"></i>
  349. </a>
  350. <div class="dropdown-menu">
  351. <ul class="list-unstyled">
  352. <li class="divider"></li>
  353. <li> <a role="menuitem" tabindex="-1" href="/DataBase/script/php/Logout.php"><i class="fa fa-power-off"></i> Logout</a> </li>
  354. </ul>
  355. </div>
  356. </div>
  357. </div>
  358. <!-- end: search & user box -->
  359. </header>
  360. <!-- end: header -->
  361. <div class="inner-wrapper">
  362. <!-- start: sidebar -->
  363. <section role="main" class="content-body">
  364. <header class="page-header">
  365. <ul>
  366. <li>
  367. <label id="header"></label>
  368. </li>
  369. </ul>
  370. </header>
  371. <div class="row">
  372. <div class="col-md-4 col-md-offset-8">
  373. 圖示顏色含意: <i class="fa fa-info-circle info">匯入確認頁面</i> <i class="fa fa-check-circle success">此頁面資料正確</i> <i class="fa fa-exclamation-circle warning">此頁面資料有空</i> <i class="fa fa-times-circle error">此頁面檔案路徑有誤</i>
  374. </div>
  375. <div class="col-md-12">
  376. <div class="tabs">
  377. <ul class="nav nav-tabs nav-justified" id="tabs">
  378. </ul>
  379. <div class="tab-content" id="tab-content">
  380. </div>
  381. </div>
  382. </div>
  383. </div>
  384. </div>
  385. </section>
  386. </div>
  387. </section>
  388. <script type="text/javascript">
  389. var userName = "<?php echo $_SESSION['name'] ?>";
  390. var role = "<?php echo ($groupName); ?>";
  391. var right = <?php echo ($right); ?>;
  392. var val = [];
  393. var error;
  394. var tables;
  395. var searchTables = [];
  396. var tableIndex;
  397. var confirmMsg = "確定要匯入嗎?";
  398. var statusList = {
  399. "error": false,
  400. "warning": false
  401. };
  402. const statusDetail = {
  403. "error": "錯誤:檔案路徑有誤,請再次檢查檔案路徑是否正確。",
  404. "warning": "警告:有資料尚未填寫。"
  405. }
  406. const icons = {
  407. 'info': 'fa fa-info-circle',
  408. 'success': 'fa fa-check-circle',
  409. 'error': 'fa fa-times-circle',
  410. 'warning': 'fa fa-exclamation-circle',
  411. };
  412. var ErrorClass = function(settings, searchData, index, rowData) {
  413. var $td = searchTables[tableIndex].row(index).nodes().to$().find('td.ErrorClass');
  414. return $td.length;
  415. }
  416. var NullClass = function(settings, searchData, index, rowData) {
  417. var $td = searchTables[tableIndex].row(index).nodes().to$().find('td.NullClass');
  418. return $td.length;
  419. }
  420. var BothClasses = function(settings, searchData, index, rowData) {
  421. var $td = searchTables[tableIndex].row(index).nodes().to$().find('td.NullClass,td.ErrorClass');
  422. return $td.length;
  423. }
  424. $(document).ready(function() {
  425. const queryString = window.location.search;
  426. const urlParams = new URLSearchParams(queryString);
  427. var file = '<?= $file ?>';
  428. var categoryId = '<?= $category_id ?>';
  429. var projectId = '<?= $project_id ?>';
  430. var projectName = '<?= $project_name ?>';
  431. addUserImage(userName.charAt(0),role);
  432. getExcel(file, projectId, projectName, categoryId);
  433. $('#form').submit(function() {
  434. var c = confirm(confirmMsg);
  435. return c;
  436. });
  437. });
  438. function getExcel(file, projectId, projectName, categoryId) {
  439. $.ajax({
  440. url: "./getExcel.php",
  441. data: {
  442. file: file,
  443. projectId: projectId,
  444. categoryId: categoryId,
  445. projectName:projectName,
  446. },
  447. async: false,
  448. contentType: "application/json",
  449. dataType: "json",
  450. type: "GET",
  451. })
  452. .success(function(response) {
  453. tables = response.table;
  454. var info = response.info;
  455. var statuses = response.statuses;
  456. errors = response.errorLists;
  457. var projectInfo = tables["匯入資訊"];
  458. $("#header").append(projectInfo[1][0] + "-" + projectInfo[1][1]); // 16019-促進民間參與高雄市鳳山溪污水處理廠放流水回收再利用案之興建、移轉、營運
  459. for (var tab in tables) {
  460. let status = statuses[tab];
  461. let active = '';
  462. if (tab == "匯入資訊") {
  463. active = 'class="active"';
  464. }
  465. if (statusList[status] != undefined & !statusList[status]) {
  466. statusList[status] = true;
  467. confirmMsg += "\n" + statusDetail[status];
  468. }
  469. console.log(status);
  470. let icon = icons[status];
  471. $('#tabs').append(`<li ${active}><a href="#page${tab}" data-toggle="tab" class="text-center ${status}"><i class="${icon}"></i> ${tab}</a></li>`);
  472. $("#tab-content").append(`<div id="page${tab}" class="tab-pane fade"></div>`);
  473. appendTable(tables[tab], `page${tab}`);
  474. }
  475. $(`#page匯入資訊`).append("<form id='form' method='post' action='./insertExcel.php'></form>");
  476. appendTable(info, "form");
  477. // TODO: add confirm message
  478. $("#form").append(`<div class='center'><input class='submit' type='submit' value='開始匯入'><button type='button' class='submit' onClick=\"location.href='/DataBase/Upload.php'\" >重新選擇檔案</button></div>`);
  479. $("#form").append(`<input id='projectId' name='projectId' type='hidden' value='${projectId}'><input id='projectName' name='projectName' type='hidden' value='${projectName}'><input id='file' name='file' type='hidden' value='${file}'><input id='categoryId' name='categoryId' style='display:none;' value='${categoryId}'>`);
  480. })
  481. .error(function(error) {
  482. console.log(error);
  483. })
  484. .complete(function() {
  485. $('#page匯入資訊').addClass('in active')
  486. let i = 1;
  487. for (var tab in tables) {
  488. if (tab != "匯入資訊" && tab != "注意事項") {
  489. var errorList = [];
  490. if (errors[tab] != "" & errors[tab] != undefined) {
  491. errorList = errors[tab].split(',');
  492. errorList.shift();
  493. }
  494. searchTables[tab] = $('#tablepage' + tab).DataTable({
  495. dom: '<"#toolbar' + tab + '">lfrtip',
  496. "language": {
  497. "processing": "處理中...",
  498. "loadingRecords": "載入中...",
  499. "lengthMenu": "顯示 _MENU_ 項資料",
  500. "zeroRecords": "沒有符合的結果或是沒有資料",
  501. "info": "顯示第 _START_ 至 _END_ 項資料,共 _TOTAL_ 項",
  502. "infoEmpty": "顯示第 0 至 0 項資料,共 0 項",
  503. "infoFiltered": "(從 _MAX_ 項資料中過濾)",
  504. "infoPostFix": "",
  505. "search": "搜尋:",
  506. "paginate": {
  507. "first": '<i class="fa fa-step-backward"></i>',
  508. "previous": '<i class="fa fa-backward"></i>',
  509. "next": '<i class="fa fa-forward"></i>',
  510. "last": '<i class="fa fa-step-forward"></i>'
  511. },
  512. "aria": {
  513. "sortAscending": ": 升冪排列",
  514. "sortDescending": ": 降冪排列"
  515. }
  516. },
  517. "columnDefs": [{
  518. "targets": -1,
  519. "createdCell": function(td, cellData, rowData, row, col) {
  520. if (errorList.length > 0) {
  521. for (i = 0; i < errorList.length; i++) {
  522. if (errorList[i] == row) {
  523. $(td).addClass('ErrorClass');
  524. }
  525. }
  526. }
  527. }
  528. }, {
  529. "targets": '_all',
  530. "createdCell": function(td, cellData, rowData, row, col) {
  531. if (cellData == "null") {
  532. $(td).addClass('NullClass');
  533. }
  534. }
  535. }],
  536. });
  537. i++;
  538. $('#toolbar' + tab).html(`<input name="check${tab}" id="errCheck${tab}" value="error" type="radio" >僅顯示錯誤檔案路徑</input>
  539. <input name="check${tab}" id="nullCheck${tab}" value="null" type="radio" >僅顯示未填入的資料</input>
  540. <input name="check${tab}" id="nullCheck${tab}" value="both" type="radio" >顯示所有異常資料</input>
  541. <input name="check${tab}" id="nullCheck${tab}" value="all" type="radio" checked="checked">顯示所有資料</input>`);
  542. /*$(`input[name='check${tab}']`).on("click", function() {
  543. $.fn.dataTable.ext.search.pop();
  544. if ($(this).val() == "error") {
  545. $.fn.dataTable.ext.search.push(ErrorClass);
  546. } else if ($(this).val() == "null") {
  547. $.fn.dataTable.ext.search.push(NullClass);
  548. } else if ($(this).val() == "both") {
  549. $.fn.dataTable.ext.search.push(BothClasses);
  550. } else {
  551. $.fn.dataTable.ext.search.pop();
  552. }
  553. console.log(tab);
  554. searchTables["3_設計圖"].draw();
  555. });*/
  556. if (document.querySelector(`input[name="check${tab}"]`)) {
  557. document.querySelectorAll(`input[name="check${tab}"]`).forEach((elem) => {
  558. elem.addEventListener("change", function(event) {
  559. var item = event.target.value;
  560. tableIndex = event.target.parentElement.id.split('bar')[1];
  561. $.fn.dataTable.ext.search.pop();
  562. if (item == "error") {
  563. $.fn.dataTable.ext.search.push(ErrorClass);
  564. } else if (item == "null") {
  565. $.fn.dataTable.ext.search.push(NullClass);
  566. } else if (item == "both") {
  567. $.fn.dataTable.ext.search.push(BothClasses);
  568. } else {
  569. $.fn.dataTable.ext.search.pop();
  570. }
  571. console.log(tableIndex);
  572. searchTables[tableIndex].draw();
  573. });
  574. });
  575. }
  576. }
  577. }
  578. });
  579. }
  580. function appendTable(data, id) {
  581. let i = 0;
  582. table = `<table id='table${id}' class='excel'><thead>`;
  583. for (var tab in data) {
  584. table += "<tr>";
  585. for (j = 0; j < data[tab].length; j++) {
  586. if (i == 0)
  587. table += `<th>${data[tab][j]}</th>` //style="width:33%;"
  588. else
  589. table += `<td>${data[tab][j]}</td>`
  590. }
  591. table += "</tr>";
  592. if (i == 0) {
  593. table += "</thead><tbody>";
  594. }
  595. i++;
  596. }
  597. table += "</tbody></table>";
  598. $('#' + id).append(table);
  599. }
  600. </script>
  601. </body>
  602. </html>