Files
exceljs_practice/test.html
Cody Zhang ff9710dc08 add scripts
2020-10-08 17:31:39 +08:00

132 lines
5.2 KiB
HTML

<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<style>
table {
border: solid black 1px;
}
tr {
border: solid black 1px;
}
th {
border: solid black 1px;
}
td {
border: solid black 1px;
}
</style>
<!-- <script src="scripts/polyfill.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/@babel/polyfill@7.11.5/dist/polyfill.js"
integrity="sha256-zMiIDM5XypPGREBv9Hmb5fNhRS727Fuldppe2Gv565Y=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/exceljs@3.8.0/dist/exceljs.min.js"
integrity="sha256-FnNb+CH5ZwjbWvJBzN+0phddfKPBgExLcXGBMRhuYc8=" crossorigin="anonymous"></script>
<script src="scripts/excelJS_helper.js"></script>
<script>
document.onreadystatechange = function () {
if (document.readyState == "complete") {
document.getElementById("btnExcel").onclick = function () {
var elt = document.getElementById("table-javascript");
var wb = exhelper.tableToBook(elt);
exhelper.addTitle(wb.worksheets[0], "title test");
//wb.worksheets[0].spliceRows(1, 7);
console.log(wb);
// save file
exhelper.saveXlsx("test.xlsx", wb);
/*
wb.xlsx.writeBuffer().then(
function (result) {
exhelper.saveBlob("test.xlsx", result);
},
function (err) {
console.log("error: ", err);
}
);
*/
}
}
}
</script>
</head>
<body>
<div class="card-content">
<div id="search-result">
<div id="table-javascript_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
<div class="dt-buttons">
<button id="btnExcel" class="btn btn-info btn-sm" tabindex="0" aria-controls="table-javascript">
<span>excel</span>
</button>
</div>
<div id="table-javascript_processing" class="dataTables_processing panel panel-default"
style="display: none;">處理中...</div>
<table id="table-javascript"
class="table table-striped table-no-bordered table-hover table-responsive display no-wrap dataTable no-footer dtr-inline"
cellspacing="0" style="width: 100%;" role="grid" aria-describedby="table-javascript_info">
<thead>
<tr role="row">
<th data-title="支付工具" data-data="PaymentAgent" class="sorting_disabled" rowspan="1"
colspan="1" style="width: 225px;">支付工具</th>
<th data-title="通路名稱" data-data="StoreName" class="sorting_disabled" rowspan="1" colspan="1"
style="width: 304px;">通路名稱</th>
<th data-title="儲值筆數" data-data="DepositCount" class="sorting_disabled" rowspan="1"
colspan="1" style="width: 226px;">儲值筆數</th>
<th data-title="儲值金額" data-data="TransAmount" class="sorting_disabled" rowspan="1"
colspan="1" style="width: 227px;">儲值金額</th>
</tr>
</thead>
<tbody>
<tr role="row" class="odd">
<th rowspan="3" tabindex="0">其他</th>
<td colspan="2">3</td>
<td>4,100</td>
</tr>
<tr role="row" class="even">
<td tabindex="0" colspan="3">橘子支活動獎勵</td>
</tr>
<tr class="group">
<th>總計</th>
<th colspan="2">5</th>
</tr>
<tr role="row" class="odd">
<th rowspan="2" tabindex="0">委外代收</th>
<td>貝克漢健康事業</td>
<td>1</td>
<td>20,000</td>
</tr>
<tr class="group">
<th>總計</th>
<th>1</th>
<th>20,000</th>
</tr>
<tr class="totalSum">
<th>總計</th>
<th></th>
<th>6</th>
<th>24,300</th>
</tr>
</tbody>
</table>
<div class="dataTables_info" id="table-javascript_info" role="status" aria-live="polite">顯示第 1 至 3 項結果,共
3 項</div>
</div>
</div>
</div>
</body>
</html>