增加 layui.excel 组件

This commit is contained in:
邹景立 2021-01-26 17:35:17 +08:00
parent f2c498e4ac
commit 02158597d4
5 changed files with 41 additions and 29 deletions

View File

@ -81,7 +81,14 @@ require.config({
}
});
/*! 注册 jquery 到 require 模块 */
/*! 注册 layui 组件 */
layui.config({
base: baseRoot + 'plugs/layui_exts/',
}).extend({
excel: 'excel',
});
/*! 注册 jquery 组件 */
define('jquery', [], function () {
return layui.$;
});

View File

@ -1,11 +1,10 @@
define(['xlsx'], function () {
define(function () {
function excel(data, filename, sheetname) {
this.name = sheetname || 'sheet1';
this.work = {SheetNames: [this.name], Sheets: {}};
this.work.Sheets[this.name] = XLSX.utils.aoa_to_sheet(data);
function excel(data, filename) {
if (filename.substr(-5).toLowerCase() !== '.xlsx') filename += '.xlsx';
XLSX.writeFile(this.work, filename);
layui.use('excel', function () {
layui.excel.exportExcel(data, filename, 'xlsx')
});
}
/*! 绑定导出的事件 */

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long