1 Star 0 Fork 1

Ronn/json2excel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.html 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
Ronn 提交于 2022-04-16 17:53 . fix icon
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>json2excel</title>
<link rel="icon" type="image/png" href="./src/assets/img/favicon.png">
<link rel="stylesheet" href="./src/assets/css/index.css">
<script type="module" src="./src/index.js"></script>
</head>
<body>
<div id="app">
<button id="export_btn">导出EXCEL🫗</button>
<div class="input_info">
<div class="input_header">
<div class="input_item"><span>输入Excel表名:</span><input id="json_title" placeholder="请输入表名"></div>
<div class="input_item"><span>自定义字段顺序:</span><input id="json_columns" placeholder="请输入表头JSON"></div>
</div>
<textarea id="json_id" placeholder="请输入json数据"></textarea>
</div>
</div>
</body>
<script type="module">
import { excelInfo } from './src/index.js';
const export_btn = document.getElementById('export_btn');
export_btn.addEventListener('click', () => {
function strToJson(str) {
if (str) {
const json = eval('(' + str + ')');
return json;
} else {
return null;
}
}
const json_data = strToJson(document.getElementById('json_id').value);
const json_columns = strToJson(document.getElementById('json_columns').value);
const json_title = (document.getElementById('json_title').value);
if (!json_data) {
alert('json 不能为空');
return;
}
const excel = new excelInfo({
fileName: json_title || new Date().getTime(),
json_data: json_data,
json_columns: json_columns
});
excel.initDom();
excel.excelExport(isDown => {
if (isDown) {
alert('导出成功');
} else {
alert('导出失败');
}
})
});
</script>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ronn97/json2excel.git
[email protected]:ronn97/json2excel.git
ronn97
json2excel
json2excel
master

搜索帮助