```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div class="container">
<table id="backViewTable" class="table table-hover table-sm table2excel">
<tr>
<td>#</td>
<td>ID</td>
<td>姓名</td>
<td>座位号</td>
<td>操作</td>
</tr>
<tr>
<th scope="row">1</th>
<td>1234</td>
<td>李文斐</td>
<td>2楼 3排 34号 </td>
<td><input class="btn-primary" type="button" value="删除"/></td>
</tr>
<tr>
<th scope="row">2</th>
<td>2345</td>
<td>lwf</td>
<td>1楼 3排 34号</td>
<td><input class="btn-primary" type="button" value="删除"/></td>
</tr>
<tr>
<th scope="row">3</th>
<td>3456</td>
<td>Lee</td>
<td>1楼 3排 12号</td>
<td><input class="btn-primary" type="button" value="删除"/></td>
</tr>
</table>
<button class="btn btn-primary btn-sm" onclick="tablesToExcel(['backViewTable'], ['ProductDay1'], 'TestBook.xls', 'Excel')">Export to Excel</button>
</div>
<script>
var tablesToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, tmplWorkbookXML = '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">'
+ '<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"><Author>Axel Richter</Author><Created>{created}</Created></DocumentProperties>'
+ '<Styles>'
+ '<Style ss:ID="Currency"><NumberFormat ss:Format="Currency"></NumberFormat></Style>'
+ '<Style ss:ID="Date"><NumberFormat ss:Format="Medium Date"></NumberFormat></Style>'
+ '</Styles>'
+ '{worksheets}</Workbook>'
, tmplWorksheetXML = '<Worksheet ss:Name="{nameWS}"><Table>{rows}</Table></Worksheet>'
, tmplCellXML = '<Cell{attributeStyleID}{attributeFormula}><Data ss:Type="{nameType}">{data}</Data></Cell>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(tables, wsnames, wbname, appname) {
var ctx = "";
var workbookXML = "";
var worksheetsXML = "";
var rowsXML = "";
for (var i = 0; i < tables.length; i++) {
if (!tables[i].nodeType) tables[i] = document.getElementById(tables[i]);
// 控制要导出的行数
for (var j = 0; j < tables[i].rows.length; j++) {
rowsXML += '<Row>';
// 控制导出的列数(在本例中,最后一列为button,导出的文件会出错,所以导出到倒数第二列
for (var k = 0; k < tables[i].rows[j].cells.length-1; k++) {
var dataType = tables[i].rows[j].cells[k].getAttribute("data-type");
var dataStyle = tables[i].rows[j].cells[k].getAttribute("data-style");
var dataValue = tables[i].rows[j].cells[k].getAttribute("data-value");
dataValue = (dataValue)?dataValue:tables[i].rows[j].cells[k].innerHTML;
var dataFormula = tables[i].rows[j].cells[k].getAttribute("data-formula");
dataFormula = (dataFormula)?dataFormula:(appname=='Calc' && dataType=='DateTime')?dataValue:null;
ctx = { attributeStyleID: (dataStyle=='Currency' || dataStyle=='Date')?' ss:StyleID="'+dataStyle+'"':''
, nameType: (dataType=='Number' || dataType=='DateTime' || dataType=='Boolean' || dataType=='Error')?dataType:'String'
, data: (dataFormula)?'':dataValue
, attributeFormula: (dataFormula)?' ss:Formula="'+dataFormula+'"':''
};
rowsXML += format(tmplCellXML, ctx);
}
rowsXML += '</Row>'
}
ctx = {rows: rowsXML, nameWS: wsnames[i] || 'Sheet' + i};
worksheetsXML += format(tmplWorksheetXML, ctx);
rowsXML = "";
}
ctx = {created: (new Date()).getTime(), worksheets: worksheetsXML};
workbookXML = format(tmplWorkbookXML, ctx);
// 查看后台的打印输出
console.log(workbookXML);
var link = document.createElement("A");
link.href = uri + base64(workbookXML);
link.download = wbname || 'Workbook.xls';
link.target = '_blank';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
})();
</script>
</body>
</html>
```
- HTML
- 讯飞插件
- Python
- 王者荣耀
- demo_cg.py
- demo_cg_TT.py
- img.py
- MySQL
- 清空表数据
- ID自增长重置
- 用户密码及权限操作
- 外键在数据库中的作用
- MySQL增删改查语句
- DDL-数据库操作
- DDL-表操作-查询
- DDL-表操作-创建
- DDL-表操作-数据类型
- DDL-表操作-修改
- DDL-表操作-删除
- DML-语句
- DML-添加数据
- DML-修改数据
- DML-删除数据
- DQL-语法
- DQL-基本查询
- DQL-条件查询
- DQL-聚合函数
- DQL-分组查询
- DQL-排序查询
- DQL-分页查询
- DCL-介绍
- DCL-管理用户
- DCL-权限控制
- 函数
- JS
- ajax
- ajax get请求
- ajax post提交
- ajax 同时上传文本和文件到数据库(inpt text和input file)
- 路径传值+接收解析
- js 本地sessionStorage
- js Excel导出.xls
- 二维码生成插件
- VUE-CLI4
- 安装手脚架及插件
- ECharts-数据可视化
- element-ui-时间戳
- qrcode二维码生成插件
- vuedraggable-拖拽组件
- vue-drag-resize-自由拖拽、缩放组件
- gitee配置
- src
- plugins
- element.js
- echartsMixin.js
- views
- login
- login.vue
- btn.vue
- home
- home.vue
- Welcome.vue
- user
- users.vue
- router
- main.js
- App.vue
- 引入语法
- 获取路径传值
- ajax请求
- token语法
- NPM更换镜像方案
- PHP
- PHP 微信网页登录
- PHP 判断函数
- PHP 获取微信公众号openid
- PHP 实现发送模板消息(微信公众号版)
- PHP 阳历阴历转换计算生肖闰年
- PHP 接口数组形式
- PHP 同文件夹下顺序命名
- PHP 输出文件
- PHP E-mail发送
- PHP cURL资源
- PHP 远程访问控制服务器
- PHP 8.0 开启mysqli扩展
- PHP 使用 OSS 批量上传图片
- PHP md5 加密与解密
- ThinkPHP
- PT6
- TP6安装多应用
- TP5
- view渲染模板常见语法
- Visual Studio Code
- 介绍
- 插件-eslint
- vs code插件
- VSCode添加自定义模板
- SFTP
- md格式的文档
- mermaid
- frp内网穿透
- 自定义端口
- ui-china.cn
- 常用软件
- 框架
- 服务器
- 微信小程序
- 云函数 Email
- 参数传递
- 其他
- VMware虚拟机centos7设置静态ip 连接外网